]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nowvideo.py
ab52ad4011851405e9a6b17f73720a8cd646860c
[youtubedl] / youtube_dl / extractor / nowvideo.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import compat_urlparse
5
6
7 class NowVideoIE(InfoExtractor):
8 _VALID_URL = r'(?:https?://)?(?:www\.)?nowvideo\.ch/video/(?P<id>\w+)'
9 _TEST = {
10 u'url': u'http://www.nowvideo.ch/video/0mw0yow7b6dxa',
11 u'file': u'0mw0yow7b6dxa.flv',
12 u'md5': u'f8fbbc8add72bd95b7850c6a02fc8817',
13 u'info_dict': {
14 u"title": u"youtubedl test video _BaW_jenozKc.mp4"
15 }
16 }
17
18 def _real_extract(self, url):
19 mobj = re.match(self._VALID_URL, url)
20
21 video_id = mobj.group('id')
22 webpage_url = 'http://www.nowvideo.ch/video/' + video_id
23 webpage = self._download_webpage(webpage_url, video_id)
24
25 self.report_extraction(video_id)
26
27 video_title = self._html_search_regex(r'<h4>(.*)</h4>',
28 webpage, u'video title')
29
30 video_key = self._search_regex(r'var fkzd="(.*)";',
31 webpage, u'video key')
32
33 api_call = "http://www.nowvideo.ch/api/player.api.php?file={0}&numOfErrors=0&cid=1&key={1}".format(video_id, video_key)
34 api_response = self._download_webpage(api_call, video_id,
35 u'Downloading API page')
36 video_url = compat_urlparse.parse_qs(api_response)[u'url'][0]
37
38 return [{
39 'id': video_id,
40 'url': video_url,
41 'ext': 'flv',
42 'title': video_title,
43 }]