| @@ -0,0 +1,79 @@ | |||||
| #!/usr/bin/env python | |||||
| # -*- coding: utf-8 -*- | |||||
| import json, os | |||||
| from os import path | |||||
| import sys | |||||
| def series(): | |||||
| if path.exists('watched_series.json') == False : | |||||
| print("Le fichier watched_series.json n'existe pas") | |||||
| else : | |||||
| print("Le fichier watched_series.json existe.. On le supprime") | |||||
| os.remove('watched_series.json') | |||||
| series = sys.argv | |||||
| series.pop(0) | |||||
| with open('watched_series.json', 'w') as json_file: | |||||
| config = json.dump(series, json_file) | |||||
| print("Le fichier watched_series.json a bien été créé") | |||||
| def config(): | |||||
| if len(sys.argv) != 7 : | |||||
| print("Il n'y a pas le bon nombre d'argument") | |||||
| sys.exit() | |||||
| client_id = sys.argv[2] | |||||
| login = sys.argv[3] | |||||
| password = sys.argv[4] | |||||
| user_id = sys.argv[5] | |||||
| token_bot = sys.argv[6] | |||||
| if path.exists('user_config.json') == False : | |||||
| print("Le fichier user_config.json n'existe pas") | |||||
| else : | |||||
| print("Le fichier user_config existe.. On le supprime") | |||||
| os.remove('user_config.json') | |||||
| config = {"client_id" : client_id, | |||||
| "login" : login, | |||||
| "password" : password, | |||||
| "user_id" : user_id, | |||||
| "token_bot" : token_bot} | |||||
| print("Dictionnaire de la configuration", config) | |||||
| with open('user_config.json', 'w') as json_file: | |||||
| config = json.dump(config, json_file) | |||||
| print("Le fichier user_config a bien été créé") | |||||
| return | |||||
| if len(sys.argv) == 1 : | |||||
| print("Veuillez correctement lancer la commande ! \n") | |||||
| print("Pour configurer le dictionnaire : python3 generate_config.py config CLIENT_ID LOGIN PASSWORD USER_ID TOKEN_BOT \n") | |||||
| print("Pour configurer les séries surveillées : python3 generate_config.py series THETVDB_ID1 THETVDB_ID2 THETVDB_ID3") | |||||
| sys.exit() | |||||
| if sys.argv[1] == "config": | |||||
| config() | |||||
| sys.exit() | |||||
| elif sys.argv[1] == "series" : | |||||
| series() | |||||
| sys.exit() | |||||
| else : | |||||
| print("Longueur de la liste : ", len(sys.argv)) | |||||
| print("Veuillez correctement lancer la commande ! \n") | |||||
| print("Pour configurer le dictionnaire : python3 generate_config.py config CLIENT_ID LOGIN PASSWORD USER_ID TOKEN_BOT \n") | |||||
| print("Pour configurer les séries surveillées : python3 generate_config.py series THETVDB_ID1 THETVDB_ID2 THETVDB_ID3") | |||||