mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-17 18:58:35 +00:00
Merge ace97a88fa
into c1ac543c81
This commit is contained in:
commit
aab8367ce0
@ -11,10 +11,12 @@
|
||||
float_or_none,
|
||||
int_or_none,
|
||||
parse_filesize,
|
||||
smuggle_url,
|
||||
str_or_none,
|
||||
try_get,
|
||||
unified_strdate,
|
||||
unified_timestamp,
|
||||
unsmuggle_url,
|
||||
update_url_query,
|
||||
url_or_none,
|
||||
urljoin,
|
||||
@ -127,6 +129,8 @@ def _extract_data_attr(self, webpage, video_id, attr='tralbum', fatal=True):
|
||||
attr + ' data', group=2), video_id, fatal=fatal)
|
||||
|
||||
def _real_extract(self, url):
|
||||
url, smuggled_track_info = unsmuggle_url(url, None)
|
||||
|
||||
title, uploader = self._match_valid_url(url).group('id', 'uploader')
|
||||
webpage = self._download_webpage(url, title)
|
||||
tralbum = self._extract_data_attr(webpage, title)
|
||||
@ -138,7 +142,7 @@ def _real_extract(self, url):
|
||||
duration = None
|
||||
|
||||
formats = []
|
||||
track_info = try_get(tralbum, lambda x: x['trackinfo'][0], dict)
|
||||
track_info = try_get(tralbum, lambda x: x['trackinfo'][0], dict) or smuggled_track_info
|
||||
if track_info:
|
||||
file_ = track_info.get('file')
|
||||
if isinstance(file_, dict):
|
||||
@ -347,6 +351,15 @@ class BandcampAlbumIE(BandcampIE): # XXX: Do not subclass from concrete IE
|
||||
'description': 'md5:b3cf845ee41b2b1141dc7bde9237255f',
|
||||
},
|
||||
'playlist_count': 2,
|
||||
}, {
|
||||
# tracks need track_info smuggled because they don't have a usable one on the pages
|
||||
'url': 'https://wetleg.bandcamp.com/album/wet-leg',
|
||||
'info_dict': {
|
||||
'id': 'wet-leg',
|
||||
'title': 'Wet Leg',
|
||||
'uploader_id': 'wetleg',
|
||||
},
|
||||
'playlist_count': 12,
|
||||
}]
|
||||
|
||||
@classmethod
|
||||
@ -364,12 +377,17 @@ def _real_extract(self, url):
|
||||
if not track_info:
|
||||
raise ExtractorError('The page doesn\'t contain any tracks')
|
||||
# Only tracks with duration info have songs
|
||||
entries = [
|
||||
self.url_result(
|
||||
urljoin(url, t['title_link']), BandcampIE.ie_key(),
|
||||
str_or_none(t.get('track_id') or t.get('id')), t.get('title'))
|
||||
for t in track_info
|
||||
if t.get('duration')]
|
||||
entries = []
|
||||
for t in track_info:
|
||||
if t.get('duration'):
|
||||
url = urljoin(url, t['title_link'])
|
||||
if t.get('track_license_id'):
|
||||
# tracks with this set don't have a usable tralbum on their pages
|
||||
url = smuggle_url(url, t)
|
||||
entries.append(self.url_result(
|
||||
url, BandcampIE.ie_key(),
|
||||
str_or_none(t.get('track_id') or t.get('id')), t.get('title'),
|
||||
))
|
||||
|
||||
current = tralbum.get('current') or {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user