lttkgp / metadata-extractor

Extract song metadata from YouTube links with Spotify API
MIT License
14 stars 7 forks source link

Improve Exception handling in the module #14

Closed mukul-mehta closed 4 years ago

mukul-mehta commented 4 years ago

I was trying to dump User Posts from Mongo to Postgres while adding metadata for posts. I hit a couple errors when extracting metadata.

track_data = response["tracks"]["items"][0]
IndexError: list index out of range
KeyError: 'link'
KeyError: 'message'

We need to improve handling and add the functions inside try-except blocks to make sure program execution doesn't stop due to an invalid link or if data isn't available for a song. We could also use defaultdict to make sure we have a default values for keys in case data isn't present/parsed for a particular key.