mirror of
https://github.com/KevinMidboe/bulk-downloader-for-reddit.git
synced 2026-01-19 07:36:01 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49920cc457 | ||
|
|
c70e7c2ebb | ||
|
|
3931dfff54 | ||
|
|
4a8c2377f9 | ||
|
|
8a18a42a9a | ||
|
|
6c2d748fbc | ||
|
|
8c966df105 |
@@ -53,6 +53,9 @@ It should redirect to a page which shows your **imgur_client_id** and **imgur_cl
|
|||||||
them, there.
|
them, there.
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
### [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)
|
### [20/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/commit/7548a010198fb693841ca03654d2c9bdf5742139)
|
||||||
- "0" input for no limit
|
- "0" input for no limit
|
||||||
- Fixed the bug that recognizes none image direct links as image links
|
- Fixed the bug that recognizes none image direct links as image links
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ optional arguments:
|
|||||||
--saved Triggers saved mode
|
--saved Triggers saved mode
|
||||||
--submitted Gets posts of --user
|
--submitted Gets posts of --user
|
||||||
--upvoted Gets upvoted 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 ...]
|
--subreddit SUBREDDIT [SUBREDDIT ...]
|
||||||
Triggers subreddit mode and takes subreddit's name
|
Triggers subreddit mode and takes subreddit's name
|
||||||
without r/. use "frontpage" for frontpage
|
without r/. use "frontpage" for frontpage
|
||||||
@@ -39,6 +40,8 @@ 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
|
||||||
|
--exclude {imgur,gfycat,direct,self} [{imgur,gfycat,direct,self} ...]
|
||||||
|
Do not download specified links
|
||||||
```
|
```
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|||||||
51
script.py
51
script.py
@@ -22,7 +22,7 @@ from src.tools import (GLOBAL, createLogFile, jsonFile, nameCorrector,
|
|||||||
|
|
||||||
__author__ = "Ali Parlakci"
|
__author__ = "Ali Parlakci"
|
||||||
__license__ = "GPL"
|
__license__ = "GPL"
|
||||||
__version__ = "1.2.1"
|
__version__ = "1.3.0"
|
||||||
__maintainer__ = "Ali Parlakci"
|
__maintainer__ = "Ali Parlakci"
|
||||||
__email__ = "parlakciali@gmail.com"
|
__email__ = "parlakciali@gmail.com"
|
||||||
|
|
||||||
@@ -143,6 +143,12 @@ def parseArguments(arguments=[]):
|
|||||||
" for downloading later",
|
" for downloading later",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
default=False)
|
default=False)
|
||||||
|
|
||||||
|
parser.add_argument("--exclude",
|
||||||
|
nargs="+",
|
||||||
|
help="Do not download specified links",
|
||||||
|
choices=["imgur","gfycat","direct","self"],
|
||||||
|
type=str)
|
||||||
|
|
||||||
if arguments == []:
|
if arguments == []:
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
@@ -318,6 +324,32 @@ class PromptUser:
|
|||||||
if Path(GLOBAL.arguments.log ).is_file():
|
if Path(GLOBAL.arguments.log ).is_file():
|
||||||
break
|
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:
|
while True:
|
||||||
try:
|
try:
|
||||||
GLOBAL.arguments.limit = int(input("\nlimit (0 for none): "))
|
GLOBAL.arguments.limit = int(input("\nlimit (0 for none): "))
|
||||||
@@ -444,6 +476,10 @@ def download(submissions):
|
|||||||
downloadedCount = subsLenght
|
downloadedCount = subsLenght
|
||||||
duplicates = 0
|
duplicates = 0
|
||||||
BACKUP = {}
|
BACKUP = {}
|
||||||
|
if GLOBAL.arguments.exclude is not None:
|
||||||
|
ToBeDownloaded = GLOBAL.arguments.exclude
|
||||||
|
else:
|
||||||
|
ToBeDownloaded = []
|
||||||
|
|
||||||
FAILED_FILE = createLogFile("FAILED")
|
FAILED_FILE = createLogFile("FAILED")
|
||||||
|
|
||||||
@@ -466,7 +502,7 @@ def download(submissions):
|
|||||||
|
|
||||||
directory = GLOBAL.directory / submissions[i]['postSubreddit']
|
directory = GLOBAL.directory / submissions[i]['postSubreddit']
|
||||||
|
|
||||||
if submissions[i]['postType'] == 'imgur':
|
if submissions[i]['postType'] == 'imgur' and not 'imgur' in ToBeDownloaded:
|
||||||
print("IMGUR",end="")
|
print("IMGUR",end="")
|
||||||
|
|
||||||
while int(time.time() - lastRequestTime) <= 2:
|
while int(time.time() - lastRequestTime) <= 2:
|
||||||
@@ -529,7 +565,7 @@ def download(submissions):
|
|||||||
)
|
)
|
||||||
downloadedCount -= 1
|
downloadedCount -= 1
|
||||||
|
|
||||||
elif submissions[i]['postType'] == 'gfycat':
|
elif submissions[i]['postType'] == 'gfycat' and not 'gfycat' in ToBeDownloaded:
|
||||||
print("GFYCAT")
|
print("GFYCAT")
|
||||||
try:
|
try:
|
||||||
Gfycat(directory,submissions[i])
|
Gfycat(directory,submissions[i])
|
||||||
@@ -549,7 +585,7 @@ def download(submissions):
|
|||||||
FAILED_FILE.add({int(i+1):[str(exception),submissions[i]]})
|
FAILED_FILE.add({int(i+1):[str(exception),submissions[i]]})
|
||||||
downloadedCount -= 1
|
downloadedCount -= 1
|
||||||
|
|
||||||
elif submissions[i]['postType'] == 'direct':
|
elif submissions[i]['postType'] == 'direct' and not 'direct' in ToBeDownloaded:
|
||||||
print("DIRECT")
|
print("DIRECT")
|
||||||
try:
|
try:
|
||||||
Direct(directory,submissions[i])
|
Direct(directory,submissions[i])
|
||||||
@@ -564,7 +600,7 @@ def download(submissions):
|
|||||||
FAILED_FILE.add({int(i+1):[str(exception),submissions[i]]})
|
FAILED_FILE.add({int(i+1):[str(exception),submissions[i]]})
|
||||||
downloadedCount -= 1
|
downloadedCount -= 1
|
||||||
|
|
||||||
elif submissions[i]['postType'] == 'self':
|
elif submissions[i]['postType'] == 'self' and not 'self' in ToBeDownloaded:
|
||||||
print("SELF")
|
print("SELF")
|
||||||
try:
|
try:
|
||||||
Self(directory,submissions[i])
|
Self(directory,submissions[i])
|
||||||
@@ -668,7 +704,10 @@ if __name__ == "__main__":
|
|||||||
GLOBAL.directory = Path(".\\")
|
GLOBAL.directory = Path(".\\")
|
||||||
print("\nQUITTING...")
|
print("\nQUITTING...")
|
||||||
except Exception as exception:
|
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())
|
print(log_stream.getvalue())
|
||||||
|
|
||||||
input("Press enter to quit\n")
|
input("Press enter to quit\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user