3 from .brightcove
import BrightcoveNewIE
4 from .common
import InfoExtractor
5 from ..utils
import ExtractorError
6 from ..utils
.traversal
import traverse_obj
9 class LaXarxaMesIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:www\.)?laxarxames\.cat/(?:[^/?#]+/)*?(player|movie-details)/(?P<id>\d+)'
11 _NETRC_MACHINE
= 'laxarxames'
14 'url': 'https://www.laxarxames.cat/player/3459421',
15 'md5': '0966f46c34275934c19af78f3df6e2bc',
17 'id': '6339612436112',
19 'title': 'Resum | UA Horta — UD Viladecans',
20 'timestamp': 1697905186,
21 'thumbnail': r
're:https?://.*\.jpg',
23 'upload_date': '20231021',
25 'tags': ['ott', 'esports', '23-24', ' futbol', ' futbol-partits', 'elit', 'resum'],
26 'uploader_id': '5779379807001',
28 'skip': 'Requires login',
31 def _perform_login(self
, username
, password
):
35 login
= self
._download
_json
(
36 'https://api.laxarxames.cat/Authorization/SignIn', None, note
='Logging in', headers
={
37 'X-Tenantorigin': 'https://laxarxames.cat',
38 'Content-Type': 'application/json',
43 'PlatformCode': 'WEB',
46 }).encode(), expected_status
=401)
48 self
._TOKEN
= traverse_obj(login
, ('AuthorizationToken', 'Token', {str}
))
50 raise ExtractorError('Login failed', expected
=True)
52 def _real_extract(self
, url
):
53 video_id
= self
._match
_id
(url
)
55 self
.raise_login_required()
57 media_play_info
= self
._download
_json
(
58 'https://api.laxarxames.cat/Media/GetMediaPlayInfo', video_id
,
60 'MediaId': int(video_id
),
62 }).encode(), headers
={
63 'Authorization': f
'Bearer {self._TOKEN}',
64 'X-Tenantorigin': 'https://laxarxames.cat',
65 'Content-Type': 'application/json',
68 if not traverse_obj(media_play_info
, ('ContentUrl', {str}
)):
69 self
.raise_no_formats('No video found', expected
=True)
71 return self
.url_result(
72 f
'https://players.brightcove.net/5779379807001/default_default/index.html?videoId={media_play_info["ContentUrl"]}',
73 BrightcoveNewIE
, video_id
, media_play_info
.get('Title'))