Refactor.
This commit is contained in:
parent
1a981adbdd
commit
72a6740a4f
@ -16,26 +16,21 @@ except ImportError:
|
|||||||
JSONDecodeError = ValueError
|
JSONDecodeError = ValueError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AtresPlayerIE(InfoExtractor):
|
class AtresPlayerIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?atresplayer\.com/[^/]+/[^/]+/[^/]+/[^/]+/[^/_]+_(?P<id>[A-z0-9]+)/?'
|
_VALID_URL = r'https?://(?:www\.)?atresplayer\.com/[^/]+/[^/]+/[^/]+/[^/]+/[^/_]+_(?P<id>[A-z0-9]+)/?'
|
||||||
_NETRC_MACHINE = 'atresplayer'
|
_NETRC_MACHINE = 'atresplayer'
|
||||||
_TESTS = [
|
_TESTS = [
|
||||||
{
|
{
|
||||||
'url': 'https://www.atresplayer.com/lasexta/series/navy-investigacion-criminal/temporada-12/capitulo-10-captulo_5ad6869b986b2866f89ebca0/',
|
'url': 'https://www.atresplayer.com/lasexta/programas/el-intermedio/temporada-12/el-intermedio-21-05-18_5b03068d7ed1a8a94b3faf29/',
|
||||||
'md5': '3afa3d3cc155264374916f2a23d1d00c',
|
'md5': '3afa3d3cc155264374916f2a23d1d00c',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '5ad6869b986b2866f89ebca0',
|
'id': '5b03068d7ed1a8a94b3faf29',
|
||||||
'ext': 'm3u8',
|
'ext': 'm3u8',
|
||||||
'title': u'Capítulo 10: Reglas de casa',
|
|
||||||
'description': 'md5:3ec43e9b7da2cd1280fa80adccdd09b0',
|
|
||||||
'duration': 2500.0,
|
|
||||||
'thumbnail': r're:^https://imagenes.atresplayer.com/.+$'
|
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
|
'skip': 'required_registered',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'url': 'http://www.atresplayer.com/television/series/el-secreto-de-puente-viejo/el-chico-de-los-tres-lunares/capitulo-977-29-12-14_2014122400174.html',
|
'url': 'http://www.atresplayer.com/television/series/el-secreto-de-puente-viejo/el-chico-de-los-tres-lunares/capitulo-977-29-12-14_2014122400174.html',
|
||||||
@ -44,13 +39,10 @@ class AtresPlayerIE(InfoExtractor):
|
|||||||
]
|
]
|
||||||
|
|
||||||
_USER_AGENT = 'Dalvik/1.6.0 (Linux; U; Android 4.3; GT-I9300 Build/JSS15J'
|
_USER_AGENT = 'Dalvik/1.6.0 (Linux; U; Android 4.3; GT-I9300 Build/JSS15J'
|
||||||
|
|
||||||
_PLAYER_URL_TEMPLATE = 'https://api.atresplayer.com/client/v1/page/episode/%s'
|
_PLAYER_URL_TEMPLATE = 'https://api.atresplayer.com/client/v1/page/episode/%s'
|
||||||
|
|
||||||
_LOGIN_URL = 'https://api.atresplayer.com/login?redirect=https%3A%2F%2Fwww.atresplayer.com'
|
_LOGIN_URL = 'https://api.atresplayer.com/login?redirect=https%3A%2F%2Fwww.atresplayer.com'
|
||||||
_LOGIN_ACCOUNT_URL = 'https://account.atresmedia.com/api/login'
|
_LOGIN_ACCOUNT_URL = 'https://account.atresmedia.com/api/login'
|
||||||
|
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
self._login()
|
self._login()
|
||||||
|
|
||||||
@ -72,13 +64,12 @@ class AtresPlayerIE(InfoExtractor):
|
|||||||
login_form,
|
login_form,
|
||||||
method='post')
|
method='post')
|
||||||
request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
# request.add_header('Content-Type', 'multipart/form-data')
|
|
||||||
try:
|
try:
|
||||||
response = self._download_json(
|
response = self._download_json(
|
||||||
request, None, 'post to login form')
|
request, None, 'post to login form')
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if isinstance(e.cause, HTTPError):
|
if isinstance(e.cause, HTTPError):
|
||||||
self._atres_player_error(e.cause.file.read(), e)
|
raise self._atres_player_error(e.cause.file.read(), e)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
@ -88,13 +79,13 @@ class AtresPlayerIE(InfoExtractor):
|
|||||||
try:
|
try:
|
||||||
data = json.loads(body_response)
|
data = json.loads(body_response)
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
raise original_exception
|
return original_exception
|
||||||
if isinstance(data, dict) and 'error' in data:
|
if isinstance(data, dict) and 'error' in data:
|
||||||
raise ExtractorError('{} returned error: {} ({})'.format(
|
return ExtractorError('{} returned error: {} ({})'.format(
|
||||||
self.IE_NAME, data['error'], data.get('error_description', 'There is no description')
|
self.IE_NAME, data['error'], data.get('error_description', 'There is no description')
|
||||||
), expected=True)
|
), expected=True)
|
||||||
else:
|
else:
|
||||||
raise original_exception
|
return original_exception
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
@ -115,7 +106,7 @@ class AtresPlayerIE(InfoExtractor):
|
|||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if len(e.exc_info) <= 1 or e.exc_info[1].code != 403:
|
if len(e.exc_info) <= 1 or e.exc_info[1].code != 403:
|
||||||
raise
|
raise
|
||||||
self._atres_player_error(e.exc_info[1].file.read(), e)
|
raise self._atres_player_error(e.exc_info[1].file.read(), e)
|
||||||
|
|
||||||
for source in video_data['sources']:
|
for source in video_data['sources']:
|
||||||
if source['type'] == "application/dash+xml":
|
if source['type'] == "application/dash+xml":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user