[eagleplatform] extract mp4 url and fix thumbnail url

This commit is contained in:
remitamine 2015-09-26 15:30:02 +01:00 committed by Sergey M․
parent 95c5e10103
commit 9d632b1b27

View file

@ -21,7 +21,7 @@ class EaglePlatformIE(InfoExtractor):
_TESTS = [{ _TESTS = [{
# http://lenta.ru/news/2015/03/06/navalny/ # http://lenta.ru/news/2015/03/06/navalny/
'url': 'http://lentaru.media.eagleplatform.com/index/player?player=new&record_id=227304&player_template_id=5201', 'url': 'http://lentaru.media.eagleplatform.com/index/player?player=new&record_id=227304&player_template_id=5201',
'md5': '0b7994faa2bd5c0f69a3db6db28d078d', 'md5': '70f5187fb620f2c1d503b3b22fd4efe3',
'info_dict': { 'info_dict': {
'id': '227304', 'id': '227304',
'ext': 'mp4', 'ext': 'mp4',
@ -36,7 +36,7 @@ class EaglePlatformIE(InfoExtractor):
# http://muz-tv.ru/play/7129/ # http://muz-tv.ru/play/7129/
# http://media.clipyou.ru/index/player?record_id=12820&width=730&height=415&autoplay=true # http://media.clipyou.ru/index/player?record_id=12820&width=730&height=415&autoplay=true
'url': 'eagleplatform:media.clipyou.ru:12820', 'url': 'eagleplatform:media.clipyou.ru:12820',
'md5': '6c2ebeab03b739597ce8d86339d5a905', 'md5': '90b26344ba442c8e44aa4cf8f301164a',
'info_dict': { 'info_dict': {
'id': '12820', 'id': '12820',
'ext': 'mp4', 'ext': 'mp4',
@ -53,10 +53,10 @@ def _handle_error(self, response):
if status != 200: if status != 200:
raise ExtractorError(' '.join(response['errors']), expected=True) raise ExtractorError(' '.join(response['errors']), expected=True)
def _download_json(self, url_or_request, video_id, note='Downloading JSON metadata'): def _get_video_url(self, url_or_request, video_id, note='Downloading JSON metadata'):
response = super(EaglePlatformIE, self)._download_json(url_or_request, video_id, note) response = self._download_json(url_or_request, video_id, note)
self._handle_error(response) self._handle_error(response)
return response return response['data'][0]
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
@ -69,7 +69,7 @@ def _real_extract(self, url):
title = media['title'] title = media['title']
description = media.get('description') description = media.get('description')
thumbnail = media.get('snapshot') thumbnail = self._proto_relative_url(media.get('snapshot'))
duration = int_or_none(media.get('duration')) duration = int_or_none(media.get('duration'))
view_count = int_or_none(media.get('views')) view_count = int_or_none(media.get('views'))
@ -78,13 +78,18 @@ def _real_extract(self, url):
if age_restriction: if age_restriction:
age_limit = 0 if age_restriction == 'allow_all' else 18 age_limit = 0 if age_restriction == 'allow_all' else 18
m3u8_data = self._download_json( secure_m3u8 = self._proto_relative_url(media['sources']['secure_m3u8']['auto'])
self._proto_relative_url(media['sources']['secure_m3u8']['auto'], 'http:'),
video_id, 'Downloading m3u8 JSON')
m3u8_url = self._get_video_url(secure_m3u8, video_id, 'Downloading m3u8 JSON')
formats = self._extract_m3u8_formats( formats = self._extract_m3u8_formats(
m3u8_data['data'][0], video_id, m3u8_url, video_id,
'mp4', entry_protocol='m3u8_native') 'mp4', entry_protocol='m3u8_native')
mp4_url = self._get_video_url(
secure_m3u8.replace("m3u8", "mp4").replace("hlsvod", "mp4").replace("hls", "mp4"),
video_id, 'Downloading mp4 JSON')
formats.append({'url': mp4_url, 'format_id': 'mp4'})
self._sort_formats(formats) self._sort_formats(formats)
return { return {