]>
Commit | Line | Data |
---|---|---|
3ef1d0c7 | 1 | from .common import InfoExtractor |
58f68fe7 | 2 | from ..utils import ( |
58f68fe7 | 3 | UnsupportedError, |
e897bd82 | 4 | traverse_obj, |
58f68fe7 | 5 | ) |
3ef1d0c7 | 6 | |
3ef1d0c7 | 7 | |
e4d74e27 | 8 | class TV2HuIE(InfoExtractor): |
58f68fe7 A |
9 | IE_NAME = 'tv2play.hu' |
10 | _VALID_URL = r'https?://(?:www\.)?tv2play\.hu/(?!szalag/)(?P<id>[^#&?]+)' | |
3ef1d0c7 | 11 | _TESTS = [{ |
58f68fe7 | 12 | 'url': 'https://tv2play.hu/mintaapak/mintaapak_213_epizod_resz', |
3ef1d0c7 | 13 | 'info_dict': { |
58f68fe7 | 14 | 'id': '249240', |
3ef1d0c7 | 15 | 'ext': 'mp4', |
58f68fe7 A |
16 | 'title': 'Mintaapák - 213. epizód', |
17 | 'series': 'Mintaapák', | |
18 | 'duration': 2164, | |
19 | 'description': 'md5:7350147e75485a59598e806c47967b07', | |
20 | 'thumbnail': r're:^https?://.*\.jpg$', | |
21 | 'release_date': '20210825', | |
58f68fe7 A |
22 | 'episode_number': 213, |
23 | }, | |
24 | 'params': { | |
25 | 'skip_download': True, | |
26 | }, | |
3ef1d0c7 | 27 | }, { |
58f68fe7 A |
28 | 'url': 'https://tv2play.hu/taxi_2', |
29 | 'md5': '585e58e2e090f34603804bb2c48e98d8', | |
30 | 'info_dict': { | |
31 | 'id': '199363', | |
32 | 'ext': 'mp4', | |
33 | 'title': 'Taxi 2', | |
34 | 'series': 'Taxi 2', | |
35 | 'duration': 5087, | |
36 | 'description': 'md5:47762155dc9a50241797ded101b1b08c', | |
37 | 'thumbnail': r're:^https?://.*\.jpg$', | |
38 | 'release_date': '20210118', | |
58f68fe7 A |
39 | }, |
40 | 'params': { | |
41 | 'skip_download': True, | |
42 | }, | |
3ef1d0c7 V |
43 | }] |
44 | ||
45 | def _real_extract(self, url): | |
add96eb9 | 46 | video_id = self._match_id(url) |
47 | json_data = self._download_json(f'https://tv2play.hu/api/search/{video_id}', video_id) | |
58f68fe7 A |
48 | |
49 | if json_data['contentType'] == 'showpage': | |
50 | ribbon_ids = traverse_obj(json_data, ('pages', ..., 'tabs', ..., 'ribbonIds'), get_all=False, expected_type=list) | |
51 | entries = [self.url_result(f'https://tv2play.hu/szalag/{ribbon_id}', | |
52 | ie=TV2HuSeriesIE.ie_key(), video_id=ribbon_id) for ribbon_id in ribbon_ids] | |
add96eb9 | 53 | return self.playlist_result(entries, playlist_id=video_id) |
58f68fe7 A |
54 | elif json_data['contentType'] != 'video': |
55 | raise UnsupportedError(url) | |
56 | ||
57 | video_id = str(json_data['id']) | |
58 | player_id = json_data.get('playerId') | |
59 | series_json = json_data.get('seriesInfo', {}) | |
60 | ||
61 | video_json_url = self._download_json(f'https://tv2play.hu/api/streaming-url?playerId={player_id}', video_id)['url'] | |
62 | video_json = self._download_json(video_json_url, video_id) | |
63 | m3u8_url = self._proto_relative_url(traverse_obj(video_json, ('bitrates', 'hls'))) | |
64 | formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id) | |
3ef1d0c7 V |
65 | |
66 | return { | |
67 | 'id': video_id, | |
58f68fe7 A |
68 | 'title': json_data['title'], |
69 | 'series': json_data.get('seriesTitle'), | |
70 | 'duration': json_data.get('length'), | |
71 | 'description': json_data.get('description'), | |
72 | 'thumbnail': 'https://tv2play.hu' + json_data.get('thumbnailUrl'), | |
73 | 'release_date': json_data.get('uploadedAt').replace('.', ''), | |
74 | 'season_number': series_json.get('seasonNr'), | |
75 | 'episode_number': series_json.get('episodeNr'), | |
e4d74e27 | 76 | 'formats': formats, |
58f68fe7 | 77 | 'subtitles': subtitles, |
3ef1d0c7 | 78 | } |
58f68fe7 A |
79 | |
80 | ||
81 | class TV2HuSeriesIE(InfoExtractor): | |
82 | IE_NAME = 'tv2playseries.hu' | |
83 | _VALID_URL = r'https?://(?:www\.)?tv2play\.hu/szalag/(?P<id>[^#&?]+)' | |
84 | ||
85 | _TESTS = [{ | |
86 | 'url': 'https://tv2play.hu/szalag/59?rendezes=nepszeruseg', | |
87 | 'playlist_mincount': 284, | |
88 | 'info_dict': { | |
89 | 'id': '59', | |
add96eb9 | 90 | }, |
58f68fe7 A |
91 | }] |
92 | ||
93 | def _real_extract(self, url): | |
add96eb9 | 94 | playlist_id = self._match_id(url) |
95 | json_data = self._download_json(f'https://tv2play.hu/api/ribbons/{playlist_id}/0?size=100000', playlist_id) | |
58f68fe7 A |
96 | entries = [] |
97 | for card in json_data.get('cards', []): | |
98 | video_id = card.get('slug') | |
99 | if video_id: | |
add96eb9 | 100 | entries.append(self.url_result( |
101 | f'https://tv2play.hu/{video_id}', TV2HuIE, video_id)) | |
58f68fe7 | 102 | |
add96eb9 | 103 | return self.playlist_result(entries, playlist_id=playlist_id) |