[mitele] Modernize and extract more metadata

This commit is contained in:
Sergey M․ 2016-11-24 22:43:02 +07:00
parent b68599ed47
commit 8eb7b5c3f1
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -86,7 +86,10 @@ class MiTeleIE(InfoExtractor):
'description': 'md5:3b6fce7eaa41b2d97358726378d9369f', 'description': 'md5:3b6fce7eaa41b2d97358726378d9369f',
'series': 'Diario de', 'series': 'Diario de',
'season': 'La redacción', 'season': 'La redacción',
'season_number': 14,
'season_id': 'diario_de_t14_11981',
'episode': 'Programa 144', 'episode': 'Programa 144',
'episode_number': 3,
'thumbnail': 're:(?i)^https?://.*\.jpg$', 'thumbnail': 're:(?i)^https?://.*\.jpg$',
'duration': 2913, 'duration': 2913,
}, },
@ -101,7 +104,10 @@ class MiTeleIE(InfoExtractor):
'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f', 'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f',
'series': 'Cuarto Milenio', 'series': 'Cuarto Milenio',
'season': 'Temporada 6', 'season': 'Temporada 6',
'season_number': 6,
'season_id': 'cuarto_milenio_t06_12715',
'episode': 'Programa 226', 'episode': 'Programa 226',
'episode_number': 24,
'thumbnail': 're:(?i)^https?://.*\.jpg$', 'thumbnail': 're:(?i)^https?://.*\.jpg$',
'duration': 7313, 'duration': 7313,
}, },
@ -118,35 +124,68 @@ class MiTeleIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
gigya_url = self._search_regex(r'<gigya-api>[^>]*</gigya-api>[^>]*<script\s*src="([^"]*)">[^>]*</script>', webpage, 'gigya', default=None) gigya_url = self._search_regex(
gigya_sc = self._download_webpage(compat_urlparse.urljoin(r'http://www.mitele.es/', gigya_url), video_id, 'Downloading gigya script') r'<gigya-api>[^>]*</gigya-api>[^>]*<script\s+src="([^"]*)">[^>]*</script>',
webpage, 'gigya', default=None)
gigya_sc = self._download_webpage(
compat_urlparse.urljoin('http://www.mitele.es/', gigya_url),
video_id, 'Downloading gigya script')
# Get a appKey/uuid for getting the session key # Get a appKey/uuid for getting the session key
appKey_var = self._search_regex(r'value\("appGridApplicationKey",([0-9a-f]+)\)', gigya_sc, 'appKey variable') appKey_var = self._search_regex(
appKey = self._search_regex(r'var %s="([0-9a-f]+)"' % appKey_var, gigya_sc, 'appKey') r'value\s*\(\s*["\']appGridApplicationKey["\']\s*,\s*([0-9a-f]+)',
uid = compat_str(uuid.uuid4()) gigya_sc, 'appKey variable')
session_url = 'https://appgrid-api.cloud.accedo.tv/session?appKey=%s&uuid=%s' % (appKey, uid) appKey = self._search_regex(
session_json = self._download_json(session_url, video_id, 'Downloading session keys') r'var\s+%s\s*=\s*["\']([0-9a-f]+)' % appKey_var, gigya_sc, 'appKey')
sessionKey = compat_str(session_json['sessionKey'])
session_json = self._download_json(
'https://appgrid-api.cloud.accedo.tv/session',
video_id, 'Downloading session keys', query={
'appKey': appKey,
'uuid': compat_str(uuid.uuid4()),
})
paths = self._download_json(
'https://appgrid-api.cloud.accedo.tv/metadata/general_configuration,%20web_configuration',
video_id, 'Downloading paths JSON',
query={'sessionKey': compat_str(session_json['sessionKey'])})
paths_url = 'https://appgrid-api.cloud.accedo.tv/metadata/general_configuration,%20web_configuration?sessionKey=' + sessionKey
paths = self._download_json(paths_url, video_id, 'Downloading paths JSON')
ooyala_s = paths['general_configuration']['api_configuration']['ooyala_search'] ooyala_s = paths['general_configuration']['api_configuration']['ooyala_search']
data_p = ( source = self._download_json(
'http://' + ooyala_s['base_url'] + ooyala_s['full_path'] + ooyala_s['provider_id'] + 'http://%s%s%s/docs/%s' % (
'/docs/' + video_id + '?include_titles=Series,Season&product_name=test&format=full') ooyala_s['base_url'], ooyala_s['full_path'],
data = self._download_json(data_p, video_id, 'Downloading data JSON') ooyala_s['provider_id'], video_id),
source = data['hits']['hits'][0]['_source'] video_id, 'Downloading data JSON', query={
embedCode = source['offers'][0]['embed_codes'][0] 'include_titles': 'Series,Season',
'product_name': 'test',
'format': 'full',
})['hits']['hits'][0]['_source']
embedCode = source['offers'][0]['embed_codes'][0]
titles = source['localizable_titles'][0] titles = source['localizable_titles'][0]
title = titles.get('title_medium') or titles['title_long'] title = titles.get('title_medium') or titles['title_long']
episode = titles['title_sort_name']
description = titles['summary_long'] description = titles.get('summary_long') or titles.get('summary_medium')
titles_series = source['localizable_titles_series'][0]
series = titles_series['title_long'] def get(key1, key2):
titles_season = source['localizable_titles_season'][0] value1 = source.get(key1)
season = titles_season['title_medium'] if not value1 or not isinstance(value1, list):
duration = parse_duration(source['videos'][0]['duration']) return
if not isinstance(value1[0], dict):
return
return value1[0].get(key2)
series = get('localizable_titles_series', 'title_medium')
season = get('localizable_titles_season', 'title_medium')
season_number = int_or_none(source.get('season_number'))
season_id = source.get('season_id')
episode = titles.get('title_sort_name')
episode_number = int_or_none(source.get('episode_number'))
duration = parse_duration(get('videos', 'duration'))
return { return {
'_type': 'url_transparent', '_type': 'url_transparent',
@ -157,7 +196,10 @@ class MiTeleIE(InfoExtractor):
'description': description, 'description': description,
'series': series, 'series': series,
'season': season, 'season': season,
'season_number': season_number,
'season_id': season_id,
'episode': episode, 'episode': episode,
'episode_number': episode_number,
'duration': duration, 'duration': duration,
'thumbnail': source['images'][0]['url'], 'thumbnail': get('images', 'url'),
} }