def playlist(): try: with open('Cache/playlist.json', 'r') as file: Cached = json.load(file) data = requests.get( f'https://api.peely.de/v1/playlists?lang={SETTINGS.lang}') new = data.json() if data.status_code != 200: return except: return if new["data"]["playlists"] != Cached["data"]["playlists"]: for i in new["data"]["playlists"]: if i not in Cached["data"]["playlists"]: print("NEW Playlist") try: playlist_id = i["playlist_id"] _type = i["_type"] image = i["image"] MODULES.tweet_image( url=i["image"], message=get_text( "playlist") + f"\n\nName:\n{playlist_id}\n\nLink:\n{image}") except: MODULES.post_text(text=get_text( "playlist") + f"\n\nName:\n{i['playlist_id']}") with open('Cache/playlist.json', 'w') as file: json.dump(new, file)
def tournament(): try: with open('Cache/tournament.json', 'r') as file: Cached = json.load(file) data = requests.get( f'https://api.peely.de/v1/tournaments?lang={SETTINGS.lang}') new = data.json() if data.status_code != 200: return except: return if new["data"]["tournaments"] != Cached["data"]["tournaments"]: for i in new["data"]["tournaments"]: if i not in Cached["data"]["tournaments"]: name = i["name"] short_description = i["short_description"] try: MODULES.tweet_image( url=i["image"], message=get_text( "tournament") + f"\n\nName:\n{name}\n\nDesc:\n{short_description}") except: MODULES.post_text(text=get_text( "tournament") + f"\n\nName:\n{name}\n\Desc:\n{short_description}") print("NEW Tournament") with open('Cache/tournament.json', 'w') as file: json.dump(new, file, indent=3)
def staging(): try: with open('Cache/staging.json', 'r', encoding="utf8") as file: Cached = json.load(file) data = requests.get( 'https://api.peely.de/v1/staging') new = data.json() if data.status_code != 200: return except: return if Cached["data"]["staging"] != new["data"]["staging"]: print("NEW Staging Server") MODULES.post_text(text=new["data"]["staging"] + f" " + get_text("staging")) with open('Cache/staging.json', 'w', encoding="utf8") as file: json.dump(new, file, indent=3)
def emergencynotice(): try: with open('Cache/notice.json', 'r') as file: Cached = json.load(file) data = requests.get( f'https://api.peely.de/v1/notices?lang={SETTINGS.lang}') new = data.json() if data.status_code != 200: return except: return if new["data"]["messages"] != Cached["data"]["messages"]: for i in new["data"]["messages"]: if i not in Cached["data"]["messages"]: title = i["title"] body = i["body"] MODULES.post_text(text=f"{title}\n{body}") print("NEW Notice") with open('Cache/notice.json', 'w') as file: json.dump(new, file, indent=3)