diff options
author | Philipp Hagemeister <[email protected]> | 2014-11-26 12:58:53 +0100 |
---|---|---|
committer | Philipp Hagemeister <[email protected]> | 2014-11-26 12:58:53 +0100 |
commit | 24144e3b8d465cb1d142bb1ff0450669ecceb2a0 (patch) | |
tree | a581913b82fbebd959cc1741158985989b0f338f | |
parent | b3034f9df78b17fc496339db7cfb0d1c59f509a8 (diff) | |
download | youtube-dl-24144e3b8d465cb1d142bb1ff0450669ecceb2a0.tar.gz youtube-dl-24144e3b8d465cb1d142bb1ff0450669ecceb2a0.zip |
[tvp] Modernize
-rw-r--r-- | youtube_dl/extractor/tvp.py | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/youtube_dl/extractor/tvp.py b/youtube_dl/extractor/tvp.py index bfed9dd04..a64580005 100644 --- a/youtube_dl/extractor/tvp.py +++ b/youtube_dl/extractor/tvp.py @@ -1,40 +1,35 @@ -import json -import re +from __future__ import unicode_literals from .common import InfoExtractor class TvpIE(InfoExtractor): - IE_NAME = u'tvp.pl' + IE_NAME = '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', - 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', + 'url': 'http://www.tvp.pl/warszawa/magazyny/campusnews/wideo/31102013/12878238', + 'md5': '148408967a6a468953c0a75cbdaf0d7a', + 'info_dict': { + 'id': '12878238', + 'ext': 'wmv', + 'title': '31.10.2013 - Odcinek 2', + 'description': '31.10.2013 - Odcinek 2', }, - u'skip': u'Download has to use same server IP as extraction. Therefore, a good (load-balancing) DNS resolver will make the download fail.' + 'skip': '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') + video_id = self._match_id(url) 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") - - params = json.loads(json_params) - self.report_extraction(video_id) + params = self._download_json( + json_url, video_id, "Downloading video metadata") video_url = params['video_url'] - title = self._og_search_title(webpage, fatal=True) return { 'id': video_id, - 'title': title, + 'title': self._og_search_title(webpage), 'ext': 'wmv', 'url': video_url, 'description': self._og_search_description(webpage), |