diff options
author | Philipp Hagemeister <[email protected]> | 2014-11-26 10:45:57 +0100 |
---|---|---|
committer | Philipp Hagemeister <[email protected]> | 2014-11-26 10:45:57 +0100 |
commit | d0720e71186ab565bc79913a946e6c6fe8d8f959 (patch) | |
tree | 3d5f07f01a8b38314f314cc7abdc4474f005e235 /youtube_dl | |
parent | 4e262a8838d487362a85eb8b8693d2fa84899f17 (diff) | |
parent | b9ed3af34368e110e6ab2262ce908d2e8572f025 (diff) | |
download | youtube-dl-d0720e71186ab565bc79913a946e6c6fe8d8f959.tar.gz youtube-dl-d0720e71186ab565bc79913a946e6c6fe8d8f959.zip |
Merge branch 'master' of github.com:rg3/youtube-dl
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/__init__.py | 1 | ||||
-rw-r--r-- | youtube_dl/extractor/tass.py | 62 |
2 files changed, 63 insertions, 0 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 3e2133f5c..5c096542b 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -373,6 +373,7 @@ from .syfy import SyfyIE from .sztvhu import SztvHuIE from .tagesschau import TagesschauIE from .tapely import TapelyIE +from .tass import TassIE from .teachertube import ( TeacherTubeIE, TeacherTubeUserIE, diff --git a/youtube_dl/extractor/tass.py b/youtube_dl/extractor/tass.py new file mode 100644 index 000000000..c4ef70778 --- /dev/null +++ b/youtube_dl/extractor/tass.py @@ -0,0 +1,62 @@ +# encoding: utf-8 +from __future__ import unicode_literals + +import json + +from .common import InfoExtractor +from ..utils import ( + js_to_json, + qualities, +) + + +class TassIE(InfoExtractor): + _VALID_URL = r'https?://(?:tass\.ru|itar-tass\.com)/[^/]+/(?P<id>\d+)' + _TESTS = [ + { + 'url': 'http://tass.ru/obschestvo/1586870', + 'md5': '3b4cdd011bc59174596b6145cda474a4', + 'info_dict': { + 'id': '1586870', + 'ext': 'mp4', + 'title': 'Посетителям московского зоопарка показали красную панду', + 'description': 'Приехавшую из Дублина Зейну можно увидеть в павильоне "Кошки тропиков"', + 'thumbnail': 're:^https?://.*\.jpg$', + }, + }, + { + 'url': 'http://itar-tass.com/obschestvo/1600009', + 'only_matching': True, + }, + ] + + def _real_extract(self, url): + video_id = self._match_id(url) + + webpage = self._download_webpage(url, video_id) + + sources = json.loads(js_to_json(self._search_regex( + r'(?s)sources\s*:\s*(\[.+?\])', webpage, 'sources'))) + + quality = qualities(['sd', 'hd']) + + formats = [] + for source in sources: + video_url = source.get('file') + if not video_url or not video_url.startswith('http') or not video_url.endswith('.mp4'): + continue + label = source.get('label') + formats.append({ + 'url': video_url, + 'format_id': label, + 'quality': quality(label), + }) + self._sort_formats(formats) + + return { + 'id': video_id, + 'title': self._og_search_title(webpage), + 'description': self._og_search_description(webpage), + 'thumbnail': self._og_search_thumbnail(webpage), + 'formats': formats, + } |