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"
|
example = "https://motherless.com/GABC123/DEF456"
|
||||||
|
|
||||||
def get_image(self):
|
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_id'] = re.match(self.pattern, self.url).group(1)
|
||||||
data['gallery_title'] = self.get_gallery_name(data['gallery_id'])
|
data['gallery_title'] = self.get_gallery_name(data['gallery_id'])
|
||||||
data['title'] = get_media_title(self.page_data)
|
data['title'] = get_media_title(self.page_data)
|
||||||
@ -107,22 +107,22 @@ class MotherlessGalleryImagesExtractor(MotherlessExtractor):
|
|||||||
|
|
||||||
page = self.request(f"{self.root}/G{self.gallery_id}").text
|
page = self.request(f"{self.root}/G{self.gallery_id}").text
|
||||||
data = {
|
data = {
|
||||||
"gallery_id" : self.gallery_id,
|
"gallery_id" : self.gallery_id,
|
||||||
"gallery_title": get_gallery_name_from_homepage(page),
|
"gallery_title": get_gallery_name_from_homepage(page),
|
||||||
"uploader": get_gallery_uploader(page),
|
"uploader": get_gallery_uploader(page),
|
||||||
"count": get_gallery_image_count(page)}
|
"count": get_gallery_image_count(page)}
|
||||||
|
|
||||||
yield Message.Directory, data
|
yield Message.Directory, data
|
||||||
|
|
||||||
for id, url, extension, title, num in get_images(self):
|
for id, url, extension, title, num in get_images(self):
|
||||||
data |= {
|
image_data = data | {
|
||||||
"id": id,
|
"id": id,
|
||||||
"filename": id,
|
"filename": id,
|
||||||
"extension": extension,
|
"extension": extension,
|
||||||
"title": title,
|
"title": title,
|
||||||
"num": num}
|
"num": num}
|
||||||
|
|
||||||
yield Message.Url, url, data
|
yield Message.Url, url, image_data
|
||||||
|
|
||||||
|
|
||||||
class MotherlessGalleryVideosExtractor(MotherlessExtractor):
|
class MotherlessGalleryVideosExtractor(MotherlessExtractor):
|
||||||
@ -137,7 +137,7 @@ class MotherlessGalleryVideosExtractor(MotherlessExtractor):
|
|||||||
self.gallery_id = re.match(self.pattern, self.url).group(1)
|
self.gallery_id = re.match(self.pattern, self.url).group(1)
|
||||||
page = self.request(f"{self.root}/G{self.gallery_id}").text
|
page = self.request(f"{self.root}/G{self.gallery_id}").text
|
||||||
data = {
|
data = {
|
||||||
"gallery_id" : self.gallery_id,
|
"gallery_id" : self.gallery_id,
|
||||||
"gallery_title": get_gallery_name_from_homepage(page),
|
"gallery_title": get_gallery_name_from_homepage(page),
|
||||||
"uploader": get_gallery_uploader(page),
|
"uploader": get_gallery_uploader(page),
|
||||||
"count": get_gallery_video_count(page)}
|
"count": get_gallery_video_count(page)}
|
||||||
@ -145,14 +145,14 @@ class MotherlessGalleryVideosExtractor(MotherlessExtractor):
|
|||||||
yield Message.Directory, data
|
yield Message.Directory, data
|
||||||
|
|
||||||
for id, url, title, num in get_videos(self):
|
for id, url, title, num in get_videos(self):
|
||||||
data |= {
|
video_data = data | {
|
||||||
"id": id,
|
"id": id,
|
||||||
"filename": id,
|
"filename": id,
|
||||||
"extension": "mp4",
|
"extension": "mp4",
|
||||||
"title": title,
|
"title": title,
|
||||||
"num": num}
|
"num": num}
|
||||||
|
|
||||||
yield Message.Url, url, data
|
yield Message.Url, url, video_data
|
||||||
|
|
||||||
|
|
||||||
class MotherlessGalleryExtractor(MotherlessExtractor):
|
class MotherlessGalleryExtractor(MotherlessExtractor):
|
||||||
@ -167,80 +167,80 @@ class MotherlessGalleryExtractor(MotherlessExtractor):
|
|||||||
self.gallery_id = re.match(self.pattern, self.url).group(1)
|
self.gallery_id = re.match(self.pattern, self.url).group(1)
|
||||||
page = self.request(f"{self.root}/G{self.gallery_id}").text
|
page = self.request(f"{self.root}/G{self.gallery_id}").text
|
||||||
data = {
|
data = {
|
||||||
"gallery_id" : self.gallery_id,
|
"gallery_id" : self.gallery_id,
|
||||||
"gallery_title": get_gallery_name_from_homepage(page),
|
"gallery_title": get_gallery_name_from_homepage(page),
|
||||||
"uploader": get_gallery_uploader(page),
|
"uploader": get_gallery_uploader(page),
|
||||||
"count": get_gallery_image_count(page) + get_gallery_video_count(page)}
|
"count": get_gallery_image_count(page) + get_gallery_video_count(page)}
|
||||||
|
|
||||||
yield Message.Directory, data
|
yield Message.Directory, data
|
||||||
|
|
||||||
for id, url, extension, title, num in get_images(self):
|
for id, url, extension, title, num in get_images(self):
|
||||||
data |= {
|
image_data = data | {
|
||||||
"id": id,
|
"id": id,
|
||||||
"filename": id,
|
"filename": id,
|
||||||
"extension": extension,
|
"extension": extension,
|
||||||
"title": title,
|
"title": title,
|
||||||
"num": num}
|
"num": num}
|
||||||
|
|
||||||
yield Message.Url, url, data
|
yield Message.Url, url, image_data
|
||||||
|
|
||||||
for id, url, title, num in get_videos(self):
|
for id, url, title, num in get_videos(self):
|
||||||
data |= {
|
video_data = data | {
|
||||||
"id": id,
|
"id": id,
|
||||||
"filename": id,
|
"filename": id,
|
||||||
"extension": "mp4",
|
"extension": "mp4",
|
||||||
"title": title,
|
"title": title,
|
||||||
"num": num}
|
"num": num}
|
||||||
|
|
||||||
yield Message.Url, url, data
|
yield Message.Url, url, video_data
|
||||||
|
|
||||||
|
|
||||||
# Url extractors.
|
# Url extractors.
|
||||||
|
|
||||||
def get_images(extractor):
|
def get_images(extractor):
|
||||||
n = 1
|
page_number = 1
|
||||||
total_count = 0
|
total_image_count = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
page = extractor.request(f"{extractor.root}/GI{extractor.gallery_id}?page={n}").text
|
page = extractor.request(f"{extractor.root}/GI{extractor.gallery_id}?page={page_number}").text
|
||||||
page_count = 0
|
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):
|
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)
|
id = result.group(1)
|
||||||
extension = result.group(2)
|
extension = result.group(2)
|
||||||
url = f"https://cdn5-images.motherlessmedia.com/images/{id}.{extension}"
|
url = f"https://cdn5-images.motherlessmedia.com/images/{id}.{extension}"
|
||||||
title = result.group(3)
|
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
|
return
|
||||||
|
|
||||||
total_count += page_count
|
total_image_count += page_image_count
|
||||||
n += 1
|
page_number += 1
|
||||||
|
|
||||||
def get_videos(extractor):
|
def get_videos(extractor):
|
||||||
n = 1
|
page_number = 1
|
||||||
total_count = 0
|
total_video_count = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
page = extractor.request(f"{extractor.root}/GV{extractor.gallery_id}?page={n}").text
|
page = extractor.request(f"{extractor.root}/GV{extractor.gallery_id}?page={page_number}").text
|
||||||
page_count = 0
|
page_video_count = 0
|
||||||
|
|
||||||
for result in re.finditer('thumbs/([A-Z0-9]+?)-strip\.jpg" alt="([^"]+)"', page):
|
for result in re.finditer('thumbs/([A-Z0-9]+?)-strip\.jpg" alt="([^"]+)"', page):
|
||||||
id = result.group(1)
|
id = result.group(1)
|
||||||
url = f"https://cdn5-videos.motherlessmedia.com/videos/{id}.mp4"
|
url = f"https://cdn5-videos.motherlessmedia.com/videos/{id}.mp4"
|
||||||
title = result.group(2)
|
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
|
return
|
||||||
|
|
||||||
total_count += page_count
|
total_video_count += page_video_count
|
||||||
n += 1
|
page_number += 1
|
||||||
|
|
||||||
# Metadata extractors.
|
# Metadata extractors.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user