]>
Commit | Line | Data |
---|---|---|
2e01ba62 BQ |
1 | from .common import InfoExtractor |
2 | from ..utils import int_or_none, parse_duration, parse_iso8601 | |
3 | ||
4 | ||
5 | class NovaPlayIE(InfoExtractor): | |
a687226b | 6 | _VALID_URL = r'https?://play\.nova\.bg/video/[^?#]+/(?P<id>\d+)' |
2e01ba62 BQ |
7 | _TESTS = [ |
8 | { | |
aeaf905e BQ |
9 | 'url': 'https://play.nova.bg/video/ochakvaite/season-0/ochakvaite-2022-07-22-sybudi-se-sat/606627', |
10 | 'md5': 'd79dff2d09d196c595a7290f48e33399', | |
2e01ba62 | 11 | 'info_dict': { |
aeaf905e | 12 | 'id': '606627', |
2e01ba62 | 13 | 'ext': 'mp4', |
aeaf905e BQ |
14 | 'title': 'Събуди се - събота по NOVA (23.07.2022)', |
15 | 'alt_title': 'ochakvaite/season-0/ochakvaite-2022-07-22-sybudi-se-sat', | |
16 | 'duration': 29.0, | |
17 | 'timestamp': 1658491547, | |
18 | 'upload_date': '20220722', | |
19 | 'thumbnail': 'https://nbg-img.fite.tv/img/606627_460x260.jpg', | |
20 | 'description': '29 сек', | |
2e01ba62 BQ |
21 | }, |
22 | }, | |
23 | { | |
aeaf905e BQ |
24 | 'url': 'https://play.nova.bg/video/ochakvaite/season-0/ochakvaite-2022-07-22-cherry-tazi/606609', |
25 | 'md5': 'f3e973e2ed1a5b9b3f498b1ab82d01b3', | |
2e01ba62 | 26 | 'info_dict': { |
aeaf905e | 27 | 'id': '606609', |
2e01ba62 | 28 | 'ext': 'mp4', |
aeaf905e BQ |
29 | 'title': 'Черешката на тортата - тази вечер по NOVA (22.07.2022)', |
30 | 'alt_title': 'ochakvaite/season-0/ochakvaite-2022-07-22-cherry-tazi', | |
31 | 'duration': 29.0, | |
32 | 'timestamp': 1658476303, | |
33 | 'upload_date': '20220722', | |
34 | 'thumbnail': 'https://nbg-img.fite.tv/img/606609_460x260.jpg', | |
35 | 'description': '29 сек', | |
2e01ba62 BQ |
36 | }, |
37 | } | |
38 | ] | |
39 | ||
aeaf905e BQ |
40 | _access_token = None |
41 | ||
2e01ba62 BQ |
42 | def _real_extract(self, url): |
43 | video_id = self._match_id(url) | |
44 | webpage = self._download_webpage(url, video_id) | |
aeaf905e BQ |
45 | self._access_token = self._access_token or self._download_json( |
46 | 'https://play.nova.bg/api/client', None, note='Fetching access token')['accessToken'] | |
135dfa2c | 47 | video_props = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['video'] |
2e01ba62 BQ |
48 | m3u8_url = self._download_json( |
49 | f'https://nbg-api.fite.tv/api/v2/videos/{video_id}/streams', | |
aeaf905e BQ |
50 | video_id, headers={ |
51 | 'x-flipps-user-agent': 'Flipps/75/9.7', | |
52 | 'x-flipps-version': '2022-05-17', | |
53 | 'Authorization': f'Bearer {self._access_token}' | |
54 | })[0]['links']['play']['href'] | |
2e01ba62 | 55 | formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', m3u8_id='hls') |
2e01ba62 BQ |
56 | |
57 | return { | |
58 | 'id': video_id, | |
59 | 'title': video_props['title'], | |
60 | 'alt_title': video_props.get('slug'), | |
61 | 'thumbnail': self._og_search_thumbnail(webpage), | |
62 | 'description': self._og_search_description(webpage), | |
63 | 'formats': formats, | |
64 | 'duration': parse_duration(video_props['duration']), | |
65 | 'timestamp': parse_iso8601(video_props['published_at']), | |
66 | 'view_count': int_or_none(video_props['view_count']), | |
67 | } |