From acd78451826fc04aac6bd861ce427c63a009340f Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 30 Apr 2020 09:07:54 +0200 Subject: [PATCH] =?UTF-8?q?Fonction=20pour=20cr=C3=A9er=20=20le=20fichier?= =?UTF-8?q?=20+=20utilisation=20de=20telegram=5Fapi.py=20pour=20envoyer=20?= =?UTF-8?q?un=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- betaseries.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/betaseries.py b/betaseries.py index 2d7dd55..00da14f 100644 --- a/betaseries.py +++ b/betaseries.py @@ -78,9 +78,8 @@ def check_latest(thetvdb_id): # Si le fichier n'existe pas. Nous n'avons rien à comparer : Par définition nous sauvegardons les informations. if path.exists(file_path) == False : - print("Fichier inexistant.. creation en cours...") - with open(file_path, "w") as write_file: - json.dump(episode_info, write_file) + print("Fichier inexistant ... Creation du fichier ") + create_file(file_path, episode_info) @@ -107,6 +106,7 @@ def check_latest(thetvdb_id): send_message(message) #On supprime le fichier, et on le ré-écris avec les nouvelles informations. os.remove(file_path) + create_file(file_path, episode_info) return if latest_season == saved_season: @@ -115,9 +115,16 @@ def check_latest(thetvdb_id): message = 'Nouvel episode de ' + title + ' ! ' + 'S' + str(latest_season) + 'E' + str(latest_episode) send_message(message) os.remove(file_path) + create_file(file_path, episode_info) return print("Aucun changement") + +def create_file(file_path, episode_info): + with open(file_path, "w") as write_file: + json.dump(episode_info, write_file) + +