mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Make tracktotal an item-level field.
This fixes tracktotal being stored incorrectly for multi-disc releases where the individual discs have a different number of tracks and per_disc_numbering is enabled.
This commit is contained in:
parent
b436e75a9e
commit
c86a5f9d97
3 changed files with 39 additions and 4 deletions
|
|
@ -728,7 +728,6 @@ class Album(LibModel):
|
||||||
'year': types.PaddedInt(4),
|
'year': types.PaddedInt(4),
|
||||||
'month': types.PaddedInt(2),
|
'month': types.PaddedInt(2),
|
||||||
'day': types.PaddedInt(2),
|
'day': types.PaddedInt(2),
|
||||||
'tracktotal': types.PaddedInt(2),
|
|
||||||
'disctotal': types.PaddedInt(2),
|
'disctotal': types.PaddedInt(2),
|
||||||
'comp': types.BOOLEAN,
|
'comp': types.BOOLEAN,
|
||||||
'mb_albumid': types.STRING,
|
'mb_albumid': types.STRING,
|
||||||
|
|
@ -767,7 +766,6 @@ class Album(LibModel):
|
||||||
'year',
|
'year',
|
||||||
'month',
|
'month',
|
||||||
'day',
|
'day',
|
||||||
'tracktotal',
|
|
||||||
'disctotal',
|
'disctotal',
|
||||||
'comp',
|
'comp',
|
||||||
'mb_albumid',
|
'mb_albumid',
|
||||||
|
|
@ -797,6 +795,7 @@ class Album(LibModel):
|
||||||
# the album's directory as `path`.
|
# the album's directory as `path`.
|
||||||
getters = plugins.album_field_getters()
|
getters = plugins.album_field_getters()
|
||||||
getters['path'] = Album.item_dir
|
getters['path'] = Album.item_dir
|
||||||
|
getters['albumtotal'] = Album.tracktotal
|
||||||
return getters
|
return getters
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
|
|
@ -884,6 +883,27 @@ class Album(LibModel):
|
||||||
raise ValueError('empty album')
|
raise ValueError('empty album')
|
||||||
return os.path.dirname(item.path)
|
return os.path.dirname(item.path)
|
||||||
|
|
||||||
|
def tracktotal(self):
|
||||||
|
"""Return the total number of tracks on all discs on the album
|
||||||
|
"""
|
||||||
|
if self.disctotal == 1 or not beets.config['per_disc_numbering']:
|
||||||
|
return self.items()[0].tracktotal
|
||||||
|
|
||||||
|
counted = []
|
||||||
|
total = 0
|
||||||
|
|
||||||
|
for item in self.items():
|
||||||
|
if item.disc in counted:
|
||||||
|
continue
|
||||||
|
|
||||||
|
total += item.tracktotal
|
||||||
|
counted.append(item.disc)
|
||||||
|
|
||||||
|
if len(counted) == self.disctotal:
|
||||||
|
break
|
||||||
|
|
||||||
|
return total
|
||||||
|
|
||||||
def art_destination(self, image, item_dir=None):
|
def art_destination(self, image, item_dir=None):
|
||||||
"""Returns a path to the destination for the album art image
|
"""Returns a path to the destination for the album art image
|
||||||
for the album. `image` is the path of the image that will be
|
for the album. `image` is the path of the image that will be
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ from beets.ui import decargs, print_obj, Subcommand
|
||||||
def _missing_count(album):
|
def _missing_count(album):
|
||||||
"""Return number of missing items in `album`.
|
"""Return number of missing items in `album`.
|
||||||
"""
|
"""
|
||||||
return (album.tracktotal or 0) - len(album.items())
|
return (album.albumtotal or 0) - len(album.items())
|
||||||
|
|
||||||
|
|
||||||
def _item(track_info, album_info, album_id):
|
def _item(track_info, album_info, album_id):
|
||||||
|
|
@ -139,7 +139,7 @@ class MissingPlugin(BeetsPlugin):
|
||||||
"""
|
"""
|
||||||
item_mbids = map(lambda x: x.mb_trackid, album.items())
|
item_mbids = map(lambda x: x.mb_trackid, album.items())
|
||||||
|
|
||||||
if len([i for i in album.items()]) < album.tracktotal:
|
if len([i for i in album.items()]) < album.albumtotal:
|
||||||
# fetch missing items
|
# fetch missing items
|
||||||
# TODO: Implement caching that without breaking other stuff
|
# TODO: Implement caching that without breaking other stuff
|
||||||
album_info = hooks.album_for_mbid(album.mb_albumid)
|
album_info = hooks.album_for_mbid(album.mb_albumid)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,21 @@ Features:
|
||||||
search results you wish to see when looking up releases at MusicBrainz
|
search results you wish to see when looking up releases at MusicBrainz
|
||||||
during import. :bug:`1245`
|
during import. :bug:`1245`
|
||||||
|
|
||||||
|
Core improvements:
|
||||||
|
|
||||||
|
* The ``tracktotal`` attribute is now a *track-level field* instead of an
|
||||||
|
album-level one. This field stores the total number of tracks on the
|
||||||
|
album, or if the ``per_disc_numbering`` config option is set, the total
|
||||||
|
number of tracks on a particular medium. With the latter option the
|
||||||
|
album-level incarnation of this field could not represent releases where
|
||||||
|
the total number of tracks differs per medium ---for example 20 tracks
|
||||||
|
on medium 1 and 21 tracks on medium 2. Now, tracktotal is correctly
|
||||||
|
handled also when ``per_disc_numbering`` is set.
|
||||||
|
* Complimentary to the change for ``tracktotal`` there is now an album-level
|
||||||
|
``albumtotal`` attribute. This field always provides the total numbers of
|
||||||
|
tracks on the album. The ``per_disc_numbering`` config option has no
|
||||||
|
influence on this field.
|
||||||
|
|
||||||
Fixes:
|
Fixes:
|
||||||
|
|
||||||
* :doc:`/plugins/lyrics`: Silence a warning about insecure requests in the new
|
* :doc:`/plugins/lyrics`: Silence a warning about insecure requests in the new
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue