@@ -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 ("<h2>" , "<" )),
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