cleanup code, flake8 passed
This commit is contained in:
parent
13d441b1b1
commit
18b5708685
@ -5,10 +5,10 @@ from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
int_or_none,
|
||||
urlencode_postdata,
|
||||
compat_str,
|
||||
ExtractorError,
|
||||
)
|
||||
|
||||
|
||||
class ContarBaseIE(InfoExtractor):
|
||||
|
||||
_NETRC_MACHINE = 'contar'
|
||||
@ -22,7 +22,7 @@ class ContarBaseIE(InfoExtractor):
|
||||
raise ExtractorError(
|
||||
'%s said: %s' % (self.IE_NAME, error), expected=True)
|
||||
|
||||
def _call_api(self, path, video_id, headers = {}, note='Downloading JSON metadata'):
|
||||
def _call_api(self, path, video_id, headers={}, note='Downloading JSON metadata'):
|
||||
if self._auth_token:
|
||||
headers['Authorization'] = 'Bearer ' + self._auth_token
|
||||
|
||||
@ -46,15 +46,13 @@ class ContarBaseIE(InfoExtractor):
|
||||
self._handle_errors(result)
|
||||
self._auth_token = result['token']
|
||||
|
||||
def _get_video_info(self, video, video_id, base = {}):
|
||||
#print(json.dumps(video, indent=4, sort_keys=True))
|
||||
#print "id = %s S%sE%s" % (video.get('id'), season.get('name') , video.get('episode'))
|
||||
def _get_video_info(self, video, video_id, base={}):
|
||||
|
||||
formats = self._get_formats(video.get('streams', []), video.get('id'))
|
||||
subtitles = self._get_subtitles(video['subtitles'].get('data', []), video.get('id'))
|
||||
|
||||
serie_info = base.get('serie_info') or self._get_serie_info(video.get('serie'))
|
||||
season_number = base.get('season_number') or self._get_season_number(serie_info, video.get('id'));
|
||||
season_number = base.get('season_number') or self._get_season_number(serie_info, video.get('id'))
|
||||
episode_number = video.get('episode')
|
||||
|
||||
info = {
|
||||
@ -70,7 +68,7 @@ class ContarBaseIE(InfoExtractor):
|
||||
'duration': int_or_none(video.get('length')),
|
||||
'thumbnail': video.get('posterImage'),
|
||||
'release_year': int_or_none(serie_info.get('year')),
|
||||
#'timestamp': timestamp,
|
||||
# 'timestamp': timestamp,
|
||||
'formats': formats,
|
||||
'subtitles': subtitles,
|
||||
}
|
||||
@ -83,7 +81,6 @@ class ContarBaseIE(InfoExtractor):
|
||||
|
||||
def _get_season_number(self, serie_info, video_id):
|
||||
for season in serie_info['seasons'].get('data', []):
|
||||
#print(json.dumps(season, indent=4, sort_keys=True))
|
||||
season_number = season.get('name')
|
||||
for episode in season['videos'].get('data', []):
|
||||
if episode.get('id') == video_id:
|
||||
@ -94,7 +91,7 @@ class ContarBaseIE(InfoExtractor):
|
||||
subs = {}
|
||||
for sub in subtitles:
|
||||
lang = sub.get('lang').lower()
|
||||
subs[lang] = [{ 'url': sub.get('url'), 'ext': 'srt'}]
|
||||
subs[lang] = [{'url': sub.get('url'), 'ext': 'srt'}]
|
||||
|
||||
return subs
|
||||
|
||||
@ -105,8 +102,8 @@ class ContarBaseIE(InfoExtractor):
|
||||
type = stream.get('type')
|
||||
if (type == 'HLS'):
|
||||
formats.extend(self._extract_m3u8_formats(stream_url,
|
||||
video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls',
|
||||
fatal=False))
|
||||
video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls',
|
||||
fatal=False))
|
||||
elif (type == 'DASH'):
|
||||
formats.extend(self._extract_mpd_formats(
|
||||
stream_url, video_id, mpd_id='dash', fatal=False))
|
||||
@ -147,7 +144,7 @@ class ContarIE(ContarBaseIE):
|
||||
video_id = self._match_id(url)
|
||||
|
||||
video = self._call_api('videos/' + video_id, video_id, headers={'Referer': url})
|
||||
info = self._get_video_info(video, video_id);
|
||||
info = self._get_video_info(video, video_id)
|
||||
return info
|
||||
|
||||
|
||||
@ -161,7 +158,7 @@ class ContarSerieIE(ContarBaseIE):
|
||||
'id': '353247d5-da97-4cb6-8571-c4fbab28c643',
|
||||
'title': 'Vidas de Radio',
|
||||
'description': 'Ana Gerschenson conduce el ciclo que repasa historias de grandes personalidades que le dieron vida al medio; marcaron una época de la Argentina y de tu vida, esas voces amigas que estuvieron siempre y son Vidas De Radio.'
|
||||
#'thumbnail': r're:^https?://.*\.jpg$',
|
||||
# 'thumbnail': r're:^https?://.*\.jpg$',
|
||||
# TODO more properties, either as:
|
||||
# * A value
|
||||
# * MD5 checksum; start the string with md5:
|
||||
@ -212,17 +209,15 @@ class ContarSerieIE(ContarBaseIE):
|
||||
|
||||
serie_info = self._get_serie_info(serie_id, headers={'Referer': url})
|
||||
|
||||
seasons = []
|
||||
entries = []
|
||||
|
||||
base = {}
|
||||
base['serie_info'] = serie_info
|
||||
|
||||
for season in serie_info['seasons'].get('data', []):
|
||||
#print(json.dumps(season, indent=4, sort_keys=True))
|
||||
base['season_number'] = season.get('name')
|
||||
for episode in season['videos'].get('data', []):
|
||||
info = self._get_video_info(episode, serie_id, base);
|
||||
info = self._get_video_info(episode, serie_id, base)
|
||||
entries.append(info)
|
||||
|
||||
return self.playlist_result(
|
||||
@ -267,6 +262,7 @@ class ContarChannelIE(ContarBaseIE):
|
||||
return self.playlist_result(
|
||||
entries, list_id, channel_info.get('name'), channel_info.get('description'))
|
||||
|
||||
|
||||
class ContarBrowseIE(ContarBaseIE):
|
||||
|
||||
_UUID_RE = r'[\d]{1,}'
|
||||
@ -303,4 +299,3 @@ class ContarBrowseIE(ContarBaseIE):
|
||||
return self.playlist_result(
|
||||
entries, list_id,
|
||||
list.get('title'))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user