2 from __future__ import unicode_literals
4 from .common import InfoExtractor
15 class TV5MondePlusIE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?tv5mondeplus\.com/toutes-les-videos/[^/]+/(?P<id>[^/?#]+)'
19 'url': 'http://www.tv5mondeplus.com/toutes-les-videos/documentaire/tdah-mon-amour-tele-quebec-tdah-mon-amour-ep001-enfants',
20 'md5': '12130fc199f020673138a83466542ec6',
22 'id': '0a774110-dc60-4037-f769-996439514f1f',
24 'title': 'Tdah, mon amour - Enfants',
25 'description': 'md5:b65f0cc50e46947e62e5d352e9916cc4',
26 'upload_date': '20170401',
27 'timestamp': 1491022860,
32 def _real_extract(self, url):
33 display_id = self._match_id(url)
34 webpage = self._download_webpage(url, display_id)
36 if ">Ce programme n'est malheureusement pas disponible pour votre zone géographique.<" in webpage:
37 self.raise_geo_restricted(countries=['FR'])
39 series = get_element_by_class('video-detail__title', webpage)
40 title = episode = get_element_by_class(
41 'video-detail__subtitle', webpage) or series
42 if series and series != title:
43 title = '%s - %s' % (series, title)
44 vpl_data = extract_attributes(self._search_regex(
45 r'(<[^>]+class="video_player_loader"[^>]+>)',
46 webpage, 'video player loader'))
48 video_files = self._parse_json(
49 vpl_data['data-broadcast'], display_id).get('files', [])
51 for video_file in video_files:
52 v_url = video_file.get('url')
55 video_format = video_file.get('format') or determine_ext(v_url)
56 if video_format == 'm3u8':
57 formats.extend(self._extract_m3u8_formats(
58 v_url, display_id, 'mp4', 'm3u8_native',
59 m3u8_id='hls', fatal=False))
63 'format_id': video_format,
65 self._sort_formats(formats)
68 'id': vpl_data.get('data-guid') or display_id,
69 'display_id': display_id,
71 'description': get_element_by_class('video-detail__description', webpage),
72 'thumbnail': vpl_data.get('data-image'),
73 'duration': int_or_none(vpl_data.get('data-duration')) or parse_duration(self._html_search_meta('duration', webpage)),
74 'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage)),