Merge branch 'master' of https://github.com/aliparlakci/bulk-downloader-for-reddit
This commit is contained in:
commit
3d5a2fc1a7
2 changed files with 14 additions and 19 deletions
|
@ -12,25 +12,19 @@ from src.errors import FileNotFoundError, FileAlreadyExistsError, AlbumNotDownlo
|
|||
class Gallery:
|
||||
def __init__(self, directory, post):
|
||||
|
||||
link = post['CONTENTURL']
|
||||
self.rawData = self.getData(link)
|
||||
|
||||
self.directory = directory
|
||||
self.post = post
|
||||
|
||||
links = post['CONTENTURL']
|
||||
|
||||
images = {}
|
||||
count = 0
|
||||
for model in self.rawData['posts']['models']:
|
||||
try:
|
||||
for item in self.rawData['posts']['models'][model]['media']['gallery']['items']:
|
||||
try:
|
||||
images[count] = {'id': item['mediaId'], 'url': self.rawData['posts'][
|
||||
'models'][model]['media']['mediaMetadata'][item['mediaId']]['s']['u']}
|
||||
count = count + 1
|
||||
except BaseException:
|
||||
continue
|
||||
except BaseException:
|
||||
continue
|
||||
for link in links:
|
||||
path = urllib.parse.urlparse(link).path
|
||||
base = os.path.basename(path)
|
||||
name = os.path.splitext(base)[0]
|
||||
images[count] = {'id': name, 'url': link}
|
||||
count = count + 1
|
||||
|
||||
self.directory = directory
|
||||
self.post = post
|
||||
|
||||
self.downloadAlbum(images, count)
|
||||
|
||||
|
|
|
@ -368,6 +368,7 @@ def extractDirectLink(URL):
|
|||
|
||||
def genLinksifGallery(metadata):
|
||||
galleryImgUrls = list()
|
||||
for key in metadata:
|
||||
galleryImgUrls.append(metadata[key]['s']['u'].split('?')[0].replace('preview','i'))
|
||||
if metadata is not None:
|
||||
for key in metadata:
|
||||
galleryImgUrls.append(metadata[key]['s']['u'].split('?')[0].replace('preview','i'))
|
||||
return galleryImgUrls
|
||||
|
|
Loading…
Reference in a new issue