From 79d85e32b85de123d2d90b1fed32a9dbbc96d5b9 Mon Sep 17 00:00:00 2001 From: Javinator9889 Date: Mon, 18 Jun 2018 17:33:20 +0200 Subject: [PATCH] First commit of the application - created methods for main and first setup --- App/.idea/deployment.xml | 14 ++++++ .../inspectionProfiles/Project_Default.xml | 27 +++++++++++ App/.idea/vcs.xml | 6 +++ App/application.py | 47 +++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 App/.idea/deployment.xml create mode 100644 App/.idea/inspectionProfiles/Project_Default.xml create mode 100644 App/.idea/vcs.xml create mode 100644 App/application.py diff --git a/App/.idea/deployment.xml b/App/.idea/deployment.xml new file mode 100644 index 0000000..45d90b0 --- /dev/null +++ b/App/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App/.idea/inspectionProfiles/Project_Default.xml b/App/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..bb2ce98 --- /dev/null +++ b/App/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,27 @@ + + + + \ No newline at end of file diff --git a/App/.idea/vcs.xml b/App/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/App/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/App/application.py b/App/application.py new file mode 100644 index 0000000..a36e67e --- /dev/null +++ b/App/application.py @@ -0,0 +1,47 @@ +from argparse import ArgumentParser, Namespace + + +def main(arguments: Namespace): + from os import path + token = arguments.token + youtube_api_key = arguments.youtube + creator_id = arguments.creator + must_show_version = arguments.version + if must_show_version: + print("Version") + exit(0) + if not path.exists("app_data.dict"): + if not token: + ValueError("You must add token at least the first time you execute this app") + elif not youtube_api_key: + ValueError("You must include the YouTube API Key at least the first time you execute this app") + elif not creator_id: + ValueError("You must include the creator ID (Telegram) at least the first time you execute this app") + else: + with open("app_data.dict", "wb") as app_data_file: + import pickle + app_data = {"TOKEN": token, + "YT_API": youtube_api_key, + "CREATOR_ID": creator_id} + pickle.dump(app_data, app_data_file, pickle.HIGHEST_PROTOCOL) + + +if __name__ == '__main__': + args = ArgumentParser() + args.add_argument("-t", + "--token", + help="Telegram token obtained via BotFather", + type=str) + args.add_argument("-y", + "--youtube", + help="YouTube API Key", + type=str) + args.add_argument("-c", + "--creator", + help="Telegram ID of the creator", + type=int) + args.add_argument("-v", + "--version", + help="Application version", + action="store_true") + main(args.parse_args())