3 from .common
import InfoExtractor
12 class MediaKlikkIE(InfoExtractor
):
13 _VALID_URL
= r
'''(?x)https?://(?:www\.)?
14 (?:mediaklikk|m4sport|hirado|petofilive)\.hu/.*?(?:videok?|cikk)/
15 (?:(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/)?
19 'url': 'https://mediaklikk.hu/filmajanlo/cikk/az-ajto/',
23 'display_id': 'az-ajto',
25 'thumbnail': 'https://cdn.cms.mtv.hu/wp-content/uploads/sites/4/2016/01/vlcsnap-2023-07-31-14h18m52s111.jpg',
28 # (old) mediaklikk. date in html.
29 'url': 'https://mediaklikk.hu/video/hazajaro-delnyugat-bacska-a-duna-menten-palankatol-doroszloig/',
32 'title': 'Hazajáró, DÉLNYUGAT-BÁCSKA – A Duna mentén Palánkától Doroszlóig',
34 'upload_date': '20210901',
35 'thumbnail': 'http://mediaklikk.hu/wp-content/uploads/sites/4/2014/02/hazajarouj_JO.jpg',
37 'skip': 'Webpage redirects to 404 page',
39 # mediaklikk. date in html.
40 'url': 'https://mediaklikk.hu/video/hazajaro-fabova-hegyseg-kishont-koronaja/',
43 'title': 'Hazajáró, Fabova-hegység - Kishont koronája',
44 'display_id': 'hazajaro-fabova-hegyseg-kishont-koronaja',
46 'upload_date': '20230903',
47 'thumbnail': 'https://mediaklikk.hu/wp-content/uploads/sites/4/2014/02/hazajarouj_JO.jpg',
49 'skip': 'Webpage redirects to 404 page',
52 'url': 'https://m4sport.hu/video/2021/08/30/gyemant-liga-parizs/',
55 'title': 'Gyémánt Liga, Párizs',
57 'upload_date': '20210830',
58 'thumbnail': 'http://m4sport.hu/wp-content/uploads/sites/4/2021/08/vlcsnap-2021-08-30-18h21m20s10-1024x576.jpg',
60 'skip': 'Webpage redirects to 404 page',
63 'url': 'https://m4sport.hu/sportkozvetitesek/video/2023/09/08/atletika-gyemant-liga-brusszel/',
66 'title': 'Atlétika – Gyémánt Liga, Brüsszel',
67 'display_id': 'atletika-gyemant-liga-brusszel',
69 'upload_date': '20230908',
70 'thumbnail': 'https://m4sport.hu/wp-content/uploads/sites/4/2023/09/vlcsnap-2023-09-08-22h43m18s691.jpg',
72 'skip': 'Webpage redirects to 404 page',
74 # m4sport with *video/ url and no date
75 'url': 'https://m4sport.hu/bl-video/real-madrid-chelsea-1-1/',
78 'title': 'Real Madrid - Chelsea 1-1',
79 'display_id': 'real-madrid-chelsea-1-1',
81 'thumbnail': 'https://m4sport.hu/wp-content/uploads/sites/4/2021/04/Sequence-01.Still001-1024x576.png',
83 'skip': 'Webpage redirects to 404 page',
86 'url': 'https://hirado.hu/videok/felteteleket-szabott-a-fovaros/',
89 'title': 'Feltételeket szabott a főváros',
91 'thumbnail': 'http://hirado.hu/wp-content/uploads/sites/4/2021/09/vlcsnap-2021-09-01-20h20m37s165.jpg',
93 'skip': 'Webpage redirects to video list page',
96 'url': 'https://hirado.hu/belfold/video/2023/09/11/marad-az-eves-elszamolas-a-napelemekre-beruhazo-csaladoknal',
99 'title': 'Marad az éves elszámolás a napelemekre beruházó családoknál',
100 'display_id': 'marad-az-eves-elszamolas-a-napelemekre-beruhazo-csaladoknal',
102 'upload_date': '20230911',
103 'thumbnail': 'https://hirado.hu/wp-content/uploads/sites/4/2023/09/vlcsnap-2023-09-11-09h16m09s882.jpg',
105 'skip': 'Webpage redirects to video list page',
108 'url': 'https://petofilive.hu/video/2021/06/07/tha-shudras-az-akusztikban/',
111 'title': 'Tha Shudras az Akusztikban',
113 'upload_date': '20210607',
114 'thumbnail': 'http://petofilive.hu/wp-content/uploads/sites/4/2021/06/vlcsnap-2021-06-07-22h14m23s915-1024x576.jpg',
116 'skip': 'Webpage redirects to empty page',
119 'url': 'https://petofilive.hu/video/2023/09/09/futball-fesztival-a-margitszigeten/',
122 'title': 'Futball Fesztivál a Margitszigeten',
123 'display_id': 'futball-fesztival-a-margitszigeten',
125 'upload_date': '20230909',
126 'thumbnail': 'https://petofilive.hu/wp-content/uploads/sites/4/2023/09/Clipboard11-2.jpg',
128 'skip': 'Webpage redirects to video list page',
131 def _real_extract(self
, url
):
132 mobj
= self
._match
_valid
_url
(url
)
133 display_id
= mobj
.group('id')
134 webpage
= self
._download
_webpage
(url
, display_id
)
136 player_data_str
= self
._html
_search
_regex
(
137 r
'mtva_player_manager\.player\(document.getElementById\(.*\),\s?(\{.*\}).*\);', webpage
, 'player data')
138 player_data
= self
._parse
_json
(player_data_str
, display_id
, urllib
.parse
.unquote
)
139 video_id
= str(player_data
['contentId'])
140 title
= player_data
.get('title') or self
._og
_search
_title
(webpage
, fatal
=False) or \
141 self
._html
_search
_regex
(r
'<h\d+\b[^>]+\bclass="article_title">([^<]+)<', webpage
, 'title')
143 upload_date
= unified_strdate(
144 '{}-{}-{}'.format(mobj
.group('year'), mobj
.group('month'), mobj
.group('day')))
146 upload_date
= unified_strdate(self
._html
_search
_regex
(
147 r
'<p+\b[^>]+\bclass="article_date">([^<]+)<', webpage
, 'upload date', default
=None))
149 player_data
['video'] = player_data
.pop('token')
150 player_page
= self
._download
_webpage
(
151 'https://player.mediaklikk.hu/playernew/player.php', video_id
,
152 query
=player_data
, headers
={'Referer': url
})
153 player_json
= self
._search
_json
(
154 r
'\bpl\.setup\s*\(', player_page
, 'player json', video_id
, end_pattern
=r
'\);')
155 playlist_url
= traverse_obj(
156 player_json
, ('playlist', lambda _
, v
: v
['type'] == 'hls', 'file', {url_or_none}
), get_all
=False)
158 raise ExtractorError('Unable to extract playlist url')
160 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(playlist_url
, video_id
)
165 'display_id': display_id
,
167 'subtitles': subtitles
,
168 'upload_date': upload_date
,
169 'thumbnail': player_data
.get('bgImage') or self
._og
_search
_thumbnail
(webpage
),