From 3eb384695e81a2cb6af3ea6aba1980a5deaf361d Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 30 Apr 2020 18:15:28 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'notification.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notification.py | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/notification.py b/notification.py index 074c3c9..87ca5ec 100644 --- a/notification.py +++ b/notification.py @@ -2,41 +2,21 @@ # -*- coding: utf-8 -*- # This program is dedicated to the public domain under the CC0 license. # Telegram - Betaseries + import logging import requests import json from bot import user_id, token_bot, client_id -from betaseries import login_beta, create_api +from betaseries import login_beta, create_api, check_latest from telegram.ext import Updater, CommandHandler - -#Love Is War / Une serie pour tester le programme. -thetvdb_id= '354198' +from config import series +import os.path +from os import path +import datetime -# def create_api(choice): - # if choice == 'latest' : - # base_url = 'https://api.betaseries.com/episodes/latest?' - # API = base_url + 'token=' + token + '&client_id=' + client_id + '&thetvdb_id=' + thetvdb_id - # return API - -def check_latest(): - API = create_api('latest') - request = requests.get(API) - if str(request) != '' : - return False - show = request.json() - episode = show['episode'] - - title = episode['show'] - print("Titre de la serie : ", str(title['title'])) - - # print("Episode : ", data[episode], " Saison : ", data[season] ) - - def main(): - global token - token = login_beta() print("------------------------------") print("Votre ID Telegram : ", user_id) @@ -47,12 +27,18 @@ def main(): print("\n\t") print("Pour arreter le script : CTRL+Z") - check_latest() + now = datetime.datetime.now() + print (now.strftime("%Y-%m-%d %H:%M:%S")) + for i in range(len(series)): + thetvdb_id = series[i] + check_latest(thetvdb_id) - print("Erreur ! Fin de la boucle") - - + + + + + #print("Erreur ! Fin de la boucle") if __name__ == '__main__':