]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/ora.py
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_urlparse
8 get_element_by_attribute
,
14 class OraTVIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?ora\.tv/([^/]+/)*(?P<id>[^/\?#]+)'
17 'url': 'https://www.ora.tv/larrykingnow/2015/12/16/vine-youtube-stars-zach-king-king-bach-on-their-viral-videos-0_36jupg6090pq',
18 'md5': 'fa33717591c631ec93b04b0e330df786',
22 'title': 'Vine & YouTube Stars Zach King & King Bach On Their Viral Videos!',
23 'description': 'md5:ebbc5b1424dd5dba7be7538148287ac1',
28 def _real_extract(self
, url
):
29 display_id
= self
._match
_id
(url
)
30 webpage
= self
._download
_webpage
(url
, display_id
)
32 video_data
= self
._search
_regex
(
33 r
'"current"\s*:\s*({[^}]+?})', webpage
, 'current video')
34 m3u8_url
= self
._search
_regex
(
35 r
'"hls_stream"\s*:\s*"([^"]+)', video_data
, 'm3u8 url', None)
37 formats
= self
._extract
_m
3u8_formats
(
38 m3u8_url
, display_id
, 'mp4', 'm3u8_native',
39 m3u8_id
='hls', fatal
=False)
40 # simular to GameSpotIE
41 m3u8_path
= compat_urlparse
.urlparse(m3u8_url
).path
42 QUALITIES_RE
= r
'((,[a-z]+\d+)+,?)'
43 available_qualities
= self
._search
_regex
(
44 QUALITIES_RE
, m3u8_path
, 'qualities').strip(',').split(',')
45 http_path
= m3u8_path
[1:].split('/', 1)[1]
46 http_template
= re
.sub(QUALITIES_RE
, r
'%s', http_path
)
47 http_template
= http_template
.replace('.csmil/master.m3u8', '')
48 http_template
= compat_urlparse
.urljoin(
49 'http://videocdn-pmd.ora.tv/', http_template
)
50 preference
= qualities(
51 ['mobile400', 'basic400', 'basic600', 'sd900', 'sd1200', 'sd1500', 'hd720', 'hd1080'])
52 for q
in available_qualities
:
54 'url': http_template
% q
,
56 'preference': preference(q
),
58 self
._sort
_formats
(formats
)
60 return self
.url_result(self
._search
_regex
(
61 r
'"youtube_id"\s*:\s*"([^"]+)', webpage
, 'youtube id'), 'Youtube')
64 'id': self
._search
_regex
(
65 r
'"video_id"\s*:\s*(\d+)', video_data
, 'video id'),
66 'display_id': display_id
,
67 'title': unescapeHTML(self
._og
_search
_title
(webpage
)),
68 'description': get_element_by_attribute(
69 'class', 'video_txt_decription', webpage
),
70 'thumbnail': self
._proto
_relative
_url
(self
._search
_regex
(
71 r
'"thumb"\s*:\s*"([^"]+)', video_data
, 'thumbnail', None)),
72 'duration': int(self
._search
_regex
(
73 r
'"duration"\s*:\s*(\d+)', video_data
, 'duration')),