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):
|
class NolifeTVBrowser(BaseBrowser):
|
||||||
DOMAIN = 'online.nolife-tv.com'
|
DOMAIN = 'online.nolife-tv.com'
|
||||||
ENCODING = None
|
ENCODING = 'utf-8'
|
||||||
PAGES = {r'http://online.nolife-tv.com/index.php\??': IndexPage,
|
PAGES = {r'http://online.nolife-tv.com/index.php\??': IndexPage,
|
||||||
r'http://online.nolife-tv.com/': 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):
|
def is_logged(self):
|
||||||
if self.password is None:
|
if self.password is None:
|
||||||
|
|
@ -70,7 +71,13 @@ class NolifeTVBrowser(BaseBrowser):
|
||||||
return self.page.get_video(video)
|
return self.page.get_video(video)
|
||||||
|
|
||||||
def search_videos(self, pattern):
|
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)
|
assert self.is_on_page(IndexPage)
|
||||||
return self.page.iter_videos()
|
return self.page.iter_videos()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,26 +33,22 @@ __all__ = ['IndexPage']
|
||||||
|
|
||||||
class IndexPage(BasePage):
|
class IndexPage(BasePage):
|
||||||
def iter_videos(self):
|
def iter_videos(self):
|
||||||
div_list = self.parser.select(self.document.getroot(), 'div.ligne_video')
|
for div in self.parser.select(self.document.getroot(), 'div.data_emissions ul li'):
|
||||||
for div in div_list:
|
m = re.match('id-(\d+)', div.attrib.get('class', ''))
|
||||||
m = re.match('index.php\?id=(\d+)', div.find('a').attrib['href'])
|
|
||||||
if not m:
|
if not m:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
img = self.parser.select(div, 'a img', 1)
|
||||||
|
|
||||||
video = NolifeTVVideo(m.group(1))
|
video = NolifeTVVideo(m.group(1))
|
||||||
video.title = self.parser.select(div, 'span.span_title', 1).text
|
video.title = unicode(img.attrib['alt'])
|
||||||
video.description = self.parser.select(div, 'span.span_description', 1).text
|
video.description = unicode(self.parser.select(div, 'div.tooltip div.border-bottom p')[-1].text)
|
||||||
video.thumbnail = Thumbnail(self.parser.select(div, 'div.screen_video', 1).find('img').attrib['src'])
|
video.thumbnail = Thumbnail(unicode(img.attrib['src']))
|
||||||
try:
|
try:
|
||||||
video.date = parse_dt(self.parser.select(div, 'div.infos_video span.span_title', 1).text.strip())
|
video.date = parse_dt(self.parser.select(div, 'div.infos_video span.span_title', 1).text.strip())
|
||||||
except Exception:
|
except Exception:
|
||||||
video.date = NotAvailable
|
video.date = NotAvailable
|
||||||
|
|
||||||
rating_url = self.parser.select(div, 'span.description img')[0].attrib['src']
|
video.set_empty_fields(NotAvailable, ('url',))
|
||||||
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
|
|
||||||
|
|
||||||
yield video
|
yield video
|
||||||
|
|
|
||||||
|
|
@ -83,4 +83,6 @@ class VideoPage(BasePage):
|
||||||
raise ForbiddenVideo(values.get('message', 'Not available').decode('iso-8859-15'))
|
raise ForbiddenVideo(values.get('message', 'Not available').decode('iso-8859-15'))
|
||||||
video.url = values['url']
|
video.url = values['url']
|
||||||
|
|
||||||
|
video.set_empty_fields(NotAvailable)
|
||||||
|
|
||||||
return video
|
return video
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ __all__ = ['NolifeTVVideo']
|
||||||
class NolifeTVVideo(BaseVideo):
|
class NolifeTVVideo(BaseVideo):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
BaseVideo.__init__(self, *args, **kwargs)
|
BaseVideo.__init__(self, *args, **kwargs)
|
||||||
self.ext = 'mp4'
|
self.ext = u'mp4'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def id2url(cls, _id):
|
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