]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hbo.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class HBOIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?hbo\.com/video/video\.html\?.*vid=(?P<id>[0-9]+)'
18 'url': 'http://www.hbo.com/video/video.html?autoplay=true&g=u&vid=1437839',
19 'md5': '1c33253f0c7782142c993c0ba62a8753',
23 'title': 'Ep. 64 Clip: Encryption',
53 def _real_extract(self
, url
):
54 video_id
= self
._match
_id
(url
)
55 video_data
= self
._download
_xml
(
56 'http://render.lv3.hbo.com/data/content/global/videos/data/%s.xml' % video_id
, video_id
)
57 title
= xpath_text(video_data
, 'title', 'title', True)
60 for source
in xpath_element(video_data
, 'videos', 'sources', True):
61 if source
.tag
== 'size':
62 path
= xpath_text(source
, './/path')
65 width
= source
.attrib
.get('width')
66 format_info
= self
._FORMATS
_INFO
.get(width
, {})
67 height
= format_info
.get('height')
70 'format_id': 'http%s' % ('-%dp' % height
if height
else ''),
71 'width': format_info
.get('width'),
74 rtmp
= re
.search(r
'^(?P<url>rtmpe?://[^/]+/(?P<app>.+))/(?P<playpath>mp4:.+)$', path
)
77 'url': rtmp
.group('url'),
78 'play_path': rtmp
.group('playpath'),
79 'app': rtmp
.group('app'),
81 'format_id': fmt
['format_id'].replace('http', 'rtmp'),
85 video_url
= source
.text
88 if source
.tag
== 'tarball':
89 formats
.extend(self
._extract
_m
3u8_formats
(
90 video_url
.replace('.tar', '/base_index_w8.m3u8'),
91 video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls', fatal
=False))
93 format_info
= self
._FORMATS
_INFO
.get(source
.tag
, {})
95 'format_id': 'http-%s' % source
.tag
,
97 'width': format_info
.get('width'),
98 'height': format_info
.get('height'),
100 self
._sort
_formats
(formats
, ('width', 'height', 'tbr', 'format_id'))
103 card_sizes
= xpath_element(video_data
, 'titleCardSizes')
104 if card_sizes
is not None:
105 for size
in card_sizes
:
106 path
= xpath_text(size
, 'path')
109 width
= int_or_none(size
.get('width'))
119 'duration': parse_duration(xpath_element(video_data
, 'duration/tv14')),
121 'thumbnails': thumbnails
,