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

Handle Current JSON Payloads and Update README #18

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Install or upgrade pylistenbrainz with:

## Support

You can ask questions about how to use pylistenbrainz on IRC (freenode #metabrainz).
You can ask questions about how to use pylistenbrainz on IRC (Libera.Chat #metabrainz).
You can also email me at `iliekcomputers [at] gmail [dot] com`.

If you have found a bug or have a feature request, let me know by opening an issue (or a pull request).
Expand Down
2 changes: 2 additions & 0 deletions pylistenbrainz/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(
listening_from=None,
isrc=None,
additional_info=None,
mbid_mapping=None,
username=None,
recording_msid=None,
):
Expand Down Expand Up @@ -104,6 +105,7 @@ def __init__(
self.listening_from = listening_from
self.isrc = isrc
self.additional_info = additional_info or {}
self.mbid_mapping = mbid_mapping or {}
self.username = username
self.recording_msid = recording_msid

Expand Down
6 changes: 4 additions & 2 deletions pylistenbrainz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ def _validate_submit_listens_payload(listen_type, listens):
def _convert_api_payload_to_listen(data):
track_metadata = data['track_metadata']
additional_info = track_metadata.get('additional_info', {})
mbid_mapping = track_metadata.get('mbid_mapping', {})
return Listen(
track_name=track_metadata['track_name'],
artist_name=track_metadata['artist_name'],
listened_at=data.get('listened_at'),
release_name=track_metadata.get('release_name'),
recording_mbid=additional_info.get('recording_mbid'),
artist_mbids=additional_info.get('artist_mbids', []),
release_mbid=additional_info.get('release_mbid'),
artist_mbids=mbid_mapping.get('artist_mbids', []),
release_mbid=mbid_mapping.get('release_mbid'),
tags=additional_info.get('tags', []),
release_group_mbid=additional_info.get('release_group_mbid'),
work_mbids=additional_info.get('work_mbids', []),
Expand All @@ -52,6 +53,7 @@ def _convert_api_payload_to_listen(data):
listening_from=additional_info.get('listening_from'),
isrc=additional_info.get('isrc'),
additional_info=additional_info,
mbid_mapping=mbid_mapping,
username=data.get('username'),
recording_msid=data.get('recording_msid'),
)