overload & and | operators to chain filters (refs #1426)
This commit is contained in:
parent
e025fb0b20
commit
8efd37e71d
5 changed files with 66 additions and 47 deletions
|
|
@ -72,12 +72,12 @@ class PastePage(BasePastebinPage):
|
|||
self.env['header'] = el.find('//div[@id="content_left"]//div[@class="paste_box_info"]')
|
||||
|
||||
obj_id = Env('id')
|
||||
obj_title = Base(Env('header'), CleanText('.//div[@class="paste_box_line1"]//h1'))
|
||||
obj_title = Base(Env('header')) & CleanText('.//div[@class="paste_box_line1"]//h1')
|
||||
obj_contents = RawText('//textarea[@id="paste_code"]')
|
||||
obj_public = Base(
|
||||
Env('header'),
|
||||
CleanVisibility(Attr('.//div[@class="paste_box_line1"]//img', 'title')))
|
||||
obj__date = Base(Env('header'), DateTime(Attr('.//div[@class="paste_box_line2"]/span[1]', 'title')))
|
||||
obj_public = Base(Env('header')) \
|
||||
& Attr('.//div[@class="paste_box_line1"]//img', 'title') \
|
||||
& CleanVisibility()
|
||||
obj__date = Base(Env('header')) & Attr('.//div[@class="paste_box_line2"]/span[1]', 'title') & DateTime()
|
||||
|
||||
|
||||
class PostPage(BasePastebinPage):
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
from weboob.tools.browser2 import HTMLPage
|
||||
from weboob.tools.browser2.page import ListElement, method, ItemElement, pagination
|
||||
from weboob.tools.browser2.filters import Link, CleanText, Duration, Regexp
|
||||
from weboob.tools.browser2.filters import Link, CleanText, Duration, Regexp, CSS
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.capabilities.image import BaseImage
|
||||
from weboob.capabilities.video import BaseVideo
|
||||
|
|
@ -40,9 +40,9 @@ class IndexPage(HTMLPage):
|
|||
class item(ItemElement):
|
||||
klass = BaseVideo
|
||||
|
||||
obj_id = Regexp(Link('.//a'), r'/videos/(.+)\.html')
|
||||
obj_title = CleanText('.//span[@id="title1"]')
|
||||
obj_duration = Duration(CleanText('.//span[@class="thumbtime"]//span'), default=NotAvailable)
|
||||
obj_id = CSS('a') & Link() & Regexp(pattern=r'/videos/(.+)\.html')
|
||||
obj_title = CSS('span#title1') & CleanText()
|
||||
obj_duration = CSS('span.thumbtime span') & CleanText() & Duration() | NotAvailable
|
||||
obj_nsfw = True
|
||||
|
||||
def obj_thumbnail(self):
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class VideoPage(HTMLPage):
|
|||
obj_title = CleanText('//title')
|
||||
obj_nsfw = True
|
||||
obj_ext = u'flv'
|
||||
obj_duration = Duration(CleanText('//div[@id="video_text"]'))
|
||||
obj_duration = CleanText('//div[@id="video_text"]') & Duration()
|
||||
|
||||
def obj_url(self):
|
||||
real_id = int(self.env['id'].split('-')[-1])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue