[gnome-music/wip/jfelder/songeditor-gtk4: 3/32] utils: Add getters for media track number and album disc number




commit feeafba3429c662eb9ba852770fb933579d11288
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 | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/gnomemusic/utils.py b/gnomemusic/utils.py
index a8989fe8e..ce8b8189e 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -157,6 +157,34 @@ def get_media_year(item: Grl.Media, fill_empty: bool = False) -> str:
     return str(date.get_year())
 
 
+def get_album_disc_nr(item: Grl.Media) -> str:
+    """Returns the album song number of the media item.
+
+    :param Grl.Media item: A Grilo Media object
+    :return: The album disc number
+    :rtype: str
+    """
+    disc_nr = item.get_album_disc_number()
+    if disc_nr == 0:
+        return ""
+
+    return str(disc_nr)
+
+
+def get_media_track_nr(item: Grl.Media) -> str:
+    """Returns the track number of the media item.
+
+    :param Grl.Media item: A Grilo Media object
+    :return: The song track number
+    :rtype: str
+    """
+    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]