mirror of
https://github.com/beetbox/beets.git
synced 2026-03-25 23:03:48 +01:00
Added has_cover_art query
No test cases yet. Query to find albums with/without embedded cover art #2572
This commit is contained in:
parent
13665a5a55
commit
77d178808a
1 changed files with 13 additions and 0 deletions
|
|
@ -805,6 +805,7 @@ class Item(LibModel):
|
|||
getters = plugins.item_field_getters()
|
||||
getters["singleton"] = lambda i: i.album_id is None
|
||||
getters["filesize"] = Item.try_filesize # In bytes.
|
||||
getters["has_images"] = Item.has_cover_art
|
||||
return getters
|
||||
|
||||
def duplicates_query(self, fields: list[str]) -> dbcore.AndQuery:
|
||||
|
|
@ -1098,6 +1099,18 @@ class Item(LibModel):
|
|||
log.warning("could not get filesize: {}", exc)
|
||||
return 0
|
||||
|
||||
def has_cover_art(self):
|
||||
"""Check if item has embedded cover art.
|
||||
|
||||
Return True if images embedded in file, False otherwise.
|
||||
If file unreadable or no images, return False.
|
||||
"""
|
||||
try:
|
||||
mediafile = MediaFile(syspath(self.path))
|
||||
return bool(mediafile.images)
|
||||
except (UnreadableFileError, Exception):
|
||||
return False
|
||||
|
||||
# Model methods.
|
||||
|
||||
def remove(self, delete=False, with_album=True):
|
||||
|
|
|
|||
Loading…
Reference in a new issue