]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/internazionale.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / internazionale.py
CommitLineData
1ae0f0a2 1from .common import InfoExtractor
640788f6 2from ..utils import unified_timestamp
1ae0f0a2
LT
3
4
5class InternazionaleIE(InfoExtractor):
640788f6 6 _VALID_URL = r'https?://(?:www\.)?internazionale\.it/video/(?:[^/]+/)*(?P<id>[^/?#&]+)'
73f3bdbe 7 _TESTS = [{
1ae0f0a2 8 'url': 'https://www.internazionale.it/video/2015/02/19/richard-linklater-racconta-una-scena-di-boyhood',
640788f6 9 'md5': '3e39d32b66882c1218e305acbf8348ca',
1ae0f0a2
LT
10 'info_dict': {
11 'id': '265968',
640788f6 12 'display_id': 'richard-linklater-racconta-una-scena-di-boyhood',
1ae0f0a2 13 'ext': 'mp4',
1ae0f0a2 14 'title': 'Richard Linklater racconta una scena di Boyhood',
640788f6
S
15 'description': 'md5:efb7e5bbfb1a54ae2ed5a4a015f0e665',
16 'timestamp': 1424354635,
17 'upload_date': '20150219',
1ae0f0a2 18 'thumbnail': r're:^https?://.*\.jpg$',
640788f6 19 },
73f3bdbe
LT
20 }, {
21 'url': 'https://www.internazionale.it/video/2018/08/29/telefono-stare-con-noi-stessi',
22 'md5': '9db8663704cab73eb972d1cee0082c79',
23 'info_dict': {
24 'id': '761344',
25 'display_id': 'telefono-stare-con-noi-stessi',
26 'ext': 'mp4',
27 'title': 'Usiamo il telefono per evitare di stare con noi stessi',
28 'description': 'md5:75ccfb0d6bcefc6e7428c68b4aa1fe44',
29 'timestamp': 1535528954,
30 'upload_date': '20180829',
31 'thumbnail': r're:^https?://.*\.jpg$',
32 },
73f3bdbe 33 }]
1ae0f0a2
LT
34
35 def _real_extract(self, url):
640788f6 36 display_id = self._match_id(url)
1ae0f0a2 37
640788f6 38 webpage = self._download_webpage(url, display_id)
1ae0f0a2 39
640788f6 40 DATA_RE = r'data-%s=(["\'])(?P<value>(?:(?!\1).)+)\1'
1ae0f0a2 41
640788f6
S
42 title = self._search_regex(
43 DATA_RE % 'video-title', webpage, 'title', default=None,
44 group='value') or self._og_search_title(webpage)
1ae0f0a2 45
640788f6
S
46 video_id = self._search_regex(
47 DATA_RE % 'job-id', webpage, 'video id', group='value')
48 video_path = self._search_regex(
49 DATA_RE % 'video-path', webpage, 'video path', group='value')
73f3bdbe
LT
50 video_available_abroad = self._search_regex(
51 DATA_RE % 'video-available_abroad', webpage,
52 'video available aboard', default='1', group='value')
53 video_available_abroad = video_available_abroad == '1'
1ae0f0a2 54
73f3bdbe
LT
55 video_base = 'https://video%s.internazionale.it/%s/%s.' % \
56 ('' if video_available_abroad else '-ita', video_path, video_id)
640788f6
S
57
58 formats = self._extract_m3u8_formats(
59 video_base + 'm3u8', display_id, 'mp4',
60 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
61 formats.extend(self._extract_mpd_formats(
62 video_base + 'mpd', display_id, mpd_id='dash', fatal=False))
1ae0f0a2 63
640788f6
S
64 timestamp = unified_timestamp(self._html_search_meta(
65 'article:published_time', webpage, 'timestamp'))
66
1ae0f0a2 67 return {
640788f6
S
68 'id': video_id,
69 'display_id': display_id,
70 'title': title,
1ae0f0a2
LT
71 'thumbnail': self._og_search_thumbnail(webpage),
72 'description': self._og_search_description(webpage),
640788f6 73 'timestamp': timestamp,
1ae0f0a2
LT
74 'formats': formats,
75 }