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