mirror of
https://github.com/KevinMidboe/bulk-downloader-for-reddit.git
synced 2025-10-29 17:40:15 +00:00
Added verbose mode
This commit is contained in:
@@ -10,13 +10,13 @@ usage: script.py [-h] [--directory DIRECTORY] [--link link] [--saved]
|
|||||||
[--subreddit SUBREDDIT [SUBREDDIT ...]]
|
[--subreddit SUBREDDIT [SUBREDDIT ...]]
|
||||||
[--multireddit MULTIREDDIT] [--user redditor]
|
[--multireddit MULTIREDDIT] [--user redditor]
|
||||||
[--search query] [--sort SORT TYPE] [--limit Limit]
|
[--search query] [--sort SORT TYPE] [--limit Limit]
|
||||||
[--time TIME_LIMIT] [--NoDownload]
|
[--time TIME_LIMIT] [--NoDownload] [--verbose]
|
||||||
|
|
||||||
This program downloads media from reddit posts
|
This program downloads media from reddit posts
|
||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--directory DIRECTORY
|
--directory DIRECTORY, -d DIRECTORY
|
||||||
Specifies the directory where posts will be downloaded
|
Specifies the directory where posts will be downloaded
|
||||||
to
|
to
|
||||||
--link link, -l link Get posts from link
|
--link link, -l link Get posts from link
|
||||||
@@ -40,6 +40,7 @@ optional arguments:
|
|||||||
all
|
all
|
||||||
--NoDownload Just gets the posts and store them in a file for
|
--NoDownload Just gets the posts and store them in a file for
|
||||||
downloading later
|
downloading later
|
||||||
|
--verbose, -v Verbose Mode
|
||||||
```
|
```
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ def parseArguments(arguments=[]):
|
|||||||
description="This program downloads " \
|
description="This program downloads " \
|
||||||
"media from reddit " \
|
"media from reddit " \
|
||||||
"posts")
|
"posts")
|
||||||
parser.add_argument("--directory",
|
parser.add_argument("--directory","-d",
|
||||||
help="Specifies the directory where posts will be " \
|
help="Specifies the directory where posts will be " \
|
||||||
"downloaded to",
|
"downloaded to",
|
||||||
metavar="DIRECTORY")
|
metavar="DIRECTORY")
|
||||||
@@ -144,6 +144,11 @@ def parseArguments(arguments=[]):
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
default=False)
|
default=False)
|
||||||
|
|
||||||
|
parser.add_argument("--verbose","-v",
|
||||||
|
help="Verbose Mode",
|
||||||
|
action="store_true",
|
||||||
|
default=False)
|
||||||
|
|
||||||
|
|
||||||
if arguments == []:
|
if arguments == []:
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import webbrowser
|
import webbrowser
|
||||||
@@ -306,6 +307,7 @@ def redditSearcher(posts,SINGLE_POST=False):
|
|||||||
|
|
||||||
allPosts = {}
|
allPosts = {}
|
||||||
|
|
||||||
|
print("GETTING POSTS")
|
||||||
postsFile = createLogFile("POSTS")
|
postsFile = createLogFile("POSTS")
|
||||||
|
|
||||||
if SINGLE_POST:
|
if SINGLE_POST:
|
||||||
@@ -326,40 +328,53 @@ def redditSearcher(posts,SINGLE_POST=False):
|
|||||||
if result is not None:
|
if result is not None:
|
||||||
details = result
|
details = result
|
||||||
orderCount += 1
|
orderCount += 1
|
||||||
printSubmission(submission,subCount,orderCount)
|
if GLOBAL.arguments.verbose:
|
||||||
|
printSubmission(submission,subCount,orderCount)
|
||||||
subList.append(details)
|
subList.append(details)
|
||||||
|
|
||||||
postsFile.add({subCount:[details]})
|
postsFile.add({subCount:[details]})
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for submission in posts:
|
try:
|
||||||
subCount += 1
|
for submission in posts:
|
||||||
|
subCount += 1
|
||||||
|
|
||||||
try:
|
if subCount % 100 == 0 and not GLOBAL.arguments.verbose:
|
||||||
details = {'postId':submission.id,
|
sys.stdout.write("• ")
|
||||||
'postTitle':submission.title,
|
sys.stdout.flush()
|
||||||
'postSubmitter':str(submission.author),
|
|
||||||
'postType':None,
|
|
||||||
'postURL':submission.url,
|
|
||||||
'postSubreddit':submission.subreddit.display_name}
|
|
||||||
except AttributeError:
|
|
||||||
continue
|
|
||||||
|
|
||||||
result = checkIfMatching(submission)
|
if subCount % 1000 == 0:
|
||||||
|
sys.stdout.write("\n")
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
if result is not None:
|
try:
|
||||||
details = result
|
details = {'postId':submission.id,
|
||||||
orderCount += 1
|
'postTitle':submission.title,
|
||||||
printSubmission(submission,subCount,orderCount)
|
'postSubmitter':str(submission.author),
|
||||||
subList.append(details)
|
'postType':None,
|
||||||
|
'postURL':submission.url,
|
||||||
|
'postSubreddit':submission.subreddit.display_name}
|
||||||
|
except AttributeError:
|
||||||
|
continue
|
||||||
|
|
||||||
allPosts[subCount] = [details]
|
result = checkIfMatching(submission)
|
||||||
|
|
||||||
|
if result is not None:
|
||||||
|
details = result
|
||||||
|
orderCount += 1
|
||||||
|
if GLOBAL.arguments.verbose:
|
||||||
|
printSubmission(submission,subCount,orderCount)
|
||||||
|
subList.append(details)
|
||||||
|
|
||||||
|
allPosts[subCount] = [details]
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("\nKeyboardInterrupt",end="")
|
||||||
|
|
||||||
postsFile.add(allPosts)
|
postsFile.add(allPosts)
|
||||||
|
|
||||||
if not len(subList) == 0:
|
if not len(subList) == 0:
|
||||||
print(
|
print(
|
||||||
"\nTotal of {} submissions found!\n"\
|
"\n\nTotal of {} submissions found!\n"\
|
||||||
"{} GFYCATs, {} IMGURs, {} EROMEs, {} DIRECTs and {} SELF POSTS\n"
|
"{} GFYCATs, {} IMGURs, {} EROMEs, {} DIRECTs and {} SELF POSTS\n"
|
||||||
.format(
|
.format(
|
||||||
len(subList),
|
len(subList),
|
||||||
|
|||||||
11
src/tools.py
11
src/tools.py
@@ -102,11 +102,12 @@ def printToFile(*args, **kwargs):
|
|||||||
|
|
||||||
if not path.exists(folderDirectory):
|
if not path.exists(folderDirectory):
|
||||||
makedirs(folderDirectory)
|
makedirs(folderDirectory)
|
||||||
|
|
||||||
with io.open(
|
if not "file" in kwargs:
|
||||||
folderDirectory / "CONSOLE_LOG.txt","a",encoding="utf-8"
|
with io.open(
|
||||||
) as FILE:
|
folderDirectory / "CONSOLE_LOG.txt","a",encoding="utf-8"
|
||||||
print(*args, file=FILE, **kwargs)
|
) as FILE:
|
||||||
|
print(*args, file=FILE, **kwargs)
|
||||||
|
|
||||||
def nameCorrector(string):
|
def nameCorrector(string):
|
||||||
"""Swap strange characters from given string
|
"""Swap strange characters from given string
|
||||||
|
|||||||
Reference in New Issue
Block a user