]> git.leonardobizzoni.com Git - holonotify/commitdiff
No windows support.
authorleo <leo@EnvyPhoenix.lan>
Thu, 11 Nov 2021 19:31:31 +0000 (20:31 +0100)
committerleo <leo@EnvyPhoenix.lan>
Thu, 11 Nov 2021 19:31:31 +0000 (20:31 +0100)
holonotify.py
utils.py

index dd8590db0075ec65a43acfdcebd66edbabfaf3cd..00a9df7cc55bd1b4ff20c83229d1df662052fcfe 100755 (executable)
@@ -1,22 +1,25 @@
 #!/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()
@@ -26,6 +29,7 @@ def updateValues():
         live = holoapi["live"]
         ended = holoapi["ended"]
 
+# --------------------------------------
 def main():
     updateValues()
     for ch in live:
@@ -40,23 +44,18 @@ def main():
         # 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)
@@ -70,17 +69,17 @@ def linuxCheckProc():
                 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)
index c61ead15f95d62092e21d1a9dd19c4f2764e12f6..cf8d171b23ad767dc6580050e5bf765884fd1a59 100644 (file)
--- a/utils.py
+++ b/utils.py
@@ -1,5 +1,4 @@
 import os
-import platform
 
 def getBlacklist():
     blacklist = list()
@@ -18,10 +17,7 @@ def getBlacklist():
     return blacklist
 
 def getIcon(name):
-    if(platform.system() == "Windows"):
-        abspath = os.path.dirname(os.path.abspath(__file__)) + "\\Icons\\"
-    else:
-        abspath = os.path.dirname(os.path.abspath(__file__)) + "/Icons/"
+    abspath = os.path.dirname(os.path.abspath(__file__)) + "/Icons/"
 
     # JP
     if ("フブキ" in name):