]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/internazionale.py
debian/control: Remove X-Python3-Version indication.
[youtubedl] / youtube_dl / extractor / internazionale.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import unified_timestamp
6
7
8 class InternazionaleIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?internazionale\.it/video/(?:[^/]+/)*(?P<id>[^/?#&]+)'
10 _TEST = {
11 'url': 'https://www.internazionale.it/video/2015/02/19/richard-linklater-racconta-una-scena-di-boyhood',
12 'md5': '3e39d32b66882c1218e305acbf8348ca',
13 'info_dict': {
14 'id': '265968',
15 'display_id': 'richard-linklater-racconta-una-scena-di-boyhood',
16 'ext': 'mp4',
17 'title': 'Richard Linklater racconta una scena di Boyhood',
18 'description': 'md5:efb7e5bbfb1a54ae2ed5a4a015f0e665',
19 'timestamp': 1424354635,
20 'upload_date': '20150219',
21 'thumbnail': r're:^https?://.*\.jpg$',
22 },
23 'params': {
24 'format': 'bestvideo',
25 },
26 }
27
28 def _real_extract(self, url):
29 display_id = self._match_id(url)
30
31 webpage = self._download_webpage(url, display_id)
32
33 DATA_RE = r'data-%s=(["\'])(?P<value>(?:(?!\1).)+)\1'
34
35 title = self._search_regex(
36 DATA_RE % 'video-title', webpage, 'title', default=None,
37 group='value') or self._og_search_title(webpage)
38
39 video_id = self._search_regex(
40 DATA_RE % 'job-id', webpage, 'video id', group='value')
41 video_path = self._search_regex(
42 DATA_RE % 'video-path', webpage, 'video path', group='value')
43
44 video_base = 'https://video.internazionale.it/%s/%s.' % (video_path, video_id)
45
46 formats = self._extract_m3u8_formats(
47 video_base + 'm3u8', display_id, 'mp4',
48 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
49 formats.extend(self._extract_mpd_formats(
50 video_base + 'mpd', display_id, mpd_id='dash', fatal=False))
51 self._sort_formats(formats)
52
53 timestamp = unified_timestamp(self._html_search_meta(
54 'article:published_time', webpage, 'timestamp'))
55
56 return {
57 'id': video_id,
58 'display_id': display_id,
59 'title': title,
60 'thumbnail': self._og_search_thumbnail(webpage),
61 'description': self._og_search_description(webpage),
62 'timestamp': timestamp,
63 'formats': formats,
64 }