[srgssr] update tests

This commit is contained in:
remitamine 2015-12-29 11:36:04 +01:00
parent b19ad2fb53
commit 422f7c112c
2 changed files with 32 additions and 36 deletions

View file

@ -28,7 +28,7 @@ class RTSIE(SRGSSRIE):
'info_dict': { 'info_dict': {
'id': '3449373', 'id': '3449373',
'display_id': 'les-enfants-terribles', 'display_id': 'les-enfants-terribles',
'ext': 'flv', 'ext': 'mp4',
'duration': 1488, 'duration': 1488,
'title': 'Les Enfants Terribles', 'title': 'Les Enfants Terribles',
'description': 'France Pommier et sa soeur Luce Feral, les deux filles de ce groupe de 5.', 'description': 'France Pommier et sa soeur Luce Feral, les deux filles de ce groupe de 5.',
@ -38,6 +38,10 @@ class RTSIE(SRGSSRIE):
'thumbnail': 're:^https?://.*\.image', 'thumbnail': 're:^https?://.*\.image',
'view_count': int, 'view_count': int,
}, },
'params': {
# m3u8 download
'skip_download': True,
}
}, },
{ {
'url': 'http://www.rts.ch/emissions/passe-moi-les-jumelles/5624067-entre-ciel-et-mer.html', 'url': 'http://www.rts.ch/emissions/passe-moi-les-jumelles/5624067-entre-ciel-et-mer.html',
@ -45,7 +49,7 @@ class RTSIE(SRGSSRIE):
'info_dict': { 'info_dict': {
'id': '5742494', 'id': '5742494',
'display_id': '5742494', 'display_id': '5742494',
'ext': 'flv', 'ext': 'mp4',
'duration': 3720, 'duration': 3720,
'title': 'Les yeux dans les cieux - Mon homard au Canada', 'title': 'Les yeux dans les cieux - Mon homard au Canada',
'description': 'md5:d22ee46f5cc5bac0912e5a0c6d44a9f7', 'description': 'md5:d22ee46f5cc5bac0912e5a0c6d44a9f7',
@ -55,6 +59,10 @@ class RTSIE(SRGSSRIE):
'thumbnail': 're:^https?://.*\.image', 'thumbnail': 're:^https?://.*\.image',
'view_count': int, 'view_count': int,
}, },
'params': {
# m3u8 download
'skip_download': True,
}
}, },
{ {
'url': 'http://www.rts.ch/video/sport/hockey/5745975-1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski.html', 'url': 'http://www.rts.ch/video/sport/hockey/5745975-1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski.html',
@ -80,7 +88,7 @@ class RTSIE(SRGSSRIE):
'info_dict': { 'info_dict': {
'id': '5745356', 'id': '5745356',
'display_id': 'londres-cachee-par-un-epais-smog', 'display_id': 'londres-cachee-par-un-epais-smog',
'ext': 'flv', 'ext': 'mp4',
'duration': 33, 'duration': 33,
'title': 'Londres cachée par un épais smog', 'title': 'Londres cachée par un épais smog',
'description': 'Un important voile de smog recouvre Londres depuis mercredi, provoqué par la pollution et du sable du Sahara.', 'description': 'Un important voile de smog recouvre Londres depuis mercredi, provoqué par la pollution et du sable du Sahara.',
@ -90,6 +98,10 @@ class RTSIE(SRGSSRIE):
'thumbnail': 're:^https?://.*\.image', 'thumbnail': 're:^https?://.*\.image',
'view_count': int, 'view_count': int,
}, },
'params': {
# m3u8 download
'skip_download': True,
}
}, },
{ {
'url': 'http://www.rts.ch/audio/couleur3/programmes/la-belle-video-de-stephane-laurenceau/5706148-urban-hippie-de-damien-krisl-03-04-2014.html', 'url': 'http://www.rts.ch/audio/couleur3/programmes/la-belle-video-de-stephane-laurenceau/5706148-urban-hippie-de-damien-krisl-03-04-2014.html',
@ -180,16 +192,12 @@ class RTSIE(SRGSSRIE):
auth_params = xpath_text(token, './/authparams', 'auth params') auth_params = xpath_text(token, './/authparams', 'auth params')
if not auth_params: if not auth_params:
continue continue
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
'%s?%s&hdcore=3.4.0&plugin=aasp-3.4.0.132.66' % (format_url, auth_params), '%s?%s&hdcore=3.4.0&plugin=aasp-3.4.0.132.66' % (format_url, auth_params),
media_id, f4m_id=format_id, fatal=False) media_id, f4m_id=format_id, fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
elif format_url.endswith('.m3u8'): elif format_url.endswith('.m3u8'):
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
format_url, media_id, 'mp4', m3u8_id=format_id, fatal=False) format_url, media_id, 'mp4', m3u8_id=format_id, fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
formats.append({ formats.append({
'format_id': format_id, 'format_id': format_id,

View file

@ -47,31 +47,24 @@ class SRGSSRIE(InfoExtractor):
created_date = media_data.get('createdDate') or metadata.get('createdDate') created_date = media_data.get('createdDate') or metadata.get('createdDate')
timestamp = parse_iso8601(created_date) timestamp = parse_iso8601(created_date)
thumbnails = [] thumbnails = [{
if 'Image' in media_data:
for image in media_data['Image']['ImageRepresentations']['ImageRepresentation']:
thumbnails.append({
'id': image.get('id'), 'id': image.get('id'),
'url': image['url'], 'url': image['url'],
}) } for image in media_data.get('Image', {}).get('ImageRepresentations', {}).get('ImageRepresentation', [])]
preference = qualities(['LQ', 'MQ', 'SD', 'HQ', 'HD']) preference = qualities(['LQ', 'MQ', 'SD', 'HQ', 'HD'])
formats = [] formats = []
for source in media_data['Playlists']['Playlist']: for source in media_data.get('Playlists', {}).get('Playlist', []) + media_data.get('Downloads', {}).get('Download', []):
assets = {}
protocol = source.get('@protocol') protocol = source.get('@protocol')
if protocol in ('HTTP-HDS', 'HTTP-HLS'): if protocol in ('HTTP-HDS', 'HTTP-HLS'):
assets = {}
for quality in source['url']: for quality in source['url']:
assets[quality['@quality']] = quality['text'] assets[quality['@quality']] = quality['text']
asset_url = assets.get('HD') or assets.get('HQ') or assets.get('SD') or assets.get('MQ') or assets.get('LQ') asset_url = assets.get('HD') or assets.get('HQ') or assets.get('SD') or assets.get('MQ') or assets.get('LQ')
if '.f4m' in asset_url: if '.f4m' in asset_url:
f4m_formats = formats.extend(self._extract_f4m_formats(asset_url + '?hdcore=3.4.0', media_id, f4m_id='hds', fatal=False)) formats.extend(self._extract_f4m_formats(asset_url + '?hdcore=3.4.0', media_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
elif '.m3u8' in asset_url: elif '.m3u8' in asset_url:
m3u8_formats = formats.extend(self._extract_m3u8_formats(asset_url, media_id, m3u8_id='hls', fatal=False)) formats.extend(self._extract_m3u8_formats(asset_url, media_id, m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
for asset in source['url']: for asset in source['url']:
asset_url = asset['text'] asset_url = asset['text']
@ -84,15 +77,6 @@ class SRGSSRIE(InfoExtractor):
'preference': preference(asset['@quality']), 'preference': preference(asset['@quality']),
'ext': ext, 'ext': ext,
}) })
if 'Downloads' in media_data:
for source in media_data['Downloads']['Download']:
for asset in source['url']:
formats.append({
'format_id': asset['@quality'],
'url': asset['text'],
'preference': preference(asset['@quality'])
})
self._sort_formats(formats) self._sort_formats(formats)
return { return {
@ -149,7 +133,7 @@ class SRGSSRPlayIE(InfoExtractor):
'info_dict': { 'info_dict': {
'id': '6348260', 'id': '6348260',
'display_id': '6348260', 'display_id': '6348260',
'ext': 'flv', 'ext': 'mp4',
'duration': 1796, 'duration': 1796,
'title': 'Le 19h30', 'title': 'Le 19h30',
'description': '', 'description': '',
@ -159,6 +143,10 @@ class SRGSSRPlayIE(InfoExtractor):
'thumbnail': 're:^https?://.*\.image', 'thumbnail': 're:^https?://.*\.image',
'view_count': int, 'view_count': int,
}, },
'params': {
# m3u8 download
'skip_download': True,
}
}] }]
def _real_extract(self, url): def _real_extract(self, url):