Fix e-hentai because of site changes
Also remove obsolete "nsfw" attribute
This commit is contained in:
parent
d91dad2b2b
commit
c938f7b063
3 changed files with 8 additions and 25 deletions
|
|
@ -49,7 +49,7 @@ class EHentaiBrowser(BaseBrowser):
|
||||||
return 'http://%s/g/%s/' % (self.DOMAIN, gallery.id)
|
return 'http://%s/g/%s/' % (self.DOMAIN, gallery.id)
|
||||||
|
|
||||||
def _gallery_page(self, gallery, n):
|
def _gallery_page(self, gallery, n):
|
||||||
return gallery.url + ('?p=%d' % n)
|
return gallery.url + ('?p='+str(n))
|
||||||
|
|
||||||
def search_gallery(self, pattern):
|
def search_gallery(self, pattern):
|
||||||
self.location(self.buildurl('/', f_search=pattern.encode('utf-8')))
|
self.location(self.buildurl('/', f_search=pattern.encode('utf-8')))
|
||||||
|
|
@ -64,20 +64,13 @@ class EHentaiBrowser(BaseBrowser):
|
||||||
def iter_gallery_images(self, gallery):
|
def iter_gallery_images(self, gallery):
|
||||||
self.location(gallery.url)
|
self.location(gallery.url)
|
||||||
assert self.is_on_page(GalleryPage)
|
assert self.is_on_page(GalleryPage)
|
||||||
i = 0
|
for n in self.page._page_numbers():
|
||||||
while True:
|
self.location(self._gallery_page(gallery, n))
|
||||||
n = self.page._next_page_link()
|
assert self.is_on_page(GalleryPage)
|
||||||
|
|
||||||
for img in self.page.image_pages():
|
for img in self.page.image_pages():
|
||||||
yield EHentaiImage(img)
|
yield EHentaiImage(img)
|
||||||
|
|
||||||
if n is None:
|
|
||||||
break
|
|
||||||
|
|
||||||
i += 1
|
|
||||||
self.location(self._gallery_page(gallery, i))
|
|
||||||
assert self.is_on_page(GalleryPage)
|
|
||||||
|
|
||||||
def get_image_url(self, image):
|
def get_image_url(self, image):
|
||||||
self.location(image.id)
|
self.location(image.id)
|
||||||
assert self.is_on_page(ImagePage)
|
assert self.is_on_page(ImagePage)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ __all_ = ['EHentaiGallery', 'EHentaiImage']
|
||||||
class EHentaiGallery(BaseGallery):
|
class EHentaiGallery(BaseGallery):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
BaseGallery.__init__(self, *args, **kwargs)
|
BaseGallery.__init__(self, *args, **kwargs)
|
||||||
self.nsfw = True
|
|
||||||
|
|
||||||
class EHentaiImage(BaseImage):
|
class EHentaiImage(BaseImage):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
|
||||||
|
|
@ -56,11 +56,8 @@ class GalleryPage(BasePage):
|
||||||
def image_pages(self):
|
def image_pages(self):
|
||||||
return self.document.xpath('//div[@class="gdtm"]//a/attribute::href')
|
return self.document.xpath('//div[@class="gdtm"]//a/attribute::href')
|
||||||
|
|
||||||
def _next_page_link(self):
|
def _page_numbers(self):
|
||||||
try:
|
return [n for n in self.document.xpath("(//table[@class='ptt'])[1]//td/text()") if re.match(r"\d+", n)]
|
||||||
return self.document.xpath("//table[@class='ptt']//a[text()='>']")[0]
|
|
||||||
except IndexError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def gallery_exists(self, gallery):
|
def gallery_exists(self, gallery):
|
||||||
if self.document.xpath("//h1"):
|
if self.document.xpath("//h1"):
|
||||||
|
|
@ -73,8 +70,8 @@ class GalleryPage(BasePage):
|
||||||
try:
|
try:
|
||||||
gallery.original_title = self.document.xpath("//h1[@id='gj']/text()")[0]
|
gallery.original_title = self.document.xpath("//h1[@id='gj']/text()")[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
gallery.orginal_title = None
|
gallery.original_title = None
|
||||||
description_div = self.document.xpath("//div[@id='gds']/div")[0]
|
description_div = self.document.xpath("//div[@id='gd71']")[0]
|
||||||
description_html = self.parser.tostring(description_div)
|
description_html = self.parser.tostring(description_div)
|
||||||
gallery.description = html2text(description_html)
|
gallery.description = html2text(description_html)
|
||||||
cardinality_string = self.document.xpath("//div[@id='gdd']//tr[td[@class='gdt1']/text()='Images:']/td[@class='gdt2']/text()")[0]
|
cardinality_string = self.document.xpath("//div[@id='gdd']//tr[td[@class='gdt1']/text()='Images:']/td[@class='gdt2']/text()")[0]
|
||||||
|
|
@ -98,12 +95,6 @@ class GalleryPage(BasePage):
|
||||||
|
|
||||||
gallery.thumbnail = Thumbnail(unicode(thumbnail_url))
|
gallery.thumbnail = Thumbnail(unicode(thumbnail_url))
|
||||||
|
|
||||||
def _prev_page_link(self):
|
|
||||||
try:
|
|
||||||
return self.document.xpath("//table[@class='ptt']//a[text()='<']")[0]
|
|
||||||
except IndexError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class ImagePage(BasePage):
|
class ImagePage(BasePage):
|
||||||
def get_url(self):
|
def get_url(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue