-
-
Notifications
You must be signed in to change notification settings - Fork 384
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
PICARD-187: Support for manually removing cover art #2377
base: master
Are you sure you want to change the base?
Conversation
I wasn't sure whether the extra test functions (for each format) will be required or not, so they are not added. However I have manually tested with all the audio files in |
picard/formats/id3.py
Outdated
@@ -659,6 +659,11 @@ def _remove_deleted_tags(self, metadata, tags): | |||
except KeyError: | |||
pass | |||
|
|||
if self.metadata.images._deleted: | |||
for key, frame in list(tags.items()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is list()
needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem to be needed. I will remove it.
picard/formats/vorbis.py
Outdated
@@ -358,6 +358,17 @@ def _remove_deleted_tags(self, metadata, tags): | |||
del tags[tag] | |||
del tags[real_name] | |||
|
|||
def _clear_cover_art(self, file): | |||
is_flac = self._File == mutagen.flac.FLAC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think is_flac
is needed here, this is used only once.
@ShubhamBhut I saw your messages about this PR on IRC, please discuss issues here instead |
Ok. I think I rushed a little and missed an important part : |
Keep in mind the displayed image is just a visual thing, a pixmap, so it has to be updated after the actual image was removed from metadata, but some care is needed because the same image might be used multiple times (in various tracks, or albums). Have a look at https://github.com/metabrainz/picard/blob/7d97ff12043b80d8e9bad80423e6d8d2effacd71/picard/util/imagelist.py#L273C1-L286 |
7ebc65d
to
f16ed33
Compare
Apologies for such late follow up, I tried a lot of different implementations. Now deletion seems to be done perfectly. But the thumbnail update still remains. For some reason, |
@@ -545,6 +550,43 @@ def load_remote_image(self, url, data): | |||
log.warning("Can't load image: %s", e) | |||
return | |||
|
|||
def delete_cover_art(self): | |||
if not self.item or not self.item.metadata.images: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an important flaw here:
- if an album was just loaded, and no image was downloaded (it has only embedded artwork), actual metadata that contains images is
self.item.orig_metadata
andself.item.metadata
is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a bit tricky to solve I think. If we remove cover art the right thing is to actually update item.metadata
. item.orig_metadata
should not be touched here, as it is the original data.
Now I think what happens is that once all images have been removed from item.metadata
the cover art box assumes there are no new images and falls back to show the images from orig_metadata
(this happens in CoverArtBox.update_metadata
.
The correct thing then would be to not do this fallback if self.item.metadata.images.delete == True
.
d3df50e
to
d328ea3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment on how I think the cover art box display issue needs to be solved. Otherwise this is looking good now.
It's really one of the issues that looks simple first but is rather tricky to get right.
@@ -545,6 +550,43 @@ def load_remote_image(self, url, data): | |||
log.warning("Can't load image: %s", e) | |||
return | |||
|
|||
def delete_cover_art(self): | |||
if not self.item or not self.item.metadata.images: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a bit tricky to solve I think. If we remove cover art the right thing is to actually update item.metadata
. item.orig_metadata
should not be touched here, as it is the original data.
Now I think what happens is that once all images have been removed from item.metadata
the cover art box assumes there are no new images and falls back to show the images from orig_metadata
(this happens in CoverArtBox.update_metadata
.
The correct thing then would be to not do this fallback if self.item.metadata.images.delete == True
.
@@ -33,6 +33,7 @@ def __init__(self, iterable=()): | |||
self._images = list(iterable) | |||
self._hash_dict = {} | |||
self._changed = True | |||
self._deleted = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a deleted
property to the class to access this internal variable. Then other code does not need to access a variable that is supposed to be internal to the imagelist implementation.
@property
def deleted(self):
return self._deleted
Added PICARD-2865 to cover updating the documentation. |
@ShubhamBhut, you should probably update the PICARD-187 ticket to show it being assigned to you so nobody else accidentally starts working on it. |
picard/ui/coverartbox.py
Outdated
if not metadata or not metadata.images: | ||
return | ||
|
||
debug_info = "Deleting %r from %r" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be "Deleted %r from %r", since it isn't logged until the deletion is complete?
picard/ui/coverartbox.py
Outdated
image_delete(item, selected_image) | ||
item.update() | ||
else: | ||
debug_info = "Dropping %r to %r is not handled" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency in terminology, would it be more appropriate to change this to something like "Unable to delete %r from %r"?
PICARD-187: Support for manually removing cover art finishing PICARD-187
PICARD-187: Support for manually removing cover art
finishing PICARD-187
Summary
Problem
Solution
Add support in all formats to allow to delete cover art tags, and modify ImageList to allow to remove desired image from ImageList
Action