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