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

fix bug 3804 #3836

Closed
wants to merge 3 commits into from
Closed

fix bug 3804 #3836

wants to merge 3 commits into from

Conversation

syco
Copy link

@syco syco commented Jan 18, 2021

Signed-off-by: Syco alberto.rinaudo+zhds@gmail.com

Description

Fixes #3804

Signed-off-by: Syco <alberto.rinaudo+zhds@gmail.com>
Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!! A couple of questions within. Also, could you please add a changelog entry? (There are notes on how to do so in the PR template.)

beetsplug/missing.py Outdated Show resolved Hide resolved
print_(u"{} - {}".format(artist[0], release_title))
for album in missing:
for album_info in hooks.albums_for_id(album['id']):
item = _album_item(album_info, album_info.album_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being slow, but I don't quite understand what the deal is with the new _album_item filter. Can you explain a little more how this works?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use the format function I needed an object previously returned by _item, but _item expects a track_info object.
Because this is applied to albums I don't have a track_info object to pass to _item, hence I created a new filter called _album_item that accept an album_info.

resp = musicbrainzngs.browse_release_groups(artist=artist[1])
release_groups = resp['release-group-list']
resp = musicbrainzngs.browse_releases(artist=artist[1])
release_groups = resp['release-list']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether the changes from this PR should be hidden behind a command line flag (--show-releases, --detailed-releases?). Going from release groups to individual releases will substantially increase the amount of output (I'd imagine you'd easily see 5-10 times as many output lines for many artists), making it harder to parse visually. I'm not a user of this plugin myself, but I think I'd mostly be interested in knowing the release groups that I'm missing rather than each and every Vinyl, CD and digital release.

What do you think?

Style-wise, I think release_groups (and rg) below should be renamed to releases and r to avoid confusion.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion with the first commit, I should have tested more before opening the PR.
This change does increase the output, but the original rg object contains only release group id, artist, and album name.
If we want allow a formatting string that uses any other placeholder it's necessary to get the full album object.

beetsplug/missing.py Show resolved Hide resolved
Syco added 2 commits January 18, 2021 17:36
Signed-off-by: Syco <alberto.rinaudo+zhds@gmail.com>
Signed-off-by: Syco <alberto.rinaudo+zhds@gmail.com>
Comment on lines +255 to +271
for release_group in missing:
try:
releases_object = musicbrainzngs.browse_releases(
release_group=release_group['id']
)
albums_list = releases_object['release-list']
except MusicBrainzError as err:
self._log.info(
u"Couldn't fetch info for release group '{}' - '{}'",
release_group['id'], err
)
continue

for album in albums_list:
for album_info in hooks.albums_for_id(album['id']):
item = _album_item(album_info, album_info.album_id)
print_(format(item, fmt))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, to print_ format, I need an item created by the filter at the top of the page, but the original object in the original code was the output of musicbrainzngs.browse_release_groups, these objects didn't contain any of the required attributes.
So for every missing release group I get the list of missing albums per release group.
This way I now have all the variables and can use the format function using all the placeholder already defined in the documentation.

@syco
Copy link
Author

syco commented Jan 18, 2021

This generates too many requests to musicbrainz and is far too slow to be usable.
Sorry I wasted your time, I'll be back in a few days when I have a better idea on how to proceed.
Thanks anyway.

@syco syco closed this Jan 18, 2021
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.

missing: Format CLI option (-f) does not work in album mode
3 participants