1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[mangareader] supply correct width and height

This commit is contained in:
Mike Fährmann 2015-06-28 01:22:39 +02:00
parent 2afe15b217
commit 13ebca2a48

View File

@ -39,7 +39,6 @@ class MangaReaderExtractor(AsynchronousExtractor):
url = self.url_base + self.part
while True:
url, image_url, data = self.get_page_metadata(url)
print(url)
if url is None:
return
yield Message.Directory, data
@ -48,25 +47,30 @@ class MangaReaderExtractor(AsynchronousExtractor):
def get_page_metadata(self, page_url):
"""Collect next url, image-url and metadata for one manga-page"""
page = self.request(page_url).text
descr , pos = self.extract(page, '<meta name="description" content="', '"')
_ , pos = self.extract(page, '<div id="imgholder">', '', pos)
print(page[pos:pos+3])
if page[pos+1] != "a":
extr = self.extract
width = None
descr, pos = extr(page, '<meta name="description" content="', '"')
test , pos = extr(page, "document['pu']", '', pos)
if test is None:
return None, None, None
url , pos = self.extract(page, ' href="', '"', pos)
width , pos = self.extract(page, '<img id="img" width="', '"', pos)
height , pos = self.extract(page, ' height="', '"', pos)
image , pos = self.extract(page, ' src="', '"', pos)
if page.find("document['imgwidth']", pos, pos+200) != -1:
width , pos = extr(page, "document['imgwidth'] = ", ";", pos)
height, pos = extr(page, "document['imgheight'] = ", ";", pos)
_ , pos = extr(page, '<div id="imgholder">', '')
url, pos = extr(page, ' href="', '"', pos)
if width is None:
width , pos = extr(page, '<img id="img" width="', '"', pos)
height, pos = extr(page, ' height="', '"', pos)
image, pos = extr(page, ' src="', '"', pos)
filename = unquote(filename_from_url(image))
name, ext = os.path.splitext(filename)
match = re.match(r"(.*) (\d+) - Read \1 \2 Manga Scans Page (\d+)", descr)
manga, chapter, page = match.groups()
return self.url_base + url, image, {
"category": info["category"],
"manga": unescape(manga),
"chapter": chapter,
"page": page,
"manga": unescape(match.group(1)),
"chapter": match.group(2),
"page": match.group(3),
"width": width,
"height": height,
"language": "English",