mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 09:11:25 +01:00
Compare commits
No commits in common. "b0b090669d7955fa9de2272de50c7f1adf4568d6" and "9c32f15b7b1380a30bd3596c11aba2212cadfaa9" have entirely different histories.
b0b090669d
...
9c32f15b7b
|
@ -14,17 +14,17 @@ from ..utils.traversal import traverse_obj, value
|
|||
|
||||
|
||||
class BandlabBaseIE(InfoExtractor):
|
||||
def _call_api(self, endpoint, asset_id, **kwargs):
|
||||
headers = kwargs.pop('headers', None) or {}
|
||||
return self._download_json(
|
||||
f'https://www.bandlab.com/api/v1.3/{endpoint}/{asset_id}',
|
||||
asset_id, headers={
|
||||
_API_HEADERS = {
|
||||
'accept': 'application/json',
|
||||
'referer': 'https://www.bandlab.com/',
|
||||
'x-client-id': 'BandLab-Web',
|
||||
'x-client-version': '10.1.124',
|
||||
**headers,
|
||||
}, **kwargs)
|
||||
}
|
||||
|
||||
def _call_api(self, endpoint, asset_id, **kwargs):
|
||||
return self._download_json(
|
||||
f'https://www.bandlab.com/api/v1.3/{endpoint}/{asset_id}',
|
||||
asset_id, headers=self._API_HEADERS, **kwargs)
|
||||
|
||||
def _parse_revision(self, revision_data, url=None):
|
||||
return {
|
||||
|
@ -102,8 +102,8 @@ class BandlabBaseIE(InfoExtractor):
|
|||
|
||||
class BandlabIE(BandlabBaseIE):
|
||||
_VALID_URL = [
|
||||
r'https?://(?:www\.)?bandlab.com/(?P<url_type>track|post|revision)/(?P<id>[\da-f_-]+)',
|
||||
r'https?://(?:www\.)?bandlab.com/(?P<url_type>embed)/\?(?:[^#]*&)?id=(?P<id>[\da-f-]+)',
|
||||
r'https?://(?:www\.)?bandlab.com/(?:track|post|revision)/(?P<id>[\da-f_-]+)',
|
||||
r'https?://(?:www\.)?bandlab.com/embed/\?(?:[^#]*&)?id=(?P<id>[\da-f-]+)',
|
||||
]
|
||||
_EMBED_REGEX = [rf'<iframe[^>]+src=[\'"](?P<url>{_VALID_URL[1]})[\'"]']
|
||||
_TESTS = [{
|
||||
|
@ -279,11 +279,11 @@ class BandlabIE(BandlabBaseIE):
|
|||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
display_id, url_type = self._match_valid_url(url).group('id', 'url_type')
|
||||
display_id = self._match_id(url)
|
||||
|
||||
qs = parse_qs(url)
|
||||
revision_id = traverse_obj(qs, (('revId', 'id'), 0, any))
|
||||
if url_type == 'revision':
|
||||
if 'bandlab.com/revision/' in url:
|
||||
revision_id = display_id
|
||||
|
||||
revision_data = None
|
||||
|
@ -301,7 +301,7 @@ class BandlabIE(BandlabBaseIE):
|
|||
return self._parse_video(post_data, url=url)
|
||||
if post_type == 'Track':
|
||||
return self._parse_track(post_data, url=url)
|
||||
raise ExtractorError(f'Could not extract data for post type {post_type!r}')
|
||||
raise ExtractorError('Could not extract data')
|
||||
|
||||
if not revision_data:
|
||||
revision_data = self._call_api(
|
||||
|
@ -415,8 +415,8 @@ class BandlabPlaylistIE(BandlabBaseIE):
|
|||
if not playlist_data.get('errorCode'):
|
||||
playlist_type = endpoint
|
||||
break
|
||||
if error_code := playlist_data.get('errorCode'):
|
||||
raise ExtractorError(f'Could not find playlist data. Error code: {error_code!r}')
|
||||
if playlist_data.get('errorCode'):
|
||||
raise ExtractorError('Could not find playlist data')
|
||||
|
||||
return self.playlist_result(
|
||||
self._entries(playlist_data), playlist_id,
|
||||
|
@ -426,7 +426,7 @@ class BandlabPlaylistIE(BandlabBaseIE):
|
|||
'uploader': ('creator', 'name', {str}),
|
||||
'uploader_id': ('creator', 'username', {str}),
|
||||
'timestamp': ('createdOn', {parse_iso8601}),
|
||||
'release_date': ('releaseDate', {lambda x: x.replace('-', '')}, filter),
|
||||
'release_date': ('releaseDate', {lambda x: x and x.replace('-', '')}),
|
||||
'thumbnail': ('picture', ('original', 'url'), {url_or_none}, any),
|
||||
'like_count': ('counters', 'likes', {int_or_none}),
|
||||
'comment_count': ('counters', 'comments', {int_or_none}),
|
||||
|
|
Loading…
Reference in New Issue
Block a user