]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rudo.py
9a330c1961b75f662caa457fabe231e6aa4bcb8a
[youtubedl] / youtube_dl / extractor / rudo.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .jwplatform import JWPlatformBaseIE
7 from ..utils import (
8 js_to_json,
9 get_element_by_class,
10 unified_strdate,
11 )
12
13
14 class RudoIE(JWPlatformBaseIE):
15 _VALID_URL = r'https?://rudo\.video/vod/(?P<id>[0-9a-zA-Z]+)'
16
17 _TEST = {
18 'url': 'http://rudo.video/vod/oTzw0MGnyG',
19 'md5': '2a03a5b32dd90a04c83b6d391cf7b415',
20 'info_dict': {
21 'id': 'oTzw0MGnyG',
22 'ext': 'mp4',
23 'title': 'Comentario Tomás Mosciatti',
24 'upload_date': '20160617',
25 },
26 }
27
28 @classmethod
29 def _extract_url(self, webpage):
30 mobj = re.search(
31 '<iframe[^>]+src=(?P<q1>[\'"])(?P<url>(?:https?:)?//rudo\.video/vod/[0-9a-zA-Z]+)(?P=q1)',
32 webpage)
33 if mobj:
34 return mobj.group('url')
35
36 def _real_extract(self, url):
37 video_id = self._match_id(url)
38
39 webpage = self._download_webpage(url, video_id, encoding='iso-8859-1')
40
41 jwplayer_data = self._parse_json(self._search_regex(
42 r'(?s)playerInstance\.setup\(({.+?})\)', webpage, 'jwplayer data'), video_id,
43 transform_source=lambda s: js_to_json(re.sub(r'encodeURI\([^)]+\)', '""', s)))
44
45 info_dict = self._parse_jwplayer_data(
46 jwplayer_data, video_id, require_title=False, m3u8_id='hls', mpd_id='dash')
47
48 info_dict.update({
49 'title': self._og_search_title(webpage),
50 'upload_date': unified_strdate(get_element_by_class('date', webpage)),
51 })
52
53 return info_dict