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,7 +23,19 @@ from weboob.capabilities.video import Video
|
||||||
|
|
||||||
class IndexPage(PornPage):
|
class IndexPage(PornPage):
|
||||||
def iter_videos(self):
|
def iter_videos(self):
|
||||||
for h1 in self.document.getiterator('h1'):
|
uls = self.document.getroot().cssselect("ul[class=clearfix]")
|
||||||
|
if not uls:
|
||||||
|
return
|
||||||
|
|
||||||
|
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')
|
a = h1.find('a')
|
||||||
if a is None:
|
if a is None:
|
||||||
continue
|
continue
|
||||||
|
|
@ -32,4 +44,24 @@ class IndexPage(PornPage):
|
||||||
_id = url[len('/watch/'):]
|
_id = url[len('/watch/'):]
|
||||||
_id = _id[:_id.find('/')]
|
_id = _id[:_id.find('/')]
|
||||||
title = a.text
|
title = a.text
|
||||||
yield Video(int(_id), title)
|
|
||||||
|
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