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:
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"""
|
||||
|
||||
title = nameCorrector(POST['postTitle'])
|
||||
FILENAME = title + "_" + POST['postId']
|
||||
FILENAME = title + "_" + POST['postId'] + "_" + POST["postSubmitter"]
|
||||
PATH = GLOBAL.directory / POST["postSubreddit"]
|
||||
|
||||
possibleExtensions = [".jpg",".png",".mp4",".gif",".webm",".md"]
|
||||
|
||||
for i in range(2):
|
||||
for extension in possibleExtensions:
|
||||
FILE_PATH = PATH / (FILENAME+extension)
|
||||
if FILE_PATH.exists():
|
||||
return True
|
||||
else:
|
||||
FILENAME = POST['postId']
|
||||
for extension in possibleExtensions:
|
||||
|
||||
OLD_FILE_PATH = PATH / (
|
||||
title
|
||||
+ "_" + POST['postId']
|
||||
+ extension
|
||||
)
|
||||
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:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user