diff options
author | Sergey M. <dstftw@gmail.com> | 2014-02-11 00:20:41 +0700 |
---|---|---|
committer | Sergey M. <dstftw@gmail.com> | 2014-02-11 00:20:41 +0700 |
commit | 0f6ed94a15ea9f5b9dcc9998e27c7a2bc648deab (patch) | |
tree | 4ccc6ab34312bdcc167b34b3aa01ebb1ca1642a1 | |
parent | bcb891e82b81e7da18b87628a0deb50308543606 (diff) |
[firsttv] Add support for 1tv.ru videoarchive
-rw-r--r-- | youtube_dl/extractor/__init__.py | 1 | ||||
-rw-r--r-- | youtube_dl/extractor/firsttv.py | 59 |
2 files changed, 60 insertions, 0 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index e2a9294dd..4c8d782be 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -64,6 +64,7 @@ from .extremetube import ExtremeTubeIE from .facebook import FacebookIE from .faz import FazIE from .firstpost import FirstpostIE +from .firsttv import FirstTVIE from .fktv import ( FKTVIE, FKTVPosteckeIE, diff --git a/youtube_dl/extractor/firsttv.py b/youtube_dl/extractor/firsttv.py new file mode 100644 index 000000000..20214eac5 --- /dev/null +++ b/youtube_dl/extractor/firsttv.py @@ -0,0 +1,59 @@ +# encoding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import int_or_none + + +class FirstTVIE(InfoExtractor): + IE_NAME = 'firsttv' + IE_DESC = 'Видеоархив - Первый канал' + _VALID_URL = r'http://(?:www\.)?1tv\.ru/videoarchive/(?P<id>\d+)' + + _TEST = { + 'url': 'http://www.1tv.ru/videoarchive/73390', + 'md5': '3de6390cf0cca4a5eae1d1d83895e5ad', + 'info_dict': { + 'id': '73390', + 'ext': 'mp4', + 'title': 'Олимпийские канатные дороги', + 'description': 'md5:cc730d2bf4215463e37fff6a1e277b13', + 'thumbnail': 'http://img1.1tv.ru/imgsize640x360/PR20140210114657.JPG', + 'duration': 149, + } + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + + webpage = self._download_webpage(url, video_id, 'Downloading page') + + video_url = self._html_search_regex( + r'''(?s)jwplayer\('flashvideoportal_1'\).setup\({.*?'file': '([^']+)'.*?}\);''', webpage, 'video URL') + + title = self._html_search_regex( + r'<div class="tv_translation">\s*<h1><a href="[^"]+">([^<]*)</a>', webpage, 'title') + description = self._html_search_regex( + r'<div class="descr">\s*<div> </div>\s*<p>([^<]*)</p></div>', webpage, 'description', fatal=False) + + thumbnail = self._og_search_thumbnail(webpage) + duration = self._og_search_property('video:duration', webpage, 'video duration', fatal=False) + + like_count = self._html_search_regex(r'title="Понравилось".*?/></label> \[(\d+)\]', + webpage, 'like count', fatal=False) + dislike_count = self._html_search_regex(r'title="Не понравилось".*?/></label> \[(\d+)\]', + webpage, 'dislike count', fatal=False) + + return { + 'id': video_id, + 'url': video_url, + 'thumbnail': thumbnail, + 'title': title, + 'description': description, + 'duration': int_or_none(duration), + 'like_count': int_or_none(like_count), + 'dislike_count': int_or_none(dislike_count), + }
\ No newline at end of file |