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) + +