[gnome-music/songeditor-tracker3: 2/32] utils: Add getters for media track number and album disc number



commit bca090904c648e1ba8c7d4f56d9bb2d1679fec2a
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 13c611ee..63a9ea1b 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -128,6 +128,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]