| @@ -6,7 +6,7 @@ | |||
| import logging | |||
| import requests | |||
| import json | |||
| from config import config | |||
| from config import config, series | |||
| import os | |||
| # import time | |||
| from os import path | |||
| @@ -40,16 +40,16 @@ def create_api(choice, thetvdb_id): | |||
| 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 | |||
| API_latest = base_url + 'token=' + token + '&client_id=' + str(client_id) + '&thetvdb_id=' + thetvdb_id | |||
| return API_latest | |||
| if choice == 'info' : | |||
| base_url = 'https://api.betaseries.com/shows/display?' | |||
| API = base_url + 'token=' + token + '&client_id=' + client_id + '&thetvdb_id=' + thetvdb_id | |||
| return API | |||
| API_info = base_url + 'token=' + token + '&client_id=' + str(client_id) + '&thetvdb_id=' + str(thetvdb_id) | |||
| return API_info | |||
| if choice == 'seen': | |||
| base_url = 'https://api.betaseries.com/episodes/watched?' | |||
| API = base_url + 'token=' + token + '&client_id=' + client_id + '&id=' | |||
| return API | |||
| API_seen = base_url + 'token=' + token + '&client_id=' + str(client_id) + '&id=' | |||
| return API_seen | |||
| return False | |||
| @@ -61,7 +61,6 @@ def check_latest(thetvdb_id): | |||
| return | |||
| request = requests.get(API) | |||
| if str(request) != '<Response [200]>' : | |||
| print("Mauvaise réponse de l'api !(Check_Latest) ") | |||
| return False | |||
| @@ -124,6 +123,7 @@ def check_latest(thetvdb_id): | |||
| return | |||
| if data['seen'] == False : | |||
| print("Vous n'avez pas vu le dernier episode de cette series : ", get_title_only(thetvdb_id)) | |||
| os.remove(file_path) | |||
| create_file(file_path, episode_info) | |||
| return | |||
| @@ -155,14 +155,12 @@ def to_see(thetvdb_id): | |||
| file_path = 'latest/' + thetvdb_id + '.json' | |||
| with open(file_path) as json_file: | |||
| data = json.load(json_file) | |||
| print(data) | |||
| if data[u'seen'] == False : | |||
| message = data['serie_title'] + ' ! ' + '\n' + 'Episode: ' + str(data['episode']) + ' Saison:' + str(data['season ']) + '\n' + '\n' | |||
| return message | |||
| else : | |||
| print(u"Vous etes à jour") | |||
| return | |||
| print(u"Vous etes à jour") | |||
| return False | |||
| def seen(thetvdb_id): | |||
| # Permet de mettre un episode en 'vu' sur betaseries | |||
| @@ -178,13 +176,27 @@ def seen(thetvdb_id): | |||
| API = create_api('seen', None) | |||
| API += str(data['id']) | |||
| print(API) | |||
| # request = requests.post(API) | |||
| # if str(request) == '<Response [400]>' : | |||
| # send_message(u"Impossible de marquer l'episode comme vu(déjà vu?)") | |||
| # print(request) | |||
| # return | |||
| send_message('Done !') | |||
| return | |||
| def get_episode_code(thetvdb_id): | |||
| file_path = 'latest/' + thetvdb_id + '.json' | |||
| with open(file_path) as json_file: | |||
| data = json.load(json_file) | |||
| code = 'S' + str(data['season ']) + 'E' + str(data['episode']) | |||
| return code | |||
| def main(): | |||
| #Only here for debug git | |||
| login_beta() | |||
| print(get_title_only('354198')) | |||
| for i in range(len(series)): | |||
| id = series[i] | |||
| print(get_episode_code(id)) | |||
| if __name__ == '__main__': | |||