1 from .common
import InfoExtractor
2 from ..networking
.exceptions
import HTTPError
10 class AtresPlayerIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?atresplayer\.com/[^/]+/[^/]+/[^/]+/[^/]+/(?P<display_id>.+?)_(?P<id>[0-9a-f]{24})'
12 _NETRC_MACHINE
= 'atresplayer'
15 'url': 'https://www.atresplayer.com/antena3/series/pequenas-coincidencias/temporada-1/capitulo-7-asuntos-pendientes_5d4aa2c57ed1a88fc715a615/',
17 'id': '5d4aa2c57ed1a88fc715a615',
19 'title': 'CapĂtulo 7: Asuntos pendientes',
20 'description': 'md5:7634cdcb4d50d5381bedf93efb537fbc',
23 'skip': 'This video is only available for registered users',
26 'url': 'https://www.atresplayer.com/lasexta/programas/el-club-de-la-comedia/temporada-4/capitulo-10-especial-solidario-nochebuena_5ad08edf986b2855ed47adc4/',
27 'only_matching': True,
30 'url': 'https://www.atresplayer.com/antena3/series/el-secreto-de-puente-viejo/el-chico-de-los-tres-lunares/capitulo-977-29-12-14_5ad51046986b2886722ccdea/',
31 'only_matching': True,
34 _API_BASE
= 'https://api.atresplayer.com/'
36 def _perform_login(self
, username
, password
):
37 self
._request
_webpage
(
38 self
._API
_BASE
+ 'login', None, 'Downloading login page')
41 target_url
= self
._download
_json
(
42 'https://account.atresmedia.com/api/login', None,
43 'Logging in', headers
={
44 'Content-Type': 'application/x-www-form-urlencoded',
45 }, data
=urlencode_postdata({
49 except ExtractorError
as e
:
50 if isinstance(e
.cause
, HTTPError
) and e
.cause
.status
== 400:
51 raise ExtractorError('Invalid username and/or password', expected
=True)
54 self
._request
_webpage
(target_url
, None, 'Following Target URL')
56 def _real_extract(self
, url
):
57 display_id
, video_id
= self
._match
_valid
_url
(url
).groups()
60 episode
= self
._download
_json
(
61 self
._API
_BASE
+ 'client/v1/player/episode/' + video_id
, video_id
)
62 except ExtractorError
as e
:
63 if isinstance(e
.cause
, HTTPError
) and e
.cause
.status
== 403:
64 error
= self
._parse
_json
(e
.cause
.response
.read(), None)
65 if error
.get('error') == 'required_registered':
66 self
.raise_login_required()
67 raise ExtractorError(error
['error_description'], expected
=True)
70 title
= episode
['titulo']
74 for source
in episode
.get('sources', []):
75 src
= source
.get('src')
78 src_type
= source
.get('type')
79 if src_type
== 'application/vnd.apple.mpegurl':
80 formats
, subtitles
= self
._extract
_m
3u8_formats
(
81 src
, video_id
, 'mp4', 'm3u8_native',
82 m3u8_id
='hls', fatal
=False)
83 elif src_type
== 'application/dash+xml':
84 formats
, subtitles
= self
._extract
_mpd
_formats
(
85 src
, video_id
, mpd_id
='dash', fatal
=False)
87 heartbeat
= episode
.get('heartbeat') or {}
88 omniture
= episode
.get('omniture') or {}
89 get_meta
= lambda x
: heartbeat
.get(x
) or omniture
.get(x
)
92 'display_id': display_id
,
95 'description': episode
.get('descripcion'),
96 'thumbnail': episode
.get('imgPoster'),
97 'duration': int_or_none(episode
.get('duration')),
99 'channel': get_meta('channel'),
100 'season': get_meta('season'),
101 'episode_number': int_or_none(get_meta('episodeNumber')),
102 'subtitles': subtitles
,