Compare commits

..

No commits in common. "b0b090669d7955fa9de2272de50c7f1adf4568d6" and "9c32f15b7b1380a30bd3596c11aba2212cadfaa9" have entirely different histories.

View File

@ -14,17 +14,17 @@ from ..utils.traversal import traverse_obj, value
class BandlabBaseIE(InfoExtractor): class BandlabBaseIE(InfoExtractor):
def _call_api(self, endpoint, asset_id, **kwargs): _API_HEADERS = {
headers = kwargs.pop('headers', None) or {}
return self._download_json(
f'https://www.bandlab.com/api/v1.3/{endpoint}/{asset_id}',
asset_id, headers={
'accept': 'application/json', 'accept': 'application/json',
'referer': 'https://www.bandlab.com/', 'referer': 'https://www.bandlab.com/',
'x-client-id': 'BandLab-Web', 'x-client-id': 'BandLab-Web',
'x-client-version': '10.1.124', '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): def _parse_revision(self, revision_data, url=None):
return { return {
@ -102,8 +102,8 @@ class BandlabBaseIE(InfoExtractor):
class BandlabIE(BandlabBaseIE): class BandlabIE(BandlabBaseIE):
_VALID_URL = [ _VALID_URL = [
r'https?://(?:www\.)?bandlab.com/(?P<url_type>track|post|revision)/(?P<id>[\da-f_-]+)', r'https?://(?:www\.)?bandlab.com/(?: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/embed/\?(?:[^#]*&)?id=(?P<id>[\da-f-]+)',
] ]
_EMBED_REGEX = [rf'<iframe[^>]+src=[\'"](?P<url>{_VALID_URL[1]})[\'"]'] _EMBED_REGEX = [rf'<iframe[^>]+src=[\'"](?P<url>{_VALID_URL[1]})[\'"]']
_TESTS = [{ _TESTS = [{
@ -279,11 +279,11 @@ class BandlabIE(BandlabBaseIE):
}] }]
def _real_extract(self, url): 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) qs = parse_qs(url)
revision_id = traverse_obj(qs, (('revId', 'id'), 0, any)) revision_id = traverse_obj(qs, (('revId', 'id'), 0, any))
if url_type == 'revision': if 'bandlab.com/revision/' in url:
revision_id = display_id revision_id = display_id
revision_data = None revision_data = None
@ -301,7 +301,7 @@ class BandlabIE(BandlabBaseIE):
return self._parse_video(post_data, url=url) return self._parse_video(post_data, url=url)
if post_type == 'Track': if post_type == 'Track':
return self._parse_track(post_data, url=url) 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: if not revision_data:
revision_data = self._call_api( revision_data = self._call_api(
@ -415,8 +415,8 @@ class BandlabPlaylistIE(BandlabBaseIE):
if not playlist_data.get('errorCode'): if not playlist_data.get('errorCode'):
playlist_type = endpoint playlist_type = endpoint
break break
if error_code := playlist_data.get('errorCode'): if playlist_data.get('errorCode'):
raise ExtractorError(f'Could not find playlist data. Error code: {error_code!r}') raise ExtractorError('Could not find playlist data')
return self.playlist_result( return self.playlist_result(
self._entries(playlist_data), playlist_id, self._entries(playlist_data), playlist_id,
@ -426,7 +426,7 @@ class BandlabPlaylistIE(BandlabBaseIE):
'uploader': ('creator', 'name', {str}), 'uploader': ('creator', 'name', {str}),
'uploader_id': ('creator', 'username', {str}), 'uploader_id': ('creator', 'username', {str}),
'timestamp': ('createdOn', {parse_iso8601}), '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), 'thumbnail': ('picture', ('original', 'url'), {url_or_none}, any),
'like_count': ('counters', 'likes', {int_or_none}), 'like_count': ('counters', 'likes', {int_or_none}),
'comment_count': ('counters', 'comments', {int_or_none}), 'comment_count': ('counters', 'comments', {int_or_none}),