add liveweb.arte.tv url management in arte module

This commit is contained in:
Bezleputh 2013-09-19 18:23:33 +02:00
commit 9d933a00eb
3 changed files with 25 additions and 3 deletions

View file

@ -55,7 +55,9 @@ class ArteBackend(BaseBackend, ICapVideo, ICapCollection):
if m:
return 'videos', m.group(1)
# TODO support live videos
m = re.match('https?://liveweb.arte.tv/\w+/video/(.*)/', _id)
if m:
return 'live_url', _id
return 'videos', _id
@ -65,6 +67,10 @@ class ArteBackend(BaseBackend, ICapVideo, ICapCollection):
if site == 'live':
return self.browser.get_live_video(_id)
elif site == 'live_url':
return self.browser.get_live_from_url(_id)
else:
return self.browser.get_video(_id)

View file

@ -21,7 +21,7 @@
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser.decorators import id2url
from .pages import IndexPage, VideoPage, ArteLivePage, ArteLiveCategorieVideoPage, ArteLiveVideoPage
from .pages import IndexPage, VideoPage, ArteLivePage, ArteLiveCategorieVideoPage, ArteLiveVideoPage, ArteLivePlayerPage
from .video import ArteVideo, ArteLiveVideo
@ -36,6 +36,7 @@ class ArteBrowser(BaseBrowser):
r'http://videos.arte.tv/\w+/videos/(?P<id>.+)\.html': VideoPage,
r'http://liveweb.arte.tv/\w+' : ArteLivePage,
r'http://liveweb.arte.tv/\w+/cat/.*' : ArteLiveCategorieVideoPage,
r'http://liveweb.arte.tv/\w+/video/.*': ArteLivePlayerPage,
r'http://arte.vo.llnwd.net/o21/liveweb/events/event-(?P<id>.+).xml' : ArteLiveVideoPage,
}
@ -79,3 +80,10 @@ class ArteBrowser(BaseBrowser):
self.location(url)
assert self.is_on_page(ArteLiveCategorieVideoPage)
return self.page.iter_videos(self.lang)
def get_live_from_url(self, url):
self.location(url)
assert self.is_on_page(ArteLivePlayerPage)
_id = self.page.retrieve_id()
if _id:
return self.get_live_video(_id)

View file

@ -36,7 +36,7 @@ __all__ = ['IndexPage', 'VideoPage', 'ArteLivePage', 'ArteLiveCategorieVideoPage
class ArteLiveVideoPage(BasePage):
def get_video(self, video=None, lang='fr', quality='hd'):
if not video:
video = ArteVideo(self.group_dict['id'])
video = ArteLiveVideo(self.group_dict['id'])
urls = {}
for url in self.document.xpath('//video')[0].getchildren():
@ -214,3 +214,11 @@ class VideoPage(BasePage):
video_url = urls.popitem()[1]
return video_url
class ArteLivePlayerPage(BasePage):
def retrieve_id(self):
player_url = self.document.xpath('//div[@class="flash"]/div/object/param')[0].attrib['value']
_id = re.match('(.*)&eventId=(\d*)&(.*)', player_url)
if _id:
return u'%s' % _id.group(2)