]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/startv.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / startv.py
CommitLineData
62cdaaf0 1from .common import InfoExtractor
62cdaaf0 2from ..utils import (
62cdaaf0 3 ExtractorError,
e897bd82 4 clean_html,
62cdaaf0 5 int_or_none,
e897bd82 6 traverse_obj,
62cdaaf0 7)
8
9
10class StarTVIE(InfoExtractor):
add96eb9 11 _VALID_URL = r'''(?x)
62cdaaf0 12 https?://(?:www\.)?startv\.com\.tr/
13 (?:
14 (?:dizi|program)/(?:[^/?#&]+)/(?:bolumler|fragmanlar|ekstralar)|
15 video/arsiv/(?:dizi|program)/(?:[^/?#&]+)
16 )/
17 (?P<id>[^/?#&]+)
add96eb9 18 '''
62cdaaf0 19 IE_NAME = 'startv'
20 _TESTS = [
21 {
22 'url': 'https://www.startv.com.tr/dizi/cocuk/bolumler/3-bolum',
23 'md5': '72381a32bcc2e2eb5841e8c8bf68f127',
24 'info_dict': {
25 'id': '904972',
26 'display_id': '3-bolum',
27 'ext': 'mp4',
28 'title': '3. Bölüm',
29 'description': 'md5:3a8049f05a75c2e8747116a673275de4',
30 'thumbnail': r're:^https?://.*\.jpg(?:\?.*?)?$',
31 'timestamp': 1569281400,
add96eb9 32 'upload_date': '20190923',
62cdaaf0 33 },
34 },
35 {
36 'url': 'https://www.startv.com.tr/video/arsiv/dizi/avlu/44-bolum',
add96eb9 37 'only_matching': True,
62cdaaf0 38 },
39 {
40 'url': 'https://www.startv.com.tr/dizi/cocuk/fragmanlar/5-bolum-fragmani',
add96eb9 41 'only_matching': True,
62cdaaf0 42 },
43 {
44 'url': 'https://www.startv.com.tr/dizi/cocuk/ekstralar/5-bolumun-nefes-kesen-final-sahnesi',
add96eb9 45 'only_matching': True,
62cdaaf0 46 },
47 {
48 'url': 'https://www.startv.com.tr/program/burcu-ile-haftasonu/bolumler/1-bolum',
add96eb9 49 'only_matching': True,
62cdaaf0 50 },
51 {
52 'url': 'https://www.startv.com.tr/program/burcu-ile-haftasonu/fragmanlar/2-fragman',
add96eb9 53 'only_matching': True,
62cdaaf0 54 },
55 {
56 'url': 'https://www.startv.com.tr/video/arsiv/program/buyukrisk/14-bolumde-hangi-unlu-ne-sordu-',
add96eb9 57 'only_matching': True,
62cdaaf0 58 },
59 {
60 'url': 'https://www.startv.com.tr/video/arsiv/program/buyukrisk/buyuk-risk-334-bolum',
add96eb9 61 'only_matching': True,
62cdaaf0 62 },
63 {
64 'url': 'https://www.startv.com.tr/video/arsiv/program/dada/dada-58-bolum',
add96eb9 65 'only_matching': True,
66 },
62cdaaf0 67 ]
68
69 def _real_extract(self, url):
70 display_id = self._match_id(url)
71 webpage = self._download_webpage(url, display_id)
72 info_url = self._search_regex(
73 r'(["\'])videoUrl\1\s*:\s*\1(?P<url>(?:(?!\1).)+)\1\s*',
74 webpage, 'video info url', group='url')
75
76 info = traverse_obj(self._download_json(info_url, display_id), 'data', expected_type=dict)
77 if not info:
78 raise ExtractorError('Failed to extract API data')
79
add96eb9 80 video_id = str(info.get('id'))
62cdaaf0 81 title = info.get('title') or self._og_search_title(webpage)
82 description = clean_html(info.get('description')) or self._og_search_description(webpage, default=None)
83 thumbnail = self._proto_relative_url(
84 self._og_search_thumbnail(webpage), scheme='http:')
85
86 formats = self._extract_m3u8_formats(
87 traverse_obj(info, ('flavors', 'hls')), video_id, entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
88
89 return {
90 'id': video_id,
91 'display_id': display_id,
92 'title': title,
93 'description': description,
94 'thumbnail': thumbnail,
95 'timestamp': int_or_none(info.get('release_date')),
add96eb9 96 'formats': formats,
62cdaaf0 97 }