]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/tvp.py
[youtube:channel] Fix the extraction of autogenerated channels
[yt-dlp.git] / youtube_dl / extractor / tvp.py
CommitLineData
5137ebac 1import json
c3a3028f 2import re
5137ebac
MC
3
4from .common import InfoExtractor
c3a3028f 5
5137ebac
MC
6
7class TvpIE(InfoExtractor):
8 IE_NAME = u'tvp.pl'
9 _VALID_URL = r'https?://www\.tvp\.pl/.*?wideo/(?P<date>\d+)/(?P<id>\d+)'
5137ebac
MC
10
11 _TEST = {
12 u'url': u'http://www.tvp.pl/warszawa/magazyny/campusnews/wideo/31102013/12878238',
c3a3028f
PH
13 u'md5': u'148408967a6a468953c0a75cbdaf0d7a',
14 u'file': u'12878238.wmv',
5137ebac
MC
15 u'info_dict': {
16 u'title': u'31.10.2013',
17 u'description': u'31.10.2013',
18 },
19 }
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
23 video_id = mobj.group('id')
c3a3028f
PH
24 webpage = self._download_webpage(url, video_id)
25 json_url = 'http://www.tvp.pl/pub/stat/videofileinfo?video_id=%s' % video_id
26 json_params = self._download_webpage(
27 json_url, video_id, u"Downloading video metadata")
5137ebac 28
c3a3028f 29 params = json.loads(json_params)
5137ebac 30 self.report_extraction(video_id)
c3a3028f 31 video_url = params['video_url']
5137ebac 32
c3a3028f
PH
33 title = self._og_search_title(webpage, fatal=True)
34 return {
5137ebac
MC
35 'id': video_id,
36 'title': title,
37 'ext': 'wmv',
38 'url': video_url,
c3a3028f
PH
39 'description': self._og_search_description(webpage),
40 'thumbnail': self._og_search_thumbnail(webpage),
5137ebac 41 }