]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/eagleplatform.py
688dfc2f7f34d15e712481351a6073987325add5
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': '0b7994faa2bd5c0f69a3db6db28d078d',
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': '6c2ebeab03b739597ce8d86339d5a905',
43 'title': "'O Sole Mio",
44 'thumbnail': 're:^https?://.*\.jpg$',
48 'skip': 'Georestricted',
51 def _handle_error(self
, response
):
52 status
= int_or_none(response
.get('status', 200))
54 raise ExtractorError(' '.join(response
['errors']), expected
=True)
56 def _download_json(self
, url_or_request
, video_id
, note
='Downloading JSON metadata'):
57 response
= super(EaglePlatformIE
, self
)._download
_json
(url_or_request
, video_id
, note
)
58 self
._handle
_error
(response
)
61 def _real_extract(self
, url
):
62 mobj
= re
.match(self
._VALID
_URL
, url
)
63 host
, video_id
= mobj
.group('custom_host') or mobj
.group('host'), mobj
.group('id')
65 player_data
= self
._download
_json
(
66 'http://%s/api/player_data?id=%s' % (host
, video_id
), video_id
)
68 media
= player_data
['data']['playlist']['viewports'][0]['medialist'][0]
70 title
= media
['title']
71 description
= media
.get('description')
72 thumbnail
= media
.get('snapshot')
73 duration
= int_or_none(media
.get('duration'))
74 view_count
= int_or_none(media
.get('views'))
76 age_restriction
= media
.get('age_restriction')
79 age_limit
= 0 if age_restriction
== 'allow_all' else 18
81 m3u8_data
= self
._download
_json
(
82 media
['sources']['secure_m3u8']['auto'],
83 video_id
, 'Downloading m3u8 JSON')
85 formats
= self
._extract
_m
3u8_formats
(
86 m3u8_data
['data'][0], video_id
,
87 'mp4', entry_protocol
='m3u8_native')
88 self
._sort
_formats
(formats
)
93 'description': description
,
94 'thumbnail': thumbnail
,
96 'view_count': view_count
,
97 'age_limit': age_limit
,