[9c9media] extract mpd formats and subtitles
This commit is contained in:
parent
8882840ec5
commit
c9e12a618c
|
@ -11,10 +11,10 @@ class CTVNewsIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:.+?\.)?ctvnews\.ca/(?:video\?(?:clip|playlist|bin)Id=|.*?)(?P<id>[0-9.]+)'
|
_VALID_URL = r'https?://(?:.+?\.)?ctvnews\.ca/(?:video\?(?:clip|playlist|bin)Id=|.*?)(?P<id>[0-9.]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.ctvnews.ca/video?clipId=901995',
|
'url': 'http://www.ctvnews.ca/video?clipId=901995',
|
||||||
'md5': '10deb320dc0ccb8d01d34d12fc2ea672',
|
'md5': '9b8624ba66351a23e0b6e1391971f9af',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '901995',
|
'id': '901995',
|
||||||
'ext': 'mp4',
|
'ext': 'flv',
|
||||||
'title': 'Extended: \'That person cannot be me\' Johnson says',
|
'title': 'Extended: \'That person cannot be me\' Johnson says',
|
||||||
'description': 'md5:958dd3b4f5bbbf0ed4d045c790d89285',
|
'description': 'md5:958dd3b4f5bbbf0ed4d045c790d89285',
|
||||||
'timestamp': 1467286284,
|
'timestamp': 1467286284,
|
||||||
|
|
|
@ -718,10 +718,7 @@ from .nick import (
|
||||||
NickRuIE,
|
NickRuIE,
|
||||||
)
|
)
|
||||||
from .niconico import NiconicoIE, NiconicoPlaylistIE
|
from .niconico import NiconicoIE, NiconicoPlaylistIE
|
||||||
from .ninecninemedia import (
|
from .ninecninemedia import NineCNineMediaIE
|
||||||
NineCNineMediaStackIE,
|
|
||||||
NineCNineMediaIE,
|
|
||||||
)
|
|
||||||
from .ninegag import NineGagIE
|
from .ninegag import NineGagIE
|
||||||
from .ninenow import NineNowIE
|
from .ninenow import NineNowIE
|
||||||
from .nintendo import NintendoIE
|
from .nintendo import NintendoIE
|
||||||
|
|
|
@ -13,38 +13,11 @@ from ..utils import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class NineCNineMediaBaseIE(InfoExtractor):
|
class NineCNineMediaIE(InfoExtractor):
|
||||||
_API_BASE_TEMPLATE = 'http://capi.9c9media.com/destinations/%s/platforms/desktop/contents/%s/'
|
|
||||||
|
|
||||||
|
|
||||||
class NineCNineMediaStackIE(NineCNineMediaBaseIE):
|
|
||||||
IE_NAME = '9c9media:stack'
|
|
||||||
_GEO_COUNTRIES = ['CA']
|
|
||||||
_VALID_URL = r'9c9media:stack:(?P<destination_code>[^:]+):(?P<content_id>\d+):(?P<content_package>\d+):(?P<id>\d+)'
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
|
||||||
destination_code, content_id, package_id, stack_id = re.match(self._VALID_URL, url).groups()
|
|
||||||
stack_base_url_template = self._API_BASE_TEMPLATE + 'contentpackages/%s/stacks/%s/manifest.'
|
|
||||||
stack_base_url = stack_base_url_template % (destination_code, content_id, package_id, stack_id)
|
|
||||||
|
|
||||||
formats = []
|
|
||||||
formats.extend(self._extract_m3u8_formats(
|
|
||||||
stack_base_url + 'm3u8', stack_id, 'mp4',
|
|
||||||
'm3u8_native', m3u8_id='hls', fatal=False))
|
|
||||||
formats.extend(self._extract_f4m_formats(
|
|
||||||
stack_base_url + 'f4m', stack_id,
|
|
||||||
f4m_id='hds', fatal=False))
|
|
||||||
self._sort_formats(formats)
|
|
||||||
|
|
||||||
return {
|
|
||||||
'id': stack_id,
|
|
||||||
'formats': formats,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class NineCNineMediaIE(NineCNineMediaBaseIE):
|
|
||||||
IE_NAME = '9c9media'
|
IE_NAME = '9c9media'
|
||||||
|
_GEO_COUNTRIES = ['CA']
|
||||||
_VALID_URL = r'9c9media:(?P<destination_code>[^:]+):(?P<id>\d+)'
|
_VALID_URL = r'9c9media:(?P<destination_code>[^:]+):(?P<id>\d+)'
|
||||||
|
_API_BASE_TEMPLATE = 'http://capi.9c9media.com/destinations/%s/platforms/desktop/contents/%s/'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
destination_code, content_id = re.match(self._VALID_URL, url).groups()
|
destination_code, content_id = re.match(self._VALID_URL, url).groups()
|
||||||
|
@ -58,13 +31,26 @@ class NineCNineMediaIE(NineCNineMediaBaseIE):
|
||||||
content_package = content['ContentPackages'][0]
|
content_package = content['ContentPackages'][0]
|
||||||
package_id = content_package['Id']
|
package_id = content_package['Id']
|
||||||
content_package_url = api_base_url + 'contentpackages/%s/' % package_id
|
content_package_url = api_base_url + 'contentpackages/%s/' % package_id
|
||||||
content_package = self._download_json(content_package_url, content_id)
|
content_package = self._download_json(
|
||||||
|
content_package_url, content_id, query={
|
||||||
|
'$include': '[HasClosedCaptions]',
|
||||||
|
})
|
||||||
|
|
||||||
if content_package.get('Constraints', {}).get('Security', {}).get('Type') == 'adobe-drm':
|
if content_package.get('Constraints', {}).get('Security', {}).get('Type'):
|
||||||
raise ExtractorError('This video is DRM protected.', expected=True)
|
raise ExtractorError('This video is DRM protected.', expected=True)
|
||||||
|
|
||||||
stacks = self._download_json(content_package_url + 'stacks/', package_id)['Items']
|
manifest_base_url = content_package_url + 'manifest.'
|
||||||
multistacks = len(stacks) > 1
|
formats = []
|
||||||
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
manifest_base_url + 'm3u8', content_id, 'mp4',
|
||||||
|
'm3u8_native', m3u8_id='hls', fatal=False))
|
||||||
|
formats.extend(self._extract_f4m_formats(
|
||||||
|
manifest_base_url + 'f4m', content_id,
|
||||||
|
f4m_id='hds', fatal=False))
|
||||||
|
formats.extend(self._extract_mpd_formats(
|
||||||
|
manifest_base_url + 'mpd', content_id,
|
||||||
|
mpd_id='dash', fatal=False))
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
for image in content.get('Images', []):
|
for image in content.get('Images', []):
|
||||||
|
@ -85,10 +71,12 @@ class NineCNineMediaIE(NineCNineMediaBaseIE):
|
||||||
continue
|
continue
|
||||||
container.append(e_name)
|
container.append(e_name)
|
||||||
|
|
||||||
description = content.get('Desc') or content.get('ShortDesc')
|
|
||||||
season = content.get('Season', {})
|
season = content.get('Season', {})
|
||||||
base_info = {
|
|
||||||
'description': description,
|
info = {
|
||||||
|
'id': content_id,
|
||||||
|
'title': title,
|
||||||
|
'description': content.get('Desc') or content.get('ShortDesc'),
|
||||||
'timestamp': parse_iso8601(content.get('BroadcastDateTime')),
|
'timestamp': parse_iso8601(content.get('BroadcastDateTime')),
|
||||||
'episode_number': int_or_none(content.get('Episode')),
|
'episode_number': int_or_none(content.get('Episode')),
|
||||||
'season': season.get('Name'),
|
'season': season.get('Name'),
|
||||||
|
@ -97,26 +85,19 @@ class NineCNineMediaIE(NineCNineMediaBaseIE):
|
||||||
'series': content.get('Media', {}).get('Name'),
|
'series': content.get('Media', {}).get('Name'),
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
'categories': categories,
|
'categories': categories,
|
||||||
|
'duration': float_or_none(content_package.get('Duration')),
|
||||||
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
||||||
entries = []
|
if content_package.get('HasClosedCaptions'):
|
||||||
for stack in stacks:
|
info['subtitles'] = {
|
||||||
stack_id = compat_str(stack['Id'])
|
'en': [{
|
||||||
entry = {
|
'url': manifest_base_url + 'vtt',
|
||||||
'_type': 'url_transparent',
|
'ext': 'vtt',
|
||||||
'url': '9c9media:stack:%s:%s:%s:%s' % (destination_code, content_id, package_id, stack_id),
|
}, {
|
||||||
'id': stack_id,
|
'url': manifest_base_url + 'srt',
|
||||||
'title': '%s_part%s' % (title, stack['Name']) if multistacks else title,
|
'ext': 'srt',
|
||||||
'duration': float_or_none(stack.get('Duration')),
|
}]
|
||||||
'ie_key': 'NineCNineMediaStack',
|
|
||||||
}
|
}
|
||||||
entry.update(base_info)
|
|
||||||
entries.append(entry)
|
|
||||||
|
|
||||||
return {
|
return info
|
||||||
'_type': 'multi_video',
|
|
||||||
'id': content_id,
|
|
||||||
'title': title,
|
|
||||||
'description': description,
|
|
||||||
'entries': entries,
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class RDSIE(InfoExtractor):
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '604333',
|
'id': '604333',
|
||||||
'display_id': 'fowler-jr-prend-la-direction-de-jacksonville',
|
'display_id': 'fowler-jr-prend-la-direction-de-jacksonville',
|
||||||
'ext': 'mp4',
|
'ext': 'flv',
|
||||||
'title': 'Fowler Jr. prend la direction de Jacksonville',
|
'title': 'Fowler Jr. prend la direction de Jacksonville',
|
||||||
'description': 'Dante Fowler Jr. est le troisième choix du repêchage 2015 de la NFL. ',
|
'description': 'Dante Fowler Jr. est le troisième choix du repêchage 2015 de la NFL. ',
|
||||||
'timestamp': 1430397346,
|
'timestamp': 1430397346,
|
||||||
|
|
Loading…
Reference in New Issue