Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safely access metadata #13

Merged
merged 1 commit into from
Feb 1, 2022
Merged

Safely access metadata #13

merged 1 commit into from
Feb 1, 2022

Conversation

benortiz
Copy link
Contributor

When a key is missing from info.json, it shouldn't prevent the rest of
the data from being loaded.

When adding an item that wasn't a part of a playlist, there will be no
'playlist_title'. Before this change, all the metadata would be missing
from these videos. Now, the other data gets loaded. Yay!

I tried to replecate the pattern already established of using:

if data['key']:

but this raised the same KeyError when the key didn't exist. I'm not a
regular Python dev but I think something changed in Python 3. Using the
in syntax here seems to work great for all the places I changed.

I think this should address:

#6 (comment)
#10 (comment)
#12

As the issue they describe has the same symptoms that I was
experiencing.

When a key is missing from info.json, it shouldn't prevent the rest of
the data from being loaded.

When adding an item that wasn't a part of a playlist, there will be no
'playlist_title'. Before this change, all the metadata would be missing
from these videos. Now, the other data gets loaded. Yay!

I tried to replecate the pattern already established of using:

```
if data['key']:
```

but this raised the same KeyError when the key didn't exist. I'm not a
regular Python dev but I think something changed in Python 3. Using the
`in` syntax here seems to work great for all the places I changed.

I think this should address:

#6 (comment)
#10 (comment)
#12

As the issue they describe has the same symptoms that I was
experiencing.
@JordyAlkema JordyAlkema merged commit 8f6b961 into JordyAlkema:master Feb 1, 2022
@JordyAlkema
Copy link
Owner

Thank you for taking the time to look into the issue and making a pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants