From: leo Date: Thu, 11 Nov 2021 19:31:31 +0000 (+0100) Subject: No windows support. X-Git-Url: http://git.leonardobizzoni.com/?a=commitdiff_plain;h=205975d653f9ef9215b4d97a5df1187b1e97b1ab;p=holonotify No windows support. --- diff --git a/holonotify.py b/holonotify.py index dd8590d..00a9df7 100755 --- a/holonotify.py +++ b/holonotify.py @@ -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) diff --git a/utils.py b/utils.py index c61ead1..cf8d171 100644 --- 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):