]>
Commit | Line | Data |
---|---|---|
e897bd82 SS |
1 | from .common import InfoExtractor |
2 | from ..compat import compat_str, compat_urllib_parse_unquote | |
bccdbd22 | 3 | from ..utils import ( |
6e07e4bc | 4 | ExtractorError, |
5 | traverse_obj, | |
6 | unified_strdate, | |
7 | url_or_none, | |
bccdbd22 | 8 | ) |
bccdbd22 | 9 | |
10 | ||
11 | class MediaKlikkIE(InfoExtractor): | |
f7b558df | 12 | _VALID_URL = r'''(?x)https?://(?:www\.)? |
13 | (?:mediaklikk|m4sport|hirado|petofilive)\.hu/.*?(?:videok?|cikk)/ | |
bccdbd22 | 14 | (?:(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/)? |
15 | (?P<id>[^/#?_]+)''' | |
16 | ||
17 | _TESTS = [{ | |
6e07e4bc | 18 | # (old) mediaklikk. date in html. |
bccdbd22 | 19 | 'url': 'https://mediaklikk.hu/video/hazajaro-delnyugat-bacska-a-duna-menten-palankatol-doroszloig/', |
20 | 'info_dict': { | |
21 | 'id': '4754129', | |
22 | 'title': 'Hazajáró, DÉLNYUGAT-BÁCSKA – A Duna mentén Palánkától Doroszlóig', | |
23 | 'ext': 'mp4', | |
24 | 'upload_date': '20210901', | |
25 | 'thumbnail': 'http://mediaklikk.hu/wp-content/uploads/sites/4/2014/02/hazajarouj_JO.jpg' | |
6e07e4bc | 26 | }, |
27 | 'skip': 'Webpage redirects to 404 page', | |
28 | }, { | |
29 | # mediaklikk. date in html. | |
30 | 'url': 'https://mediaklikk.hu/video/hazajaro-fabova-hegyseg-kishont-koronaja/', | |
31 | 'info_dict': { | |
32 | 'id': '6696133', | |
33 | 'title': 'Hazajáró, Fabova-hegység - Kishont koronája', | |
34 | 'display_id': 'hazajaro-fabova-hegyseg-kishont-koronaja', | |
35 | 'ext': 'mp4', | |
36 | 'upload_date': '20230903', | |
37 | 'thumbnail': 'https://mediaklikk.hu/wp-content/uploads/sites/4/2014/02/hazajarouj_JO.jpg' | |
bccdbd22 | 38 | } |
39 | }, { | |
6e07e4bc | 40 | # (old) m4sport |
bccdbd22 | 41 | 'url': 'https://m4sport.hu/video/2021/08/30/gyemant-liga-parizs/', |
42 | 'info_dict': { | |
43 | 'id': '4754999', | |
44 | 'title': 'Gyémánt Liga, Párizs', | |
45 | 'ext': 'mp4', | |
46 | 'upload_date': '20210830', | |
47 | 'thumbnail': 'http://m4sport.hu/wp-content/uploads/sites/4/2021/08/vlcsnap-2021-08-30-18h21m20s10-1024x576.jpg' | |
6e07e4bc | 48 | }, |
49 | 'skip': 'Webpage redirects to 404 page', | |
50 | }, { | |
51 | # m4sport | |
52 | 'url': 'https://m4sport.hu/sportkozvetitesek/video/2023/09/08/atletika-gyemant-liga-brusszel/', | |
53 | 'info_dict': { | |
54 | 'id': '6711136', | |
55 | 'title': 'Atlétika – Gyémánt Liga, Brüsszel', | |
56 | 'display_id': 'atletika-gyemant-liga-brusszel', | |
57 | 'ext': 'mp4', | |
58 | 'upload_date': '20230908', | |
59 | 'thumbnail': 'https://m4sport.hu/wp-content/uploads/sites/4/2023/09/vlcsnap-2023-09-08-22h43m18s691.jpg' | |
bccdbd22 | 60 | } |
61 | }, { | |
62 | # m4sport with *video/ url and no date | |
63 | 'url': 'https://m4sport.hu/bl-video/real-madrid-chelsea-1-1/', | |
64 | 'info_dict': { | |
65 | 'id': '4492099', | |
66 | 'title': 'Real Madrid - Chelsea 1-1', | |
6e07e4bc | 67 | 'display_id': 'real-madrid-chelsea-1-1', |
bccdbd22 | 68 | 'ext': 'mp4', |
6e07e4bc | 69 | 'thumbnail': 'https://m4sport.hu/wp-content/uploads/sites/4/2021/04/Sequence-01.Still001-1024x576.png' |
bccdbd22 | 70 | } |
71 | }, { | |
6e07e4bc | 72 | # (old) hirado |
bccdbd22 | 73 | 'url': 'https://hirado.hu/videok/felteteleket-szabott-a-fovaros/', |
74 | 'info_dict': { | |
75 | 'id': '4760120', | |
76 | 'title': 'Feltételeket szabott a főváros', | |
77 | 'ext': 'mp4', | |
78 | 'thumbnail': 'http://hirado.hu/wp-content/uploads/sites/4/2021/09/vlcsnap-2021-09-01-20h20m37s165.jpg' | |
6e07e4bc | 79 | }, |
80 | 'skip': 'Webpage redirects to video list page', | |
81 | }, { | |
82 | # hirado | |
83 | 'url': 'https://hirado.hu/belfold/video/2023/09/11/marad-az-eves-elszamolas-a-napelemekre-beruhazo-csaladoknal', | |
84 | 'info_dict': { | |
85 | 'id': '6716068', | |
86 | 'title': 'Marad az éves elszámolás a napelemekre beruházó családoknál', | |
87 | 'display_id': 'marad-az-eves-elszamolas-a-napelemekre-beruhazo-csaladoknal', | |
88 | 'ext': 'mp4', | |
89 | 'upload_date': '20230911', | |
90 | 'thumbnail': 'https://hirado.hu/wp-content/uploads/sites/4/2023/09/vlcsnap-2023-09-11-09h16m09s882.jpg' | |
bccdbd22 | 91 | } |
92 | }, { | |
6e07e4bc | 93 | # (old) petofilive |
bccdbd22 | 94 | 'url': 'https://petofilive.hu/video/2021/06/07/tha-shudras-az-akusztikban/', |
95 | 'info_dict': { | |
96 | 'id': '4571948', | |
97 | 'title': 'Tha Shudras az Akusztikban', | |
98 | 'ext': 'mp4', | |
99 | 'upload_date': '20210607', | |
100 | 'thumbnail': 'http://petofilive.hu/wp-content/uploads/sites/4/2021/06/vlcsnap-2021-06-07-22h14m23s915-1024x576.jpg' | |
6e07e4bc | 101 | }, |
102 | 'skip': 'Webpage redirects to empty page', | |
103 | }, { | |
104 | # petofilive | |
105 | 'url': 'https://petofilive.hu/video/2023/09/09/futball-fesztival-a-margitszigeten/', | |
106 | 'info_dict': { | |
107 | 'id': '6713233', | |
108 | 'title': 'Futball Fesztivál a Margitszigeten', | |
109 | 'display_id': 'futball-fesztival-a-margitszigeten', | |
110 | 'ext': 'mp4', | |
111 | 'upload_date': '20230909', | |
112 | 'thumbnail': 'https://petofilive.hu/wp-content/uploads/sites/4/2023/09/Clipboard11-2.jpg' | |
bccdbd22 | 113 | } |
114 | }] | |
115 | ||
116 | def _real_extract(self, url): | |
117 | mobj = self._match_valid_url(url) | |
118 | display_id = mobj.group('id') | |
119 | webpage = self._download_webpage(url, display_id) | |
120 | ||
121 | player_data_str = self._html_search_regex( | |
122 | r'mtva_player_manager\.player\(document.getElementById\(.*\),\s?(\{.*\}).*\);', webpage, 'player data') | |
123 | player_data = self._parse_json(player_data_str, display_id, compat_urllib_parse_unquote) | |
124 | video_id = compat_str(player_data['contentId']) | |
125 | title = player_data.get('title') or self._og_search_title(webpage, fatal=False) or \ | |
126 | self._html_search_regex(r'<h\d+\b[^>]+\bclass="article_title">([^<]+)<', webpage, 'title') | |
127 | ||
128 | upload_date = unified_strdate( | |
129 | '%s-%s-%s' % (mobj.group('year'), mobj.group('month'), mobj.group('day'))) | |
130 | if not upload_date: | |
131 | upload_date = unified_strdate(self._html_search_regex( | |
132 | r'<p+\b[^>]+\bclass="article_date">([^<]+)<', webpage, 'upload date', default=None)) | |
133 | ||
134 | player_data['video'] = player_data.pop('token') | |
135 | player_page = self._download_webpage('https://player.mediaklikk.hu/playernew/player.php', video_id, query=player_data) | |
6e07e4bc | 136 | player_json = self._search_json( |
137 | r'\bpl\.setup\s*\(', player_page, 'player json', video_id, end_pattern=r'\);') | |
138 | playlist_url = traverse_obj( | |
139 | player_json, ('playlist', lambda _, v: v['type'] == 'hls', 'file', {url_or_none}), get_all=False) | |
140 | if not playlist_url: | |
141 | raise ExtractorError('Unable to extract playlist url') | |
bccdbd22 | 142 | |
143 | formats = self._extract_wowza_formats( | |
144 | playlist_url, video_id, skip_protocols=['f4m', 'smil', 'dash']) | |
bccdbd22 | 145 | |
146 | return { | |
147 | 'id': video_id, | |
148 | 'title': title, | |
149 | 'display_id': display_id, | |
150 | 'formats': formats, | |
151 | 'upload_date': upload_date, | |
152 | 'thumbnail': player_data.get('bgImage') or self._og_search_thumbnail(webpage) | |
153 | } |