1
0
Fork 0
mirror of synced 2024-09-29 08:41:56 +13:00
This commit is contained in:
Ali Parlakci 2021-03-27 12:28:49 +03:00
commit 3d5a2fc1a7
2 changed files with 14 additions and 19 deletions

View file

@ -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)

View file

@ -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