1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-16 16:35:51 +00:00
youtube-dl/youtube_dl/extractor/tvp.py

43 lines
1.5 KiB
Python
Raw Normal View History

import json
2013-11-13 10:06:53 +00:00
import re
from .common import InfoExtractor
2013-11-13 10:06:53 +00:00
class TvpIE(InfoExtractor):
IE_NAME = u'tvp.pl'
_VALID_URL = r'https?://www\.tvp\.pl/.*?wideo/(?P<date>\d+)/(?P<id>\d+)'
_TEST = {
u'url': u'http://www.tvp.pl/warszawa/magazyny/campusnews/wideo/31102013/12878238',
2013-11-13 10:06:53 +00:00
u'md5': u'148408967a6a468953c0a75cbdaf0d7a',
u'file': u'12878238.wmv',
u'info_dict': {
u'title': u'31.10.2013 - Odcinek 2',
u'description': u'31.10.2013 - Odcinek 2',
},
2013-11-16 01:09:30 +00:00
u'skip': u'Download has to use same server IP as extraction. Therefore, a good (load-balancing) DNS resolver will make the download fail.'
}
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
2013-11-13 10:06:53 +00:00
webpage = self._download_webpage(url, video_id)
json_url = 'http://www.tvp.pl/pub/stat/videofileinfo?video_id=%s' % video_id
json_params = self._download_webpage(
json_url, video_id, u"Downloading video metadata")
2013-11-13 10:06:53 +00:00
params = json.loads(json_params)
self.report_extraction(video_id)
2013-11-13 10:06:53 +00:00
video_url = params['video_url']
2013-11-13 10:06:53 +00:00
title = self._og_search_title(webpage, fatal=True)
return {
'id': video_id,
'title': title,
'ext': 'wmv',
'url': video_url,
2013-11-13 10:06:53 +00:00
'description': self._og_search_description(webpage),
'thumbnail': self._og_search_thumbnail(webpage),
}