[gnome-music/wip/mschraal/tageditor-13feb2020: 20/41] utils: Add getters for media track number and album disc number



commit 3dec316d40257240045c189f198d78fd446eef3e
Author: Sumaid Syed <sumaidsyed gmail com>
Date:   Sun Aug 4 22:05:49 2019 +0530

    utils: Add getters for media track number and album disc number
    
    Based on the patches by Jean Felder
    
    https://gitlab.gnome.org/GNOME/gnome-music/issues/293

 gnomemusic/utils.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/gnomemusic/utils.py b/gnomemusic/utils.py
index 65f8c606..f57eb139 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -127,6 +127,32 @@ def get_media_year(item, fill_empty=False):
     return str(date.get_year())
 
 
+def get_album_disc_nr(item):
+    """Returns the album song number associated with the media item
+
+    :param Grl.Media item: song
+    :return: The album disc number
+    :rtype: string
+    """
+    disc_nr = item.get_album_disc_number()
+    if disc_nr == 0:
+        return ""
+    return str(disc_nr)
+
+
+def get_media_track_nr(item):
+    """Returns the track number of the media item.
+
+    :param Grl.Media item: song
+    :return: The song track number
+    :rtype: string
+    """
+    track_nr = item.get_track_number()
+    if track_nr == 0:
+        return ""
+    return str(track_nr)
+
+
 def seconds_to_string(duration):
     """Convert a time in seconds to a mm:ss string
 


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