#!/usr/bin/env python
+# --------------------------------------
+# -- Imports:
import os
import time
-import platform
+import psutil
import urllib.request
import json
import utils
+# --------------------------------------
+# -- Variables:
liveAnnouced = list()
live = list()
ended = list()
blacklist = list()
-running = True
-checkedPs = False
-psCount = 0
+# --------------------------------------
+# -- Functions:
def updateValues():
global live, ended, blacklist
blacklist = utils.getBlacklist()
live = holoapi["live"]
ended = holoapi["ended"]
+# --------------------------------------
def main():
updateValues()
for ch in live:
# check if the live has already been announces and its not blacklisted
if(chName not in liveAnnouced and notBlacklist):
chIcon = utils.getIcon(chName)
-
- if(platform.system() == "Windows"):
- from plyer import notification
- notification.notify(title=chName + " is live!", message=ch["title"])
- else:
- os.system(f'''notify-send -i {chIcon} "{chName} is live!" "{ch["title"]}"''')
+ os.system(f'''notify-send -i {chIcon} "{chName} is live!" "{ch["title"]}"''')
liveAnnouced.append(chName)
# check if the live has ended and remove it from the live already announced
if(ch["yt_video_key"] in ended):
liveAnnouced.remove(ch["channel"]["name"])
-def linuxCheckProc():
+# --------------------------------------
+def checkProc():
global checkedPs, psCount, running
- if checkedPs == False and platform.system() == "Linux":
- import psutil
+ if checkedPs == False:
for pid in psutil.pids():
try:
p = psutil.Process(pid)
continue
checkedPs = True
-def windowsCheckProc():
- # TODO
- pass
-
+# --------------------------------------
+# -- Main:
if __name__ == "__main__":
+ global checkedPs, psCount, running
+ running = True
+ checkedPs = False
+ psCount = 0
+
while running:
main()
-
- # If there's another instance running, show who's live and quit
- linuxCheckProc()
- windowsCheckProc()
+ checkProc()
if running:
time.sleep(60*5)