From bb1524b46af3872dd8a5d812053a2f6c9d8f101f Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Sat, 10 Jul 2010 03:28:13 +0200 Subject: [PATCH] use ExpectedElementNotFound --- weboob/backends/youjizz/pages/index.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/weboob/backends/youjizz/pages/index.py b/weboob/backends/youjizz/pages/index.py index 16761239..3e042955 100644 --- a/weboob/backends/youjizz/pages/index.py +++ b/weboob/backends/youjizz/pages/index.py @@ -18,7 +18,7 @@ import re -from weboob.tools.browser import BasePage +from weboob.tools.browser import BasePage, ExpectedElementNotFound from ..video import YoujizzVideo @@ -28,24 +28,25 @@ __all__ = ['IndexPage'] class IndexPage(BasePage): def iter_videos(self): - span_list = self.document.getroot().cssselect("span#miniatura") + div_id = 'span#miniatura' + span_list = self.document.getroot().cssselect(div_id) if not span_list: - return + raise ExpectedElementNotFound(div_id) for span in span_list: a = span.find('.//a') if a is None: - continue + raise ExpectedElementNotFound('%s.//a' % span) url = a.attrib['href'] _id = re.sub(r'/videos/(.+)\.html', r'\1', url) thumbnail_url = span.find('.//img').attrib['src'] - title1 = span.cssselect('span#title1') + title1_selector = 'span#title1' + title1 = span.cssselect(title1_selector) if title1 is None: - title = None - else: - title = title1[0].text.strip() + raise ExpectedElementNotFound(title1_selector) + title = title1[0].text.strip() duration = 0 thumbtime = span.cssselect('span.thumbtime') @@ -58,4 +59,4 @@ class IndexPage(BasePage): title=title, duration=duration, thumbnail_url=thumbnail_url, - nsfw=True) + )