From 2c99c584a5ae993d31e5241e80a37649f0dcca7f Mon Sep 17 00:00:00 2001 From: Dagmawi Biru Date: Sun, 27 Dec 2020 19:26:47 -0600 Subject: [PATCH 1/2] Added new --download-delay flag to allow throttling the download across all supported platofrms. --- script.py | 9 ++++++++- src/arguments.py | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) mode change 100644 => 100755 script.py diff --git a/script.py b/script.py old mode 100644 new mode 100755 index 1eda96c..c009015 --- a/script.py +++ b/script.py @@ -36,6 +36,8 @@ from src.programMode import ProgramMode from src.reddit import Reddit from src.store import Store +from time import sleep + __author__ = "Ali Parlakci" __license__ = "GPL" __version__ = "1.9.4" @@ -154,13 +156,18 @@ def download(submissions): try: downloadPost(details,directory) GLOBAL.downloadedPosts.add(details['POSTID']) + try: if GLOBAL.arguments.unsave: reddit.submission(id=details['POSTID']).unsave() except InsufficientScope: reddit = Reddit().begin() reddit.submission(id=details['POSTID']).unsave() - + + if GLOBAL.arguments.download_delay: + print(f"Delaying next download for {GLOBAL.arguments.download_delay} seconds...") + sleep(GLOBAL.arguments.download_delay) + downloadedCount += 1 except FileAlreadyExistsError: diff --git a/src/arguments.py b/src/arguments.py index dd7c0e9..9f3b71a 100644 --- a/src/arguments.py +++ b/src/arguments.py @@ -153,6 +153,11 @@ class Arguments: action="store_true", help="Just saved posts into a the POSTS.json file without downloading" ) + parser.add_argument("--download-delay", + metavar="DELAY", + type=int, + help="Amount, in seconds, to delay before beginning the next item in the download queue" + ) if arguments == []: From 99c1e4c455a0870b4d46670982f27b01eb2abb04 Mon Sep 17 00:00:00 2001 From: Ali Parlakci Date: Fri, 26 Mar 2021 13:06:17 +0300 Subject: [PATCH 2/2] Add documentation for --downloaded-delay --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index da98663..00a554a 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,9 @@ Takes a file directory as a parameter and skips the posts if it matches with the Example usage: **`--downloaded-posts D:\bdfr\ALL_POSTS.txt`** +## **`--downloaded-delay`** +When specified, it delays every download for given seconds. + ## ❔ FAQ ### I am running the script on a headless machine or on a remote server. How can I authenticate my reddit account?