mirror of
https://github.com/KevinMidboe/bulk-downloader-for-reddit.git
synced 2025-10-29 17:40:15 +00:00
Fixed v.redd.it links
This commit is contained in:
@@ -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
|
||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user