mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-22 02:11:26 +02:00
Compare commits
No commits in common. "f3f5d080bdff666c535f39e4ab0a1fea9095d5bd" and "8f03e0301bb176f2ddda9adaf2598b67e4713777" have entirely different histories.
f3f5d080bd
...
8f03e0301b
|
@ -2,28 +2,21 @@ import json
|
||||||
|
|
||||||
from .brightcove import BrightcoveNewIE
|
from .brightcove import BrightcoveNewIE
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import ExtractorError
|
|
||||||
from ..utils.traversal import traverse_obj
|
|
||||||
|
|
||||||
|
|
||||||
class LaXarxaMesIE(InfoExtractor):
|
class LaXarxaMesIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?laxarxames\.cat/(?:[^/?#]+/)*?(player|movie-details)/(?P<id>\d+)'
|
_VALID_URL = r'https?://(?:www\.)?laxarxames\.cat/(?:[^/]+/)*?(player|movie-details)/(?P<id>[0-9]+)'
|
||||||
_NETRC_MACHINE = 'laxarxames'
|
_NETRC_MACHINE = 'laxarxames'
|
||||||
_TOKEN = None
|
_TOKEN = None
|
||||||
|
_LOGIN_URL = 'https://www.laxarxames.cat/login'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.laxarxames.cat/player/3459421',
|
'url': 'https://www.laxarxames.cat/player/3459421',
|
||||||
'md5': '0966f46c34275934c19af78f3df6e2bc',
|
'md5': '0966f46c34275934c19af78f3df6e2bc',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '6339612436112',
|
'id': '3459421',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Resum | UA Horta — UD Viladecans',
|
'title': 'Resum | UA Horta — UD Viladecans',
|
||||||
'timestamp': 1697905186,
|
'type': 'video/mp4',
|
||||||
'thumbnail': r're:https?://.*\.jpg',
|
|
||||||
'description': '',
|
|
||||||
'upload_date': '20231021',
|
|
||||||
'duration': 129.44,
|
|
||||||
'tags': ['ott', 'esports', '23-24', ' futbol', ' futbol-partits', 'elit', 'resum'],
|
|
||||||
'uploader_id': '5779379807001',
|
|
||||||
},
|
},
|
||||||
'skip': 'Requires login',
|
'skip': 'Requires login',
|
||||||
}]
|
}]
|
||||||
|
@ -35,6 +28,8 @@ class LaXarxaMesIE(InfoExtractor):
|
||||||
'https://api.laxarxames.cat/Authorization/SignIn', None, note='Logging in', headers={
|
'https://api.laxarxames.cat/Authorization/SignIn', None, note='Logging in', headers={
|
||||||
'X-Tenantorigin': 'https://laxarxames.cat',
|
'X-Tenantorigin': 'https://laxarxames.cat',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json, text/plain, */*',
|
||||||
|
'Origin': 'https://www.laxarxames.cat',
|
||||||
}, data=json.dumps({
|
}, data=json.dumps({
|
||||||
'Username': username,
|
'Username': username,
|
||||||
'Password': password,
|
'Password': password,
|
||||||
|
@ -42,30 +37,38 @@ class LaXarxaMesIE(InfoExtractor):
|
||||||
'PlatformCode': 'WEB',
|
'PlatformCode': 'WEB',
|
||||||
'Name': 'Mac OS ()',
|
'Name': 'Mac OS ()',
|
||||||
},
|
},
|
||||||
}).encode('utf-8'), expected_status=401)
|
}).encode('utf-8')
|
||||||
|
)
|
||||||
|
|
||||||
if not traverse_obj(login, ('AuthorizationToken', 'Token', {str})):
|
if not login['AuthorizationToken']:
|
||||||
raise ExtractorError('Login failed', expected=True)
|
raise Exception('Login failed')
|
||||||
self._TOKEN = login['AuthorizationToken']['Token']
|
else:
|
||||||
|
self._TOKEN = login['AuthorizationToken']['Token']
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
if not self._TOKEN:
|
if not self._TOKEN:
|
||||||
self.raise_login_required()
|
self.raise_login_required()
|
||||||
media_play_info = self._download_json(
|
mediaplayinfo = self._download_json(
|
||||||
'https://api.laxarxames.cat/Media/GetMediaPlayInfo', video_id,
|
'https://api.laxarxames.cat/Media/GetMediaPlayInfo',
|
||||||
|
video_id,
|
||||||
data=json.dumps({
|
data=json.dumps({
|
||||||
'MediaId': int(video_id),
|
'MediaId': int(video_id),
|
||||||
'StreamType': 'MAIN'
|
'StreamType': 'MAIN'
|
||||||
}).encode('utf-8'), headers={
|
}).encode('utf-8'),
|
||||||
'Authorization': f'Bearer {self._TOKEN}',
|
headers={
|
||||||
|
'Authorization': 'Bearer ' + self._TOKEN,
|
||||||
'X-Tenantorigin': 'https://laxarxames.cat',
|
'X-Tenantorigin': 'https://laxarxames.cat',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
})
|
'Accept': 'application/json, text/plain, */*',
|
||||||
|
'Origin': 'https://www.laxarxames.cat',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
content_url = mediaplayinfo['ContentUrl']
|
||||||
|
video_title = mediaplayinfo['Title']
|
||||||
|
|
||||||
if not traverse_obj(media_play_info, ('ContentUrl', {str})):
|
|
||||||
self.raise_no_formats('No video found', expected=True)
|
|
||||||
return self.url_result(
|
return self.url_result(
|
||||||
f'https://players.brightcove.net/5779379807001/default_default/index.html?videoId={media_play_info["ContentUrl"]}',
|
f'http://players.brightcove.net/5779379807001/default_default/index.html?videoId={content_url}',
|
||||||
BrightcoveNewIE, video_id, media_play_info.get('Title'))
|
BrightcoveNewIE, video_id, video_title)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user