mirror of
https://github.com/l1ving/youtube-dl
synced 2025-01-24 11:22:58 +08:00
review
This commit is contained in:
parent
471f398772
commit
8d66489358
@ -186,7 +186,7 @@ def expect_info_dict(self, got_dict, expected_dict):
|
||||
# Are checkable fields missing from the test case definition?
|
||||
test_info_dict = dict((key, value if not isinstance(value, compat_str) or len(value) < 250 else 'md5:' + md5(value))
|
||||
for key, value in got_dict.items()
|
||||
if value and key in ('id', 'title', 'description', 'uploader', 'upload_date', 'timestamp', 'uploader_id', 'location', 'age_limit', 'album', 'artist', 'track', 'track_number', 'release_year', 'release_date'))
|
||||
if value and key in ('id', 'title', 'description', 'uploader', 'upload_date', 'timestamp', 'uploader_id', 'location', 'age_limit'))
|
||||
missing_keys = set(test_info_dict.keys()) - set(expected_dict.keys())
|
||||
if missing_keys:
|
||||
def _repr(v):
|
||||
|
@ -77,7 +77,10 @@ class BandcampIE(InfoExtractor):
|
||||
m_download = re.search(r'freeDownloadPage: "(.*?)"', webpage)
|
||||
m_trackinfo = re.search(r'trackinfo: (.+),\s*?\n', webpage)
|
||||
json_code = m_trackinfo.group(1) if m_trackinfo else None
|
||||
data = json.loads(json_code)[0] if json_code else None
|
||||
try:
|
||||
data = json.loads(json_code)[0] if json_code else None
|
||||
except ValueError:
|
||||
data = None
|
||||
|
||||
match = re.search(r'album_title\s*:\s*"([^"]+)"', webpage)
|
||||
album_title = match.group(1) if match else None
|
||||
@ -89,9 +92,12 @@ class BandcampIE(InfoExtractor):
|
||||
release_date = unified_strdate(match.group(1)) if match else None
|
||||
release_year = int(release_date[0:4]) if release_date else None
|
||||
|
||||
track = data['title'] if data else None
|
||||
track = data.get('title') if data else None
|
||||
title = '%s - %s' % (artist, track) if artist else track
|
||||
|
||||
track_number = data.get('track_num') if data else None
|
||||
duration = float_or_none(data.get('duration'))
|
||||
|
||||
if not m_download:
|
||||
if data:
|
||||
track_id = compat_str(data['id'])
|
||||
@ -119,14 +125,14 @@ class BandcampIE(InfoExtractor):
|
||||
'uploader': artist,
|
||||
'artist': artist,
|
||||
'track_id': track_id,
|
||||
'track_number': data.get('track_num'),
|
||||
'track_number': track_number,
|
||||
'release_date': release_date,
|
||||
'release_year': release_year,
|
||||
'track': track,
|
||||
'title': title,
|
||||
'thumbnail': thumbnail,
|
||||
'formats': formats,
|
||||
'duration': float_or_none(data.get('duration')),
|
||||
'duration': duration,
|
||||
}
|
||||
else:
|
||||
raise ExtractorError('No free songs found')
|
||||
@ -192,7 +198,7 @@ class BandcampIE(InfoExtractor):
|
||||
'uploader': artist,
|
||||
'artist': artist,
|
||||
'track_id': video_id,
|
||||
'track_number': data.get('track_num'),
|
||||
'track_number': track_number,
|
||||
'release_date': release_date,
|
||||
'release_year': release_year,
|
||||
'track': track,
|
||||
@ -200,6 +206,7 @@ class BandcampIE(InfoExtractor):
|
||||
'thumbnail': digital_items.get('thumb_url') or thumbnail,
|
||||
'track': track,
|
||||
'formats': formats,
|
||||
'duration': duration,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user