]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tvp.py
debian/NEWS: Fix oversight with version and distribution.
[youtubedl] / youtube_dl / extractor / tvp.py
1 import json
2 import re
3
4 from .common import InfoExtractor
5
6
7 class TvpIE(InfoExtractor):
8 IE_NAME = u'tvp.pl'
9 _VALID_URL = r'https?://www\.tvp\.pl/.*?wideo/(?P<date>\d+)/(?P<id>\d+)'
10
11 _TEST = {
12 u'url': u'http://www.tvp.pl/warszawa/magazyny/campusnews/wideo/31102013/12878238',
13 u'md5': u'148408967a6a468953c0a75cbdaf0d7a',
14 u'file': u'12878238.wmv',
15 u'info_dict': {
16 u'title': u'31.10.2013 - Odcinek 2',
17 u'description': u'31.10.2013 - Odcinek 2',
18 },
19 u'skip': u'Download has to use same server IP as extraction. Therefore, a good (load-balancing) DNS resolver will make the download fail.'
20 }
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
24 video_id = mobj.group('id')
25 webpage = self._download_webpage(url, video_id)
26 json_url = 'http://www.tvp.pl/pub/stat/videofileinfo?video_id=%s' % video_id
27 json_params = self._download_webpage(
28 json_url, video_id, u"Downloading video metadata")
29
30 params = json.loads(json_params)
31 self.report_extraction(video_id)
32 video_url = params['video_url']
33
34 title = self._og_search_title(webpage, fatal=True)
35 return {
36 'id': video_id,
37 'title': title,
38 'ext': 'wmv',
39 'url': video_url,
40 'description': self._og_search_description(webpage),
41 'thumbnail': self._og_search_thumbnail(webpage),
42 }