mirror of
https://github.com/KevinMidboe/bulk-downloader-for-reddit.git
synced 2025-10-29 17:40:15 +00:00
Add submitter to file name
This commit is contained in:
@@ -6,13 +6,12 @@ This program downloads imgur, gfycat and direct image and video links of saved p
|
|||||||
## What it can do
|
## What it can do
|
||||||
- Can get posts from: frontpage, subreddits, multireddits, redditor's submissions, upvoted and saved posts; search results or just plain reddit links
|
- Can get posts from: frontpage, subreddits, multireddits, redditor's submissions, upvoted and saved posts; search results or just plain reddit links
|
||||||
- Sorts posts by hot, top, new and so on
|
- Sorts posts by hot, top, new and so on
|
||||||
- Downloads imgur albums, gfycat links, [self posts](#how-do-i-open-self-post-files) and any link to a direct image
|
- Downloads **REDDIT** images and videos, **IMGUR** images and albums, **GFYCAT** links, **EROME** images and albums, **SELF POSTS** and any link to a direct image
|
||||||
- Skips the existing ones
|
- Skips the existing ones
|
||||||
- Puts post titles to file's name
|
- Puts post titles to file's name
|
||||||
- Puts every post to its subreddit's folder
|
- Puts every post to its subreddit's folder
|
||||||
- Saves a reusable copy of posts' details that are found so that they can be re-downloaded again
|
- Saves a reusable copy of posts' details that are found so that they can be re-downloaded again
|
||||||
- Logs failed ones in a file to so that you can try to download them later
|
- Logs failed ones in a file to so that you can try to download them later
|
||||||
- Can run with double-clicking on Windows
|
|
||||||
|
|
||||||
## [Download the latest release](https://github.com/aliparlakci/bulk-downloader-for-reddit/releases/latest)
|
## [Download the latest release](https://github.com/aliparlakci/bulk-downloader-for-reddit/releases/latest)
|
||||||
|
|
||||||
|
|||||||
29
script.py
29
script.py
@@ -427,17 +427,30 @@ def postExists(POST):
|
|||||||
"""Figure out a file's name and checks if the file already exists"""
|
"""Figure out a file's name and checks if the file already exists"""
|
||||||
|
|
||||||
title = nameCorrector(POST['postTitle'])
|
title = nameCorrector(POST['postTitle'])
|
||||||
FILENAME = title + "_" + POST['postId']
|
FILENAME = title + "_" + POST['postId'] + "_" + POST["postSubmitter"]
|
||||||
PATH = GLOBAL.directory / POST["postSubreddit"]
|
PATH = GLOBAL.directory / POST["postSubreddit"]
|
||||||
|
|
||||||
possibleExtensions = [".jpg",".png",".mp4",".gif",".webm",".md"]
|
possibleExtensions = [".jpg",".png",".mp4",".gif",".webm",".md"]
|
||||||
|
|
||||||
for i in range(2):
|
for extension in possibleExtensions:
|
||||||
for extension in possibleExtensions:
|
|
||||||
FILE_PATH = PATH / (FILENAME+extension)
|
OLD_FILE_PATH = PATH / (
|
||||||
if FILE_PATH.exists():
|
title
|
||||||
return True
|
+ "_" + POST['postId']
|
||||||
else:
|
+ extension
|
||||||
FILENAME = POST['postId']
|
)
|
||||||
|
FILE_PATH = PATH / (
|
||||||
|
title
|
||||||
|
+ "_" + POST['postId']
|
||||||
|
+ "_" + POST["postSubmitter"]
|
||||||
|
+ extension
|
||||||
|
)
|
||||||
|
|
||||||
|
SHORT_FILE_PATH = PATH / (POST['postId']+extension)
|
||||||
|
|
||||||
|
if OLD_FILE_PATH.exists() FILE_PATH.exists() or SHORT_FILE_PATH.exists():
|
||||||
|
return True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -89,11 +89,12 @@ class Erome:
|
|||||||
title = nameCorrector(post['postTitle'])
|
title = nameCorrector(post['postTitle'])
|
||||||
print(title+"_" +post['postId']+extension)
|
print(title+"_" +post['postId']+extension)
|
||||||
|
|
||||||
fileDir = title + "_" + post['postId'] + extension
|
fileDir = directory / (
|
||||||
fileDir = directory / fileDir
|
title+"_"+POST["postSubmitter"]+"_"+POST['postId']+extension
|
||||||
|
)
|
||||||
tempDir = title + "_" + post['postId'] + '.tmp'
|
tempDir = directory / (
|
||||||
tempDir = directory / tempDir
|
title+"_"+POST["postSubmitter"]+"_"+POST['postId']+".tmp"
|
||||||
|
)
|
||||||
|
|
||||||
imageURL = "https:" + IMAGES[0]
|
imageURL = "https:" + IMAGES[0]
|
||||||
|
|
||||||
@@ -108,7 +109,9 @@ class Erome:
|
|||||||
title = nameCorrector(post['postTitle'])
|
title = nameCorrector(post['postTitle'])
|
||||||
print(title+"_"+post['postId'],end="\n\n")
|
print(title+"_"+post['postId'],end="\n\n")
|
||||||
|
|
||||||
folderDir = directory / (title+"_"+post['postId'])
|
folderDir = directory / (
|
||||||
|
title + "_" + post["postSubmitter"] + "_" + post['postId']
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(folderDir):
|
if not os.path.exists(folderDir):
|
||||||
@@ -215,11 +218,20 @@ class Imgur:
|
|||||||
title = nameCorrector(post['postTitle'])
|
title = nameCorrector(post['postTitle'])
|
||||||
print(title+"_" +post['postId']+post['postExt'])
|
print(title+"_" +post['postId']+post['postExt'])
|
||||||
|
|
||||||
fileDir = title + "_" + post['postId'] + post['postExt']
|
fileDir = directory / (
|
||||||
fileDir = directory / fileDir
|
title
|
||||||
|
+ "_" + post["postSubmitter"]
|
||||||
|
+ "_" + post['postId']
|
||||||
|
+ post['postExt']
|
||||||
|
)
|
||||||
|
|
||||||
|
tempDir = directory / (
|
||||||
|
title
|
||||||
|
+ "_" + post["postSubmitter"]
|
||||||
|
+ "_" + post['postId']
|
||||||
|
+ ".tmp"
|
||||||
|
)
|
||||||
|
|
||||||
tempDir = title + "_" + post['postId'] + '.tmp'
|
|
||||||
tempDir = directory / tempDir
|
|
||||||
try:
|
try:
|
||||||
getFile(fileDir,tempDir,post['mediaURL'])
|
getFile(fileDir,tempDir,post['mediaURL'])
|
||||||
except FileNameTooLong:
|
except FileNameTooLong:
|
||||||
@@ -237,7 +249,9 @@ class Imgur:
|
|||||||
title = nameCorrector(post['postTitle'])
|
title = nameCorrector(post['postTitle'])
|
||||||
print(title+"_"+post['postId'],end="\n\n")
|
print(title+"_"+post['postId'],end="\n\n")
|
||||||
|
|
||||||
folderDir = directory / (title+"_"+post['postId'])
|
folderDir = directory / (
|
||||||
|
title + "_" + post["postSubmitter"] + "_" + post['postId']
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(folderDir):
|
if not os.path.exists(folderDir):
|
||||||
@@ -357,8 +371,13 @@ class Gfycat:
|
|||||||
title = nameCorrector(POST['postTitle'])
|
title = nameCorrector(POST['postTitle'])
|
||||||
print(title+"_"+POST['postId']+POST['postExt'])
|
print(title+"_"+POST['postId']+POST['postExt'])
|
||||||
|
|
||||||
fileDir = directory / (title+"_"+POST['postId']+POST['postExt'])
|
fileDir = directory / (
|
||||||
tempDir = directory / (title+"_"+POST['postId']+".tmp")
|
title+"_"+POST["postSubmitter"]+"_"+POST['postId']+POST['postExt']
|
||||||
|
)
|
||||||
|
tempDir = directory / (
|
||||||
|
title+"_"+POST["postSubmitter"]+"_"+POST['postId']+".tmp"
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
getFile(fileDir,tempDir,POST['mediaURL'])
|
getFile(fileDir,tempDir,POST['mediaURL'])
|
||||||
except FileNameTooLong:
|
except FileNameTooLong:
|
||||||
@@ -406,11 +425,12 @@ class Direct:
|
|||||||
title = nameCorrector(POST['postTitle'])
|
title = nameCorrector(POST['postTitle'])
|
||||||
print(title+"_"+POST['postId']+POST['postExt'])
|
print(title+"_"+POST['postId']+POST['postExt'])
|
||||||
|
|
||||||
fileDir = title+"_"+POST['postId']+POST['postExt']
|
fileDir = directory / (
|
||||||
fileDir = directory / fileDir
|
title+"_"+POST["postSubmitter"]+"_"+POST['postId']+POST['postExt']
|
||||||
|
)
|
||||||
tempDir = title+"_"+POST['postId']+".tmp"
|
tempDir = directory / (
|
||||||
tempDir = directory / tempDir
|
title+"_"+POST["postSubmitter"]+"_"+POST['postId']+".tmp"
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
getFile(fileDir,tempDir,POST['postURL'])
|
getFile(fileDir,tempDir,POST['postURL'])
|
||||||
@@ -427,8 +447,9 @@ class Self:
|
|||||||
title = nameCorrector(post['postTitle'])
|
title = nameCorrector(post['postTitle'])
|
||||||
print(title+"_"+post['postId']+".md")
|
print(title+"_"+post['postId']+".md")
|
||||||
|
|
||||||
fileDir = title+"_"+post['postId']+".md"
|
fileDir = directory / (
|
||||||
fileDir = directory / fileDir
|
title+"_"+POST["postSubmitter"]+"_"+POST['postId']+".md"
|
||||||
|
)
|
||||||
|
|
||||||
if Path.is_file(fileDir):
|
if Path.is_file(fileDir):
|
||||||
raise FileAlreadyExistsError
|
raise FileAlreadyExistsError
|
||||||
|
|||||||
Reference in New Issue
Block a user