]>
Commit | Line | Data |
---|---|---|
7d540621 S |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..utils import ( | |
5 | ExtractorError, | |
6 | int_or_none, | |
7 | xpath_attr, | |
8 | xpath_text, | |
9 | xpath_element, | |
10 | unescapeHTML, | |
11 | unified_timestamp, | |
12 | ) | |
13 | ||
14 | ||
15 | class SpringboardPlatformIE(InfoExtractor): | |
16 | _VALID_URL = r'''(?x) | |
17 | https?:// | |
18 | cms\.springboardplatform\.com/ | |
19 | (?: | |
20 | (?:previews|embed_iframe)/(?P<index>\d+)/video/(?P<id>\d+)| | |
21 | xml_feeds_advanced/index/(?P<index_2>\d+)/rss3/(?P<id_2>\d+) | |
22 | ) | |
23 | ''' | |
bfd973ec | 24 | _EMBED_REGEX = [r'<iframe\b[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//cms\.springboardplatform\.com/embed_iframe/\d+/video/\d+.*?)\1'] |
7d540621 S |
25 | _TESTS = [{ |
26 | 'url': 'http://cms.springboardplatform.com/previews/159/video/981017/0/0/1', | |
27 | 'md5': '5c3cb7b5c55740d482561099e920f192', | |
28 | 'info_dict': { | |
29 | 'id': '981017', | |
30 | 'ext': 'mp4', | |
31 | 'title': 'Redman "BUD like YOU" "Usher Good Kisser" REMIX', | |
32 | 'description': 'Redman "BUD like YOU" "Usher Good Kisser" REMIX', | |
33 | 'thumbnail': r're:^https?://.*\.jpg$', | |
34 | 'timestamp': 1409132328, | |
35 | 'upload_date': '20140827', | |
36 | 'duration': 193, | |
37 | }, | |
38 | }, { | |
39 | 'url': 'http://cms.springboardplatform.com/embed_iframe/159/video/981017/rab007/rapbasement.com/1/1', | |
40 | 'only_matching': True, | |
41 | }, { | |
42 | 'url': 'http://cms.springboardplatform.com/embed_iframe/20/video/1731611/ki055/kidzworld.com/10', | |
43 | 'only_matching': True, | |
44 | }, { | |
45 | 'url': 'http://cms.springboardplatform.com/xml_feeds_advanced/index/159/rss3/981017/0/0/1/', | |
46 | 'only_matching': True, | |
47 | }] | |
48 | ||
7d540621 | 49 | def _real_extract(self, url): |
5ad28e7f | 50 | mobj = self._match_valid_url(url) |
7d540621 S |
51 | video_id = mobj.group('id') or mobj.group('id_2') |
52 | index = mobj.group('index') or mobj.group('index_2') | |
53 | ||
54 | video = self._download_xml( | |
55 | 'http://cms.springboardplatform.com/xml_feeds_advanced/index/%s/rss3/%s' | |
56 | % (index, video_id), video_id) | |
57 | ||
58 | item = xpath_element(video, './/item', 'item', fatal=True) | |
59 | ||
60 | content = xpath_element( | |
61 | item, './{http://search.yahoo.com/mrss/}content', 'content', | |
62 | fatal=True) | |
63 | title = unescapeHTML(xpath_text(item, './title', 'title', fatal=True)) | |
64 | ||
65 | video_url = content.attrib['url'] | |
66 | ||
67 | if 'error_video.mp4' in video_url: | |
68 | raise ExtractorError( | |
69 | 'Video %s no longer exists' % video_id, expected=True) | |
70 | ||
71 | duration = int_or_none(content.get('duration')) | |
72 | tbr = int_or_none(content.get('bitrate')) | |
73 | filesize = int_or_none(content.get('fileSize')) | |
74 | width = int_or_none(content.get('width')) | |
75 | height = int_or_none(content.get('height')) | |
76 | ||
77 | description = unescapeHTML(xpath_text( | |
78 | item, './description', 'description')) | |
79 | thumbnail = xpath_attr( | |
80 | item, './{http://search.yahoo.com/mrss/}thumbnail', 'url', | |
81 | 'thumbnail') | |
82 | ||
83 | timestamp = unified_timestamp(xpath_text( | |
84 | item, './{http://cms.springboardplatform.com/namespaces.html}created', | |
85 | 'timestamp')) | |
86 | ||
87 | formats = [{ | |
88 | 'url': video_url, | |
89 | 'format_id': 'http', | |
90 | 'tbr': tbr, | |
91 | 'filesize': filesize, | |
92 | 'width': width, | |
93 | 'height': height, | |
94 | }] | |
95 | ||
96 | m3u8_format = formats[0].copy() | |
97 | m3u8_format.update({ | |
98 | 'url': re.sub(r'(https?://)cdn\.', r'\1hls.', video_url) + '.m3u8', | |
99 | 'ext': 'mp4', | |
100 | 'format_id': 'hls', | |
101 | 'protocol': 'm3u8_native', | |
102 | }) | |
103 | formats.append(m3u8_format) | |
104 | ||
7d540621 S |
105 | return { |
106 | 'id': video_id, | |
107 | 'title': title, | |
108 | 'description': description, | |
109 | 'thumbnail': thumbnail, | |
110 | 'timestamp': timestamp, | |
111 | 'duration': duration, | |
112 | 'formats': formats, | |
113 | } |