ehentai: fix encoding and crash (closes #655,#656)

This commit is contained in:
Roger Philibert 2011-05-08 11:02:50 +02:00 committed by Romain Bignon
commit 8b274bfa60
4 changed files with 33 additions and 12 deletions

View file

@ -48,7 +48,7 @@ class IndexPage(BasePage):
a = line.xpath('.//div[@class="it3"]/a')[-1]
url = a.attrib["href"]
title = a.text.strip()
yield EHentaiGallery(url, title=title)
yield EHentaiGallery(re.search('(?<=/g/)\d+/[\dabcdef]+', url).group(0), title=title)
class GalleryPage(BasePage):
def image_pages(self):
@ -60,6 +60,12 @@ class GalleryPage(BasePage):
except IndexError:
return None
def gallery_exists(self, gallery):
if self.document.xpath("//h1"):
return True
else:
return False
def fill_gallery(self, gallery):
gallery.title = self.document.xpath("//h1[@id='gn']/text()")[0]
try: