mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[motherless] general tidying
This commit is contained in:
parent
5547955126
commit
ab2a725e9c
@ -77,7 +77,7 @@ class MotherlessMediaInGalleryExtractor(MotherlessMediaExtractor):
|
||||
example = "https://motherless.com/GABC123/DEF456"
|
||||
|
||||
def get_image(self):
|
||||
media_url, data = super().get_image()
|
||||
media_url, data = super().get_image()
|
||||
data['gallery_id'] = re.match(self.pattern, self.url).group(1)
|
||||
data['gallery_title'] = self.get_gallery_name(data['gallery_id'])
|
||||
data['title'] = get_media_title(self.page_data)
|
||||
@ -115,14 +115,14 @@ class MotherlessGalleryImagesExtractor(MotherlessExtractor):
|
||||
yield Message.Directory, data
|
||||
|
||||
for id, url, extension, title, num in get_images(self):
|
||||
data |= {
|
||||
image_data = data | {
|
||||
"id": id,
|
||||
"filename": id,
|
||||
"extension": extension,
|
||||
"title": title,
|
||||
"num": num}
|
||||
|
||||
yield Message.Url, url, data
|
||||
yield Message.Url, url, image_data
|
||||
|
||||
|
||||
class MotherlessGalleryVideosExtractor(MotherlessExtractor):
|
||||
@ -145,14 +145,14 @@ class MotherlessGalleryVideosExtractor(MotherlessExtractor):
|
||||
yield Message.Directory, data
|
||||
|
||||
for id, url, title, num in get_videos(self):
|
||||
data |= {
|
||||
video_data = data | {
|
||||
"id": id,
|
||||
"filename": id,
|
||||
"extension": "mp4",
|
||||
"title": title,
|
||||
"num": num}
|
||||
|
||||
yield Message.Url, url, data
|
||||
yield Message.Url, url, video_data
|
||||
|
||||
|
||||
class MotherlessGalleryExtractor(MotherlessExtractor):
|
||||
@ -175,72 +175,72 @@ class MotherlessGalleryExtractor(MotherlessExtractor):
|
||||
yield Message.Directory, data
|
||||
|
||||
for id, url, extension, title, num in get_images(self):
|
||||
data |= {
|
||||
image_data = data | {
|
||||
"id": id,
|
||||
"filename": id,
|
||||
"extension": extension,
|
||||
"title": title,
|
||||
"num": num}
|
||||
|
||||
yield Message.Url, url, data
|
||||
yield Message.Url, url, image_data
|
||||
|
||||
for id, url, title, num in get_videos(self):
|
||||
data |= {
|
||||
video_data = data | {
|
||||
"id": id,
|
||||
"filename": id,
|
||||
"extension": "mp4",
|
||||
"title": title,
|
||||
"num": num}
|
||||
|
||||
yield Message.Url, url, data
|
||||
yield Message.Url, url, video_data
|
||||
|
||||
|
||||
# Url extractors.
|
||||
|
||||
def get_images(extractor):
|
||||
n = 1
|
||||
total_count = 0
|
||||
page_number = 1
|
||||
total_image_count = 0
|
||||
|
||||
while True:
|
||||
page = extractor.request(f"{extractor.root}/GI{extractor.gallery_id}?page={n}").text
|
||||
page_count = 0
|
||||
page = extractor.request(f"{extractor.root}/GI{extractor.gallery_id}?page={page_number}").text
|
||||
page_image_count = 0
|
||||
|
||||
for result in re.finditer(' src="https://cdn5-thumbs\.motherlessmedia\.com/thumbs/([A-Z0-9]+?)\.([a-zA-Z]+)"[\s\S]+?alt="([^"]+)"', page):
|
||||
id = result.group(1)
|
||||
extension = result.group(2)
|
||||
url = f"https://cdn5-images.motherlessmedia.com/images/{id}.{extension}"
|
||||
title = result.group(3)
|
||||
page_count += 1
|
||||
page_image_count += 1
|
||||
|
||||
yield id, url, extension, title, total_count + page_count
|
||||
yield id, url, extension, title, total_image_count + page_image_count
|
||||
|
||||
if page_count == 0:
|
||||
if page_image_count == 0:
|
||||
return
|
||||
|
||||
total_count += page_count
|
||||
n += 1
|
||||
total_image_count += page_image_count
|
||||
page_number += 1
|
||||
|
||||
def get_videos(extractor):
|
||||
n = 1
|
||||
total_count = 0
|
||||
page_number = 1
|
||||
total_video_count = 0
|
||||
|
||||
while True:
|
||||
page = extractor.request(f"{extractor.root}/GV{extractor.gallery_id}?page={n}").text
|
||||
page_count = 0
|
||||
page = extractor.request(f"{extractor.root}/GV{extractor.gallery_id}?page={page_number}").text
|
||||
page_video_count = 0
|
||||
|
||||
for result in re.finditer('thumbs/([A-Z0-9]+?)-strip\.jpg" alt="([^"]+)"', page):
|
||||
id = result.group(1)
|
||||
url = f"https://cdn5-videos.motherlessmedia.com/videos/{id}.mp4"
|
||||
title = result.group(2)
|
||||
page_count += 1
|
||||
page_video_count += 1
|
||||
|
||||
yield id, url, title, total_count + page_count
|
||||
yield id, url, title, total_video_count + page_video_count
|
||||
|
||||
if page_count == 0:
|
||||
if page_video_count == 0:
|
||||
return
|
||||
|
||||
total_count += page_count
|
||||
n += 1
|
||||
total_video_count += page_video_count
|
||||
page_number += 1
|
||||
|
||||
# Metadata extractors.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user