on mosaic, parse preview_url, duration and rating
This commit is contained in:
parent
c3f6618bc8
commit
baa2fd937a
1 changed files with 42 additions and 10 deletions
|
|
@ -23,13 +23,45 @@ from weboob.capabilities.video import Video
|
|||
|
||||
class IndexPage(PornPage):
|
||||
def iter_videos(self):
|
||||
for h1 in self.document.getiterator('h1'):
|
||||
a = h1.find('a')
|
||||
if a is None:
|
||||
continue
|
||||
uls = self.document.getroot().cssselect("ul[class=clearfix]")
|
||||
if not uls:
|
||||
return
|
||||
|
||||
url = a.attrib['href']
|
||||
_id = url[len('/watch/'):]
|
||||
_id = _id[:_id.find('/')]
|
||||
title = a.text
|
||||
yield Video(int(_id), title)
|
||||
for ul in uls:
|
||||
for li in ul.findall('li'):
|
||||
a = li.find('a')
|
||||
if a is None or a.find('img') is None:
|
||||
continue
|
||||
|
||||
preview_url = a.find('img').attrib['src']
|
||||
|
||||
h1 = li.find('h1')
|
||||
a = h1.find('a')
|
||||
if a is None:
|
||||
continue
|
||||
|
||||
url = a.attrib['href']
|
||||
_id = url[len('/watch/'):]
|
||||
_id = _id[:_id.find('/')]
|
||||
title = a.text
|
||||
|
||||
duration = 0
|
||||
div = li.cssselect('div[class=duration_views]')
|
||||
if div:
|
||||
h2 = div[0].find('h2')
|
||||
duration = 60 * int(h2.text)
|
||||
duration += int(h2.find('span').tail)
|
||||
|
||||
rating = 0
|
||||
rating_max = 0
|
||||
div = li.cssselect('div[class=rating]')
|
||||
if div:
|
||||
p = div[0].find('p')
|
||||
rating = float(p.text.strip())
|
||||
rating_max = float(p.find('span').text.strip()[2:])
|
||||
yield Video(int(_id),
|
||||
title,
|
||||
rating=rating,
|
||||
rating_max=rating_max,
|
||||
duration=duration,
|
||||
preview_url=preview_url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue