mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 13:07:09 +01:00
add get_item convenience function to fetch Items by id
The beetfs project uses this to quickly get paths for items when reading them.
This commit is contained in:
parent
c62b1355f1
commit
7de294ba9f
1 changed files with 13 additions and 0 deletions
|
|
@ -884,6 +884,19 @@ class Library(BaseLibrary):
|
|||
" ORDER BY artist, album, disc, track"
|
||||
c = self.conn.execute(sql, subvals)
|
||||
return ResultIterator(c, self)
|
||||
|
||||
|
||||
# Convenience accessor.
|
||||
|
||||
def get_item(self, id):
|
||||
"""Fetch an Item by its ID. Returns None if no match is found.
|
||||
"""
|
||||
c = self.conn.execute("SELECT * FROM items WHERE id=?", (id,))
|
||||
it = ResultIterator(c, self)
|
||||
try:
|
||||
return it.next()
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
|
||||
# Album-level data.
|
||||
|
|
|
|||
Loading…
Reference in a new issue