[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / tass.py
blobd4c5b41a718f36b45a6e3d941c0d48e3e907db8c
1 import json
3 from .common import InfoExtractor
4 from ..utils import (
5 js_to_json,
6 qualities,
10 class TassIE(InfoExtractor):
11 _WORKING = False
12 _VALID_URL = r'https?://(?:tass\.ru|itar-tass\.com)/[^/]+/(?P<id>\d+)'
13 _TESTS = [
15 'url': 'http://tass.ru/obschestvo/1586870',
16 'md5': '3b4cdd011bc59174596b6145cda474a4',
17 'info_dict': {
18 'id': '1586870',
19 'ext': 'mp4',
20 'title': 'Посетителям московского зоопарка показали красную панду',
21 'description': 'Приехавшую из Дублина Зейну можно увидеть в павильоне "Кошки тропиков"',
22 'thumbnail': r're:^https?://.*\.jpg$',
26 'url': 'http://itar-tass.com/obschestvo/1600009',
27 'only_matching': True,
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
34 webpage = self._download_webpage(url, video_id)
36 sources = json.loads(js_to_json(self._search_regex(
37 r'(?s)sources\s*:\s*(\[.+?\])', webpage, 'sources')))
39 quality = qualities(['sd', 'hd'])
41 formats = []
42 for source in sources:
43 video_url = source.get('file')
44 if not video_url or not video_url.startswith('http') or not video_url.endswith('.mp4'):
45 continue
46 label = source.get('label')
47 formats.append({
48 'url': video_url,
49 'format_id': label,
50 'quality': quality(label),
53 return {
54 'id': video_id,
55 'title': self._og_search_title(webpage),
56 'description': self._og_search_description(webpage),
57 'thumbnail': self._og_search_thumbnail(webpage),
58 'formats': formats,