[arretsurimages] fix #1691, correctly implement search and add a test

This commit is contained in:
Bezleputh 2014-12-18 18:04:28 +01:00 committed by Florent Fourcot
commit 71347cb8f7
4 changed files with 17 additions and 7 deletions

View file

@ -29,10 +29,13 @@ from .video import ArretSurImagesVideo
class IndexPage(Page):
def iter_videos(self):
def iter_videos(self, pattern=None):
videos = self.document.getroot().cssselect("div[class=bloc-contenu-8]")
for div in videos:
title = self.parser.select(div, 'h1', 1).text_content().replace(' ', ' ')
if pattern:
if pattern.upper() not in title.upper():
continue
m = re.match(r'/contenu.php\?id=(.*)', div.find('a').attrib['href'])
_id = ''
if m: