]>
Commit | Line | Data |
---|---|---|
2e01ba62 BQ |
1 | # coding: utf-8 |
2 | from .common import InfoExtractor | |
3 | from ..utils import int_or_none, parse_duration, parse_iso8601 | |
4 | ||
5 | ||
6 | class NovaPlayIE(InfoExtractor): | |
7 | _VALID_URL = r'https://play.nova\.bg/video/.*/(?P<id>\d+)' | |
8 | _TESTS = [ | |
9 | { | |
10 | 'url': 'https://play.nova.bg/video/bratya/season-3/bratq-2021-10-08/548677', | |
11 | 'md5': 'b1127a84e61bed1632b7c2ca9cbb4153', | |
12 | 'info_dict': { | |
13 | 'id': '548677', | |
14 | 'ext': 'mp4', | |
15 | 'title': 'Братя', | |
16 | 'alt_title': 'bratya/season-3/bratq-2021-10-08', | |
17 | 'duration': 1603.0, | |
18 | 'timestamp': 1633724150, | |
19 | 'upload_date': '20211008', | |
20 | 'thumbnail': 'https://nbg-img.fite.tv/img/548677_460x260.jpg', | |
21 | 'description': 'Сезон 3 Епизод 25' | |
22 | }, | |
23 | }, | |
24 | { | |
25 | 'url': 'https://play.nova.bg/video/igri-na-volqta/season-3/igri-na-volqta-2021-09-20-1/548227', | |
26 | 'md5': '5fd61b8ecbe582fc021019d570965d58', | |
27 | 'info_dict': { | |
28 | 'id': '548227', | |
29 | 'ext': 'mp4', | |
30 | 'title': 'Игри на волята: България (20.09.2021) - част 1', | |
31 | 'alt_title': 'gri-na-volqta/season-3/igri-na-volqta-2021-09-20-1', | |
32 | 'duration': 4060.0, | |
33 | 'timestamp': 1632167564, | |
34 | 'upload_date': '20210920', | |
35 | 'thumbnail': 'https://nbg-img.fite.tv/img/548227_460x260.jpg', | |
36 | 'description': 'Сезон 3 Епизод 13' | |
37 | }, | |
38 | } | |
39 | ] | |
40 | ||
41 | def _real_extract(self, url): | |
42 | video_id = self._match_id(url) | |
43 | webpage = self._download_webpage(url, video_id) | |
135dfa2c | 44 | video_props = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['video'] |
2e01ba62 BQ |
45 | m3u8_url = self._download_json( |
46 | f'https://nbg-api.fite.tv/api/v2/videos/{video_id}/streams', | |
47 | video_id, headers={'x-flipps-user-agent': 'Flipps/75/9.7'})[0]['url'] | |
48 | formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', m3u8_id='hls') | |
49 | self._sort_formats(formats) | |
50 | ||
51 | return { | |
52 | 'id': video_id, | |
53 | 'title': video_props['title'], | |
54 | 'alt_title': video_props.get('slug'), | |
55 | 'thumbnail': self._og_search_thumbnail(webpage), | |
56 | 'description': self._og_search_description(webpage), | |
57 | 'formats': formats, | |
58 | 'duration': parse_duration(video_props['duration']), | |
59 | 'timestamp': parse_iso8601(video_props['published_at']), | |
60 | 'view_count': int_or_none(video_props['view_count']), | |
61 | } |