Added new --download-delay flag to allow throttling the download across all supported platofrms.
This commit is contained in:
7
script.py
Normal file → Executable file
7
script.py
Normal file → Executable file
@@ -36,6 +36,8 @@ from src.programMode import ProgramMode
|
|||||||
from src.reddit import Reddit
|
from src.reddit import Reddit
|
||||||
from src.store import Store
|
from src.store import Store
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
__author__ = "Ali Parlakci"
|
__author__ = "Ali Parlakci"
|
||||||
__license__ = "GPL"
|
__license__ = "GPL"
|
||||||
__version__ = "1.9.4"
|
__version__ = "1.9.4"
|
||||||
@@ -154,6 +156,7 @@ def download(submissions):
|
|||||||
try:
|
try:
|
||||||
downloadPost(details,directory)
|
downloadPost(details,directory)
|
||||||
GLOBAL.downloadedPosts.add(details['POSTID'])
|
GLOBAL.downloadedPosts.add(details['POSTID'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if GLOBAL.arguments.unsave:
|
if GLOBAL.arguments.unsave:
|
||||||
reddit.submission(id=details['POSTID']).unsave()
|
reddit.submission(id=details['POSTID']).unsave()
|
||||||
@@ -161,6 +164,10 @@ def download(submissions):
|
|||||||
reddit = Reddit().begin()
|
reddit = Reddit().begin()
|
||||||
reddit.submission(id=details['POSTID']).unsave()
|
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
|
downloadedCount += 1
|
||||||
|
|
||||||
except FileAlreadyExistsError:
|
except FileAlreadyExistsError:
|
||||||
|
|||||||
@@ -153,6 +153,11 @@ class Arguments:
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="Just saved posts into a the POSTS.json file without downloading"
|
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 == []:
|
if arguments == []:
|
||||||
|
|||||||
Reference in New Issue
Block a user