11 Commits

Author SHA1 Message Date
Ali
22047338e2 Update version number 2019-04-09 20:45:22 +03:00
Ali
b16cdd3cbb Hopefully, fixed the config.json bug 2019-04-09 20:31:42 +03:00
Ali
2a8394a48c Fixed the bug concerning config.json 2019-04-08 22:09:52 +03:00
Ali Parlakçı
eac4404bbf Update README.md 2019-03-31 11:59:49 +03:00
Ali Parlakci
fae49d50da Update version 2019-03-31 11:46:03 +03:00
Ali Parlakci
7130525ece Update version 2019-03-31 11:35:27 +03:00
Ali Parlakci
2bf1e03ee1 Update version 2019-03-31 11:33:29 +03:00
Ali
15a91e5784 Fixed saving auth info problem 2019-02-24 12:28:40 +03:00
Ali
344201a70d Fixed v.redd.it links 2019-02-23 00:01:39 +03:00
Ali
92e47adb43 Update version 2019-02-22 23:59:57 +03:00
Ali
4d385fda60 Fixed v.redd.it links 2019-02-22 23:59:03 +03:00
5 changed files with 45 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
# Bulk Downloader for Reddit # Bulk Downloader for Reddit
Downloads media from reddit posts. Downloads media from reddit posts. Made by [u/aliparlakci](https://reddit.com/u/aliparlakci)
## [Download the latest release here](https://github.com/aliparlakci/bulk-downloader-for-reddit/releases/latest) ## [Download the latest release here](https://github.com/aliparlakci/bulk-downloader-for-reddit/releases/latest)

View File

@@ -1,4 +1,7 @@
# Changes on *master* # Changes on *master*
##[23/02/2019](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/4d385fda60028343be816eb7c4f7bc613a9d555d)
- Fixed v.redd.it links
## [27/01/2019](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/b7baf07fb5998368d87e3c4c36aed40daf820609) ## [27/01/2019](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/b7baf07fb5998368d87e3c4c36aed40daf820609)
- Clarified the instructions - Clarified the instructions

View File

@@ -23,7 +23,7 @@ from src.tools import (GLOBAL, createLogFile, jsonFile, nameCorrector,
__author__ = "Ali Parlakci" __author__ = "Ali Parlakci"
__license__ = "GPL" __license__ = "GPL"
__version__ = "1.6.4.1" __version__ = "1.6.5"
__maintainer__ = "Ali Parlakci" __maintainer__ = "Ali Parlakci"
__email__ = "parlakciali@gmail.com" __email__ = "parlakciali@gmail.com"
@@ -672,10 +672,15 @@ def main():
except ProgramModeError as err: except ProgramModeError as err:
PromptUser() PromptUser()
if not Path(GLOBAL.configDirectory).is_dir(): if not Path(GLOBAL.defaultConfigDirectory).is_dir():
os.makedirs(GLOBAL.configDirectory) os.makedirs(GLOBAL.defaultConfigDirectory)
GLOBAL.config = getConfig("config.json") if Path("config.json").exists() \
else getConfig(GLOBAL.configDirectory / "config.json") if Path("config.json").exists():
GLOBAL.configDirectory = Path("config.json")
else:
GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json"
GLOBAL.config = getConfig(GLOBAL.configDirectory)
if GLOBAL.arguments.log is not None: if GLOBAL.arguments.log is not None:
logDir = Path(GLOBAL.arguments.log) logDir = Path(GLOBAL.arguments.log)

View File

@@ -3,6 +3,8 @@ import sys
import random import random
import socket import socket
import webbrowser import webbrowser
import urllib.request
from urllib.error import HTTPError
import praw import praw
from prawcore.exceptions import NotFound, ResponseException, Forbidden from prawcore.exceptions import NotFound, ResponseException, Forbidden
@@ -93,7 +95,7 @@ def beginPraw(config,user_agent = str(socket.gethostname())):
authorizedInstance = GetAuth(reddit,port).getRefreshToken(*scopes) authorizedInstance = GetAuth(reddit,port).getRefreshToken(*scopes)
reddit = authorizedInstance[0] reddit = authorizedInstance[0]
refresh_token = authorizedInstance[1] refresh_token = authorizedInstance[1]
jsonFile(GLOBAL.configDirectory / "config.json").add({ jsonFile(GLOBAL.configDirectory).add({
"reddit_username":str(reddit.user.me()), "reddit_username":str(reddit.user.me()),
"reddit_refresh_token":refresh_token "reddit_refresh_token":refresh_token
}) })
@@ -103,7 +105,7 @@ def beginPraw(config,user_agent = str(socket.gethostname())):
authorizedInstance = GetAuth(reddit,port).getRefreshToken(*scopes) authorizedInstance = GetAuth(reddit,port).getRefreshToken(*scopes)
reddit = authorizedInstance[0] reddit = authorizedInstance[0]
refresh_token = authorizedInstance[1] refresh_token = authorizedInstance[1]
jsonFile(GLOBAL.configDirectory / "config.json").add({ jsonFile(GLOBAL.configDirectory).add({
"reddit_username":str(reddit.user.me()), "reddit_username":str(reddit.user.me()),
"reddit_refresh_token":refresh_token "reddit_refresh_token":refresh_token
}) })
@@ -422,18 +424,20 @@ def checkIfMatching(submission):
eromeCount += 1 eromeCount += 1
return details return details
elif isDirectLink(submission.url) is not False:
details['postType'] = 'direct'
details['postURL'] = isDirectLink(submission.url)
directCount += 1
return details
elif submission.is_self: elif submission.is_self:
details['postType'] = 'self' details['postType'] = 'self'
details['postContent'] = submission.selftext details['postContent'] = submission.selftext
selfCount += 1 selfCount += 1
return details return details
directLink = isDirectLink(submission.url)
if directLink is not False:
details['postType'] = 'direct'
details['postURL'] = directLink
directCount += 1
return details
def printSubmission(SUB,validNumber,totalNumber): def printSubmission(SUB,validNumber,totalNumber):
"""Print post's link, title and media link to screen""" """Print post's link, title and media link to screen"""
@@ -473,7 +477,22 @@ def isDirectLink(URL):
return URL return URL
elif "v.redd.it" in URL: elif "v.redd.it" in URL:
return URL+"/DASH_600_K" bitrates = ["DASH_1080","DASH_720","DASH_600", \
"DASH_480","DASH_360","DASH_240"]
for bitrate in bitrates:
videoURL = URL+"/"+bitrate
try:
responseCode = urllib.request.urlopen(videoURL).getcode()
except urllib.error.HTTPError:
responseCode = 0
if responseCode == 200:
return videoURL
else:
return False
for extension in imageTypes: for extension in imageTypes:
if extension in URL: if extension in URL:

View File

@@ -14,7 +14,8 @@ class GLOBAL:
config = None config = None
arguments = None arguments = None
directory = None directory = None
configDirectory = Path.home() / "Bulk Downloader for Reddit" defaultConfigDirectory = Path.home() / "Bulk Downloader for Reddit"
configDirectory = ""
reddit_client_id = "BSyphDdxYZAgVQ" reddit_client_id = "BSyphDdxYZAgVQ"
reddit_client_secret = "bfqNJaRh8NMh-9eAr-t4TRz-Blk" reddit_client_secret = "bfqNJaRh8NMh-9eAr-t4TRz-Blk"
printVanilla = print printVanilla = print