From fc19a690bd2445d8f27941dab103d9cde506dc6f Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Tue, 21 Jun 2022 12:32:46 +0100 Subject: [PATCH] loadDownloadHistory --- GoGoDownloaderCLI.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/GoGoDownloaderCLI.py b/GoGoDownloaderCLI.py index 202d8fd..64fe3c1 100644 --- a/GoGoDownloaderCLI.py +++ b/GoGoDownloaderCLI.py @@ -1,7 +1,24 @@ from backend import * +import json +import io +import os + + +def loadDownloadHistory(): + if os.path.isfile("./downloadHistory.json") and os.access( + "./downloadHistory.json", os.R_OK + ): + return json.load(open("./downloadHistory.json")) + else: + print("Either file is missing or is not readable, creating file...") + with io.open(os.path.join("./", "downloadHistory.json"), "w") as db_file: + db_file.write(json.dumps([])) + return json.load(open("./downloadHistory.json")) def main(): + dh = loadDownloadHistory() + config = config_check() downloader = gogoanime( config,