]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/eagleplatform.py
7bbf617d468f9d5295ee2e1123452679a21a7e4b
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
13 class EaglePlatformIE(InfoExtractor
):
16 eagleplatform:(?P<custom_host>[^/]+):|
17 https?://(?P<host>.+?\.media\.eagleplatform\.com)/index/player\?.*\brecord_id=
22 # http://lenta.ru/news/2015/03/06/navalny/
23 'url': 'http://lentaru.media.eagleplatform.com/index/player?player=new&record_id=227304&player_template_id=5201',
24 'md5': '70f5187fb620f2c1d503b3b22fd4efe3',
28 'title': 'Навальный вышел на свободу',
29 'description': 'md5:d97861ac9ae77377f3f20eaf9d04b4f5',
30 'thumbnail': 're:^https?://.*\.jpg$',
36 # http://muz-tv.ru/play/7129/
37 # http://media.clipyou.ru/index/player?record_id=12820&width=730&height=415&autoplay=true
38 'url': 'eagleplatform:media.clipyou.ru:12820',
39 'md5': '90b26344ba442c8e44aa4cf8f301164a',
43 'title': "'O Sole Mio",
44 'thumbnail': 're:^https?://.*\.jpg$',
48 'skip': 'Georestricted',
52 def _handle_error(response
):
53 status
= int_or_none(response
.get('status', 200))
55 raise ExtractorError(' '.join(response
['errors']), expected
=True)
57 def _download_json(self
, url_or_request
, video_id
, note
='Downloading JSON metadata'):
58 response
= super(EaglePlatformIE
, self
)._download
_json
(url_or_request
, video_id
, note
)
59 self
._handle
_error
(response
)
62 def _get_video_url(self
, url_or_request
, video_id
, note
='Downloading JSON metadata'):
63 return self
._download
_json
(url_or_request
, video_id
, note
)['data'][0]
65 def _real_extract(self
, url
):
66 mobj
= re
.match(self
._VALID
_URL
, url
)
67 host
, video_id
= mobj
.group('custom_host') or mobj
.group('host'), mobj
.group('id')
69 player_data
= self
._download
_json
(
70 'http://%s/api/player_data?id=%s' % (host
, video_id
), video_id
)
72 media
= player_data
['data']['playlist']['viewports'][0]['medialist'][0]
74 title
= media
['title']
75 description
= media
.get('description')
76 thumbnail
= self
._proto
_relative
_url
(media
.get('snapshot'), 'http:')
77 duration
= int_or_none(media
.get('duration'))
78 view_count
= int_or_none(media
.get('views'))
80 age_restriction
= media
.get('age_restriction')
83 age_limit
= 0 if age_restriction
== 'allow_all' else 18
85 secure_m3u8
= self
._proto
_relative
_url
(media
['sources']['secure_m3u8']['auto'], 'http:')
87 m3u8_url
= self
._get
_video
_url
(secure_m3u8
, video_id
, 'Downloading m3u8 JSON')
88 formats
= self
._extract
_m
3u8_formats
(
90 'mp4', entry_protocol
='m3u8_native', m3u8_id
='hls')
92 mp4_url
= self
._get
_video
_url
(
93 # Secure mp4 URL is constructed according to Player.prototype.mp4 from
94 # http://lentaru.media.eagleplatform.com/player/player.js
95 re
.sub(r
'm3u8|hlsvod|hls|f4m', 'mp4', secure_m3u8
),
96 video_id
, 'Downloading mp4 JSON')
97 formats
.append({'url': mp4_url
, 'format_id': 'mp4'})
99 self
._sort
_formats
(formats
)
104 'description': description
,
105 'thumbnail': thumbnail
,
106 'duration': duration
,
107 'view_count': view_count
,
108 'age_limit': age_limit
,