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