[gnome-music] widgets: Use track number tags



commit d10e689c0ccf7a49bfc3b85649a3f8ff13933293
Author: Marinus Schraal <mschraal src gnome org>
Date:   Tue Oct 25 14:28:14 2016 +0200

    widgets: Use track number tags
    
    Music was using a count system to calculate the track number of songs,
    resulting in incorrect track numbers if songs were missing and on
    multi-disc albums. Use Grilo track number property instead and have
    tracker look them up from tags.

 gnomemusic/grilo.py                     |    1 +
 gnomemusic/query.py                     |    1 +
 gnomemusic/widgets/disclistboxwidget.py |    2 +-
 3 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index c9e816d..d90d841 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -56,6 +56,7 @@ class Grilo(GObject.GObject):
         Grl.METADATA_KEY_LYRICS,
         Grl.METADATA_KEY_THUMBNAIL,
         Grl.METADATA_KEY_TITLE,
+        Grl.METADATA_KEY_TRACK_NUMBER,
         Grl.METADATA_KEY_URL
     ]
 
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index f990c51..e91e4bd 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -272,6 +272,7 @@ class Query():
         nmm:artistName(nmm:performer(?song)) AS ?artist
         nie:title(nmm:musicAlbum(?song)) AS ?album
         nfo:duration(?song) AS ?duration
+        nmm:trackNumber(?song) AS ?track_number
         nmm:setNumber(nmm:musicAlbumDisc(?song)) AS ?album_disc_number
         IF(bound(?tag), 'truth!', '') AS ?lyrics
     WHERE {
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index 3b82e52..e5d81c9 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -304,7 +304,7 @@ class DiscBox(Gtk.Box):
 
         song_widget.number = builder.get_object('num')
         song_widget.number.set_markup(
-            '<span color=\'grey\'>{}</span>'.format(len(self._songs)))
+            '<span color=\'grey\'>{}</span>'.format(track.get_track_number()))
         song_widget.number.set_no_show_all(True)
 
         song_widget.title = builder.get_object('title')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]