]>
Commit | Line | Data |
---|---|---|
1 | from ..utils import ( | |
2 | unified_strdate | |
3 | ) | |
4 | from .common import InfoExtractor | |
5 | from ..compat import ( | |
6 | compat_urllib_parse_unquote, | |
7 | compat_str | |
8 | ) | |
9 | ||
10 | ||
11 | class MediaKlikkIE(InfoExtractor): | |
12 | _VALID_URL = r'''(?x)https?://(?:www\.)? | |
13 | (?:mediaklikk|m4sport|hirado|petofilive)\.hu/.*?(?:videok?|cikk)/ | |
14 | (?:(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/)? | |
15 | (?P<id>[^/#?_]+)''' | |
16 | ||
17 | _TESTS = [{ | |
18 | # mediaklikk. date in html. | |
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' | |
26 | } | |
27 | }, { | |
28 | # m4sport | |
29 | 'url': 'https://m4sport.hu/video/2021/08/30/gyemant-liga-parizs/', | |
30 | 'info_dict': { | |
31 | 'id': '4754999', | |
32 | 'title': 'Gyémánt Liga, Párizs', | |
33 | 'ext': 'mp4', | |
34 | 'upload_date': '20210830', | |
35 | 'thumbnail': 'http://m4sport.hu/wp-content/uploads/sites/4/2021/08/vlcsnap-2021-08-30-18h21m20s10-1024x576.jpg' | |
36 | } | |
37 | }, { | |
38 | # m4sport with *video/ url and no date | |
39 | 'url': 'https://m4sport.hu/bl-video/real-madrid-chelsea-1-1/', | |
40 | 'info_dict': { | |
41 | 'id': '4492099', | |
42 | 'title': 'Real Madrid - Chelsea 1-1', | |
43 | 'ext': 'mp4', | |
44 | 'thumbnail': 'http://m4sport.hu/wp-content/uploads/sites/4/2021/04/Sequence-01.Still001-1024x576.png' | |
45 | } | |
46 | }, { | |
47 | # hirado | |
48 | 'url': 'https://hirado.hu/videok/felteteleket-szabott-a-fovaros/', | |
49 | 'info_dict': { | |
50 | 'id': '4760120', | |
51 | 'title': 'Feltételeket szabott a főváros', | |
52 | 'ext': 'mp4', | |
53 | 'thumbnail': 'http://hirado.hu/wp-content/uploads/sites/4/2021/09/vlcsnap-2021-09-01-20h20m37s165.jpg' | |
54 | } | |
55 | }, { | |
56 | # petofilive | |
57 | 'url': 'https://petofilive.hu/video/2021/06/07/tha-shudras-az-akusztikban/', | |
58 | 'info_dict': { | |
59 | 'id': '4571948', | |
60 | 'title': 'Tha Shudras az Akusztikban', | |
61 | 'ext': 'mp4', | |
62 | 'upload_date': '20210607', | |
63 | 'thumbnail': 'http://petofilive.hu/wp-content/uploads/sites/4/2021/06/vlcsnap-2021-06-07-22h14m23s915-1024x576.jpg' | |
64 | } | |
65 | }] | |
66 | ||
67 | def _real_extract(self, url): | |
68 | mobj = self._match_valid_url(url) | |
69 | display_id = mobj.group('id') | |
70 | webpage = self._download_webpage(url, display_id) | |
71 | ||
72 | player_data_str = self._html_search_regex( | |
73 | r'mtva_player_manager\.player\(document.getElementById\(.*\),\s?(\{.*\}).*\);', webpage, 'player data') | |
74 | player_data = self._parse_json(player_data_str, display_id, compat_urllib_parse_unquote) | |
75 | video_id = compat_str(player_data['contentId']) | |
76 | title = player_data.get('title') or self._og_search_title(webpage, fatal=False) or \ | |
77 | self._html_search_regex(r'<h\d+\b[^>]+\bclass="article_title">([^<]+)<', webpage, 'title') | |
78 | ||
79 | upload_date = unified_strdate( | |
80 | '%s-%s-%s' % (mobj.group('year'), mobj.group('month'), mobj.group('day'))) | |
81 | if not upload_date: | |
82 | upload_date = unified_strdate(self._html_search_regex( | |
83 | r'<p+\b[^>]+\bclass="article_date">([^<]+)<', webpage, 'upload date', default=None)) | |
84 | ||
85 | player_data['video'] = player_data.pop('token') | |
86 | player_page = self._download_webpage('https://player.mediaklikk.hu/playernew/player.php', video_id, query=player_data) | |
87 | playlist_url = self._proto_relative_url(compat_urllib_parse_unquote( | |
88 | self._html_search_regex(r'\"file\":\s*\"(\\?/\\?/.*playlist\.m3u8)\"', player_page, 'playlist_url')).replace('\\/', '/')) | |
89 | ||
90 | formats = self._extract_wowza_formats( | |
91 | playlist_url, video_id, skip_protocols=['f4m', 'smil', 'dash']) | |
92 | ||
93 | return { | |
94 | 'id': video_id, | |
95 | 'title': title, | |
96 | 'display_id': display_id, | |
97 | 'formats': formats, | |
98 | 'upload_date': upload_date, | |
99 | 'thumbnail': player_data.get('bgImage') or self._og_search_thumbnail(webpage) | |
100 | } |