Skip to content

Commit

Permalink
Fix a bug with last.fm not returning consistent data
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30 committed Jan 8, 2021
1 parent fb052e9 commit 446f122
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bin/ytmdl
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ def main(args):

# Else exit
logger.critical("Error occurred: ", str(e),
". Exiting. Pass `--ignore-errors` if you want errors \
like this to be ignored")
". Exiting. Pass `--ignore-errors` if you want errors"
"like this to be ignored")

# Delete the cached songs
dir._delete_cached_songs(passed_format)
Expand Down
12 changes: 9 additions & 3 deletions ytmdl/meta/lastfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ def get_more_data(song):

# Update the songs attributes
song.track_number = 1
song.collection_name = track_details["track"]["album"]["title"]
song.track_time = song._convert_time(track_details["track"]["duration"])
song.release_date = track_details["track"]["wiki"]["published"]

try:
song.collection_name = track_details["track"]["album"]["title"]
song.track_time = song._convert_time(track_details["track"]["duration"])
song.release_date = track_details["track"]["wiki"]["published"]
except KeyError:
# This happens because last.fm do not have consistent data for some songs
# Just ignore this errors if they occur.
pass

return song

Expand Down

0 comments on commit 446f122

Please sign in to comment.