From 6803e4cd3c31e6d6fc6657799b25bd1572287a7c Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Tue, 28 Mar 2023 20:09:35 +0200 Subject: [PATCH] init --- config.json | 7 +++++++ main.py | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 config.json create mode 100644 main.py diff --git a/config.json b/config.json new file mode 100644 index 0000000..065daf1 --- /dev/null +++ b/config.json @@ -0,0 +1,7 @@ +{ + "email": "email", + "access_token": "", + "refresh_token": "", + "user_id": "", + "cookie": "" +} diff --git a/main.py b/main.py new file mode 100644 index 0000000..e7a42b1 --- /dev/null +++ b/main.py @@ -0,0 +1,22 @@ +from tgtg import TgtgClient +import json + +def main(): + file = open('config.json') + config = json.load(file) + + try: + client = TgtgClient(access_token=config.get("access_token"), refresh_token=config.get("refresh_token"), user_id=config.get("user_id"), cookie=config.get("cookie")) + client.get_credentials() + except: + client = TgtgClient(email=config.get("email")) + credentials = client.get_credentials() + config.update(credentials) + with open("config.json", "w") as outfile: + json.dump(config, outfile) + favorites = client.get_favorites() + for favorite in favorites: + if (favorite.get("items_available") > 0): + print(favorite.get("display_name"), favorite.get("items_available"), "\n") +if (__name__ == "__main__"): + main()