search works again
This commit is contained in:
parent
9294f3e964
commit
fbdf44e27a
4 changed files with 23 additions and 18 deletions
|
|
@ -33,10 +33,11 @@ __all__ = ['NolifeTVBrowser']
|
|||
|
||||
class NolifeTVBrowser(BaseBrowser):
|
||||
DOMAIN = 'online.nolife-tv.com'
|
||||
ENCODING = None
|
||||
ENCODING = 'utf-8'
|
||||
PAGES = {r'http://online.nolife-tv.com/index.php\??': IndexPage,
|
||||
r'http://online.nolife-tv.com/': IndexPage,
|
||||
r'http://online.nolife-tv.com/index.php\?id=(?P<id>.+)': VideoPage}
|
||||
r'http://online.nolife-tv.com/do.php': IndexPage,
|
||||
r'http://online.nolife-tv.com/emission-(?P<id>.+)/?.*': VideoPage}
|
||||
|
||||
def is_logged(self):
|
||||
if self.password is None:
|
||||
|
|
@ -70,7 +71,13 @@ class NolifeTVBrowser(BaseBrowser):
|
|||
return self.page.get_video(video)
|
||||
|
||||
def search_videos(self, pattern):
|
||||
self.location('/index.php?', 'search=%s' % urllib.quote_plus(pattern.encode('utf-8')))
|
||||
data = {'a': 'search',
|
||||
'search': pattern.encode('utf-8'),
|
||||
'vu': 'all',
|
||||
}
|
||||
self.openurl('/do.php', urllib.urlencode(data))
|
||||
self.location('/do.php', 'a=em')
|
||||
|
||||
assert self.is_on_page(IndexPage)
|
||||
return self.page.iter_videos()
|
||||
|
||||
|
|
|
|||
|
|
@ -33,26 +33,22 @@ __all__ = ['IndexPage']
|
|||
|
||||
class IndexPage(BasePage):
|
||||
def iter_videos(self):
|
||||
div_list = self.parser.select(self.document.getroot(), 'div.ligne_video')
|
||||
for div in div_list:
|
||||
m = re.match('index.php\?id=(\d+)', div.find('a').attrib['href'])
|
||||
for div in self.parser.select(self.document.getroot(), 'div.data_emissions ul li'):
|
||||
m = re.match('id-(\d+)', div.attrib.get('class', ''))
|
||||
if not m:
|
||||
continue
|
||||
|
||||
img = self.parser.select(div, 'a img', 1)
|
||||
|
||||
video = NolifeTVVideo(m.group(1))
|
||||
video.title = self.parser.select(div, 'span.span_title', 1).text
|
||||
video.description = self.parser.select(div, 'span.span_description', 1).text
|
||||
video.thumbnail = Thumbnail(self.parser.select(div, 'div.screen_video', 1).find('img').attrib['src'])
|
||||
video.title = unicode(img.attrib['alt'])
|
||||
video.description = unicode(self.parser.select(div, 'div.tooltip div.border-bottom p')[-1].text)
|
||||
video.thumbnail = Thumbnail(unicode(img.attrib['src']))
|
||||
try:
|
||||
video.date = parse_dt(self.parser.select(div, 'div.infos_video span.span_title', 1).text.strip())
|
||||
except Exception:
|
||||
video.date = NotAvailable
|
||||
|
||||
rating_url = self.parser.select(div, 'span.description img')[0].attrib['src']
|
||||
m = re.match('.*view_level(\d+)\.gif', rating_url)
|
||||
if m:
|
||||
video.rating = int(m.group(1))
|
||||
video.rating_max = 21
|
||||
else:
|
||||
video.rating = video.rating_max = NotAvailable
|
||||
video.set_empty_fields(NotAvailable, ('url',))
|
||||
|
||||
yield video
|
||||
|
|
|
|||
|
|
@ -83,4 +83,6 @@ class VideoPage(BasePage):
|
|||
raise ForbiddenVideo(values.get('message', 'Not available').decode('iso-8859-15'))
|
||||
video.url = values['url']
|
||||
|
||||
video.set_empty_fields(NotAvailable)
|
||||
|
||||
return video
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ __all__ = ['NolifeTVVideo']
|
|||
class NolifeTVVideo(BaseVideo):
|
||||
def __init__(self, *args, **kwargs):
|
||||
BaseVideo.__init__(self, *args, **kwargs)
|
||||
self.ext = 'mp4'
|
||||
self.ext = u'mp4'
|
||||
|
||||
@classmethod
|
||||
def id2url(cls, _id):
|
||||
return 'http://online.nolife-tv.com/index.php?id=%s' % _id
|
||||
return 'http://online.nolife-tv.com/emission-%s/' % _id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue