Skip to content

Commit 1115103

Browse files
spicybiguymikf
andauthored
[motherless] fix 'gallery_title' extraction (#8605)
* Update motherless.py for title selector Updated the selector for the title property for Motherless galleries to be an h2 instead of an h1 to reflect changes on the site * fix 'gallery_title' extraction --------- Co-authored-by: Mike Fährmann <[email protected]>
1 parent acf281a commit 1115103

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

gallery_dl/extractor/motherless.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def _extract_media(self, path):
4141
path, _, media_id = path.rpartition("/")
4242
data = {
4343
"id" : media_id,
44+
"title": text.unescape(
45+
(t := extr("<title>", "<")) and t[:t.rfind(" | ")]),
4446
"type" : extr("__mediatype = '", "'"),
4547
"group": extr("__group = '", "'"),
4648
"url" : extr("__fileurl = '", "'"),
@@ -49,7 +51,6 @@ def _extract_media(self, path):
4951
for tag in text.extract_iter(
5052
extr('class="media-meta-tags">', "</div>"), ">#", "<")
5153
],
52-
"title": text.unescape(extr("<h1>", "<")),
5354
"views": text.parse_int(extr(
5455
'class="count">', " ").replace(",", "")),
5556
"favorites": text.parse_int(extr(
@@ -131,10 +132,9 @@ def _extract_gallery_title(self, page, gallery_id):
131132
if title:
132133
return text.unescape(title.strip())
133134

134-
pos = page.find(f' href="/G{gallery_id}"')
135-
if pos >= 0:
136-
return text.unescape(text.extract(
137-
page, ' title="', '"', pos)[0])
135+
if f' href="/G{gallery_id}"' in page:
136+
return text.unescape(
137+
(t := text.extr(page, "<title>", "<")) and t[:t.rfind(" | ")])
138138

139139
return ""
140140

0 commit comments

Comments
 (0)