mirror of
https://github.com/KevinMidboe/bulk-downloader-for-reddit.git
synced 2026-01-10 19:25:41 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49920cc457 | ||
|
|
c70e7c2ebb | ||
|
|
3931dfff54 | ||
|
|
4a8c2377f9 | ||
|
|
8a18a42a9a | ||
|
|
6c2d748fbc | ||
|
|
8c966df105 | ||
|
|
2adf2c0451 | ||
|
|
3e3a2df4d1 | ||
|
|
7548a01019 | ||
|
|
2ab16608d5 | ||
|
|
e15f33b97a | ||
|
|
27211f993c | ||
|
|
87d3b294f7 | ||
|
|
8128378dcd |
@@ -53,7 +53,14 @@ It should redirect to a page which shows your **imgur_client_id** and **imgur_cl
|
||||
them, there.
|
||||
|
||||
## Changelog
|
||||
### [19/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/50c4a8d6d7e21d9b44a6d6d00c1811cfe9c655b1)
|
||||
### [21/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/4a8c2377f9fb4d60ed7eeb8d50aaf9a26492462a)
|
||||
- Added exclude mode
|
||||
|
||||
### [20/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/commit/7548a010198fb693841ca03654d2c9bdf5742139)
|
||||
- "0" input for no limit
|
||||
- Fixed the bug that recognizes none image direct links as image links
|
||||
|
||||
### [19/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/41cbb58db34f500a8a5ecc3ac4375bf6c3b275bb)
|
||||
- Added v.redd.it support
|
||||
- Added custom exception descriptions to FAILED.json file
|
||||
- Fixed the bug that prevents downloading some gfycat URLs
|
||||
|
||||
@@ -23,7 +23,8 @@ optional arguments:
|
||||
--saved Triggers saved mode
|
||||
--submitted Gets posts of --user
|
||||
--upvoted Gets upvoted posts of --user
|
||||
--log LOG FILE Triggers log read mode and takes a log file
|
||||
--log LOG FILE Takes a log file which created by itself (json files),
|
||||
reads posts and tries downloading them again.
|
||||
--subreddit SUBREDDIT [SUBREDDIT ...]
|
||||
Triggers subreddit mode and takes subreddit's name
|
||||
without r/. use "frontpage" for frontpage
|
||||
@@ -39,6 +40,8 @@ optional arguments:
|
||||
all
|
||||
--NoDownload Just gets the posts and store them in a file for
|
||||
downloading later
|
||||
--exclude {imgur,gfycat,direct,self} [{imgur,gfycat,direct,self} ...]
|
||||
Do not download specified links
|
||||
```
|
||||
|
||||
# Examples
|
||||
|
||||
55
script.py
55
script.py
@@ -22,7 +22,7 @@ from src.tools import (GLOBAL, createLogFile, jsonFile, nameCorrector,
|
||||
|
||||
__author__ = "Ali Parlakci"
|
||||
__license__ = "GPL"
|
||||
__version__ = "1.2.0"
|
||||
__version__ = "1.3.0"
|
||||
__maintainer__ = "Ali Parlakci"
|
||||
__email__ = "parlakciali@gmail.com"
|
||||
|
||||
@@ -143,6 +143,12 @@ def parseArguments(arguments=[]):
|
||||
" for downloading later",
|
||||
action="store_true",
|
||||
default=False)
|
||||
|
||||
parser.add_argument("--exclude",
|
||||
nargs="+",
|
||||
help="Do not download specified links",
|
||||
choices=["imgur","gfycat","direct","self"],
|
||||
type=str)
|
||||
|
||||
if arguments == []:
|
||||
return parser.parse_args()
|
||||
@@ -318,9 +324,37 @@ class PromptUser:
|
||||
if Path(GLOBAL.arguments.log ).is_file():
|
||||
break
|
||||
|
||||
GLOBAL.arguments.exclude = []
|
||||
|
||||
sites = ["imgur","gfycat","direct","self"]
|
||||
|
||||
excludeInput = input("exclude: ").lower()
|
||||
if excludeInput in sites and excludeInput != "":
|
||||
GLOBAL.arguments.exclude = [excludeInput]
|
||||
|
||||
while not excludeInput == "":
|
||||
while True:
|
||||
excludeInput = input("exclude: ").lower()
|
||||
if not excludeInput in sites or excludeInput in GLOBAL.arguments.exclude:
|
||||
break
|
||||
elif excludeInput == "":
|
||||
break
|
||||
else:
|
||||
GLOBAL.arguments.exclude.append(excludeInput)
|
||||
|
||||
for i in range(len(GLOBAL.arguments.exclude)):
|
||||
if " " in GLOBAL.arguments.exclude[i]:
|
||||
inputWithWhitespace = GLOBAL.arguments.exclude[i]
|
||||
del GLOBAL.arguments.exclude[i]
|
||||
for siteInput in inputWithWhitespace.split():
|
||||
if siteInput in sites and siteInput not in GLOBAL.arguments.exclude:
|
||||
GLOBAL.arguments.exclude.append(siteInput)
|
||||
|
||||
while True:
|
||||
try:
|
||||
GLOBAL.arguments.limit = int(input("\nlimit: "))
|
||||
GLOBAL.arguments.limit = int(input("\nlimit (0 for none): "))
|
||||
if GLOBAL.arguments.limit == 0:
|
||||
GLOBAL.arguments.limit = None
|
||||
break
|
||||
except ValueError:
|
||||
pass
|
||||
@@ -442,6 +476,10 @@ def download(submissions):
|
||||
downloadedCount = subsLenght
|
||||
duplicates = 0
|
||||
BACKUP = {}
|
||||
if GLOBAL.arguments.exclude is not None:
|
||||
ToBeDownloaded = GLOBAL.arguments.exclude
|
||||
else:
|
||||
ToBeDownloaded = []
|
||||
|
||||
FAILED_FILE = createLogFile("FAILED")
|
||||
|
||||
@@ -464,7 +502,7 @@ def download(submissions):
|
||||
|
||||
directory = GLOBAL.directory / submissions[i]['postSubreddit']
|
||||
|
||||
if submissions[i]['postType'] == 'imgur':
|
||||
if submissions[i]['postType'] == 'imgur' and not 'imgur' in ToBeDownloaded:
|
||||
print("IMGUR",end="")
|
||||
|
||||
while int(time.time() - lastRequestTime) <= 2:
|
||||
@@ -527,7 +565,7 @@ def download(submissions):
|
||||
)
|
||||
downloadedCount -= 1
|
||||
|
||||
elif submissions[i]['postType'] == 'gfycat':
|
||||
elif submissions[i]['postType'] == 'gfycat' and not 'gfycat' in ToBeDownloaded:
|
||||
print("GFYCAT")
|
||||
try:
|
||||
Gfycat(directory,submissions[i])
|
||||
@@ -547,7 +585,7 @@ def download(submissions):
|
||||
FAILED_FILE.add({int(i+1):[str(exception),submissions[i]]})
|
||||
downloadedCount -= 1
|
||||
|
||||
elif submissions[i]['postType'] == 'direct':
|
||||
elif submissions[i]['postType'] == 'direct' and not 'direct' in ToBeDownloaded:
|
||||
print("DIRECT")
|
||||
try:
|
||||
Direct(directory,submissions[i])
|
||||
@@ -562,7 +600,7 @@ def download(submissions):
|
||||
FAILED_FILE.add({int(i+1):[str(exception),submissions[i]]})
|
||||
downloadedCount -= 1
|
||||
|
||||
elif submissions[i]['postType'] == 'self':
|
||||
elif submissions[i]['postType'] == 'self' and not 'self' in ToBeDownloaded:
|
||||
print("SELF")
|
||||
try:
|
||||
Self(directory,submissions[i])
|
||||
@@ -666,7 +704,10 @@ if __name__ == "__main__":
|
||||
GLOBAL.directory = Path(".\\")
|
||||
print("\nQUITTING...")
|
||||
except Exception as exception:
|
||||
logging.error("Runtime error!", exc_info=full_exc_info(sys.exc_info()))
|
||||
if GLOBAL.directory is None:
|
||||
GLOBAL.directory = Path(".\\")
|
||||
logging.error(sys.exc_info()[0].__name__,
|
||||
exc_info=full_exc_info(sys.exc_info()))
|
||||
print(log_stream.getvalue())
|
||||
|
||||
input("Press enter to quit\n")
|
||||
|
||||
@@ -397,7 +397,7 @@ def checkIfMatching(submission):
|
||||
imgurCount += 1
|
||||
return details
|
||||
|
||||
elif isDirectLink(submission.url) is not None:
|
||||
elif isDirectLink(submission.url) is not False:
|
||||
details['postType'] = 'direct'
|
||||
details['postURL'] = isDirectLink(submission.url)
|
||||
directCount += 1
|
||||
|
||||
Reference in New Issue
Block a user