Created
          September 7, 2020 09:03 
        
      - 
      
 - 
        
Save KennFatt/eb7e2ac6a43bb61e9f1a51a5c4954277 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import notify2 | |
| import requests | |
| import pathlib | |
| import os | |
| APP_NAME = "notifier" | |
| IMG_NAME = "_notifier" | |
| TMP_DIR = pathlib.Path(f"/tmp/{IMG_NAME}") | |
| def fetch_image(url: str) -> bool: | |
| if TMP_DIR.is_file(): | |
| os.remove(TMP_DIR) | |
| try: | |
| response = requests.get(url) | |
| if response.status_code == 200: | |
| with open(TMP_DIR, "wb") as f: | |
| f.write(response.content) | |
| finally: | |
| return TMP_DIR.is_file() | |
| if fetch_image("https://i.scdn.co/image/ab67616d0000b273203c89bd4391468eea4cc3f5"): | |
| notify2.init(APP_NAME) | |
| notify2.Notification(summary="Summary", message="Body", icon=str(TMP_DIR)).show() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment