Philipp Hörist pushed to branch master at gajim / gajim

Commits:

1 changed file:

Changes:

  • gajim/common/dbus/music_track.py
    ... ... @@ -32,13 +32,17 @@ MPRIS_PLAYER_PREFIX = 'org.mpris.MediaPlayer2.'
    32 32
     class MusicTrackInfo:
    
    33 33
         __slots__ = ['title', 'album', 'artist', 'duration', 'track_number',
    
    34 34
                      'paused']
    
    35
    -    def __init__(self):
    
    36
    -        self.title = None
    
    37
    -        self.album = None
    
    38
    -        self.artist = None
    
    39
    -        self.duration = None
    
    40
    -        self.track_number = None
    
    41
    -        self.paused = None
    
    35
    +    def __init__(self, meta_info, status):
    
    36
    +        self.title = meta_info.get('xesam:title')
    
    37
    +        self.album = meta_info.get('xesam:album')
    
    38
    +        # xesam:artist is always a list of strings if not None
    
    39
    +        self.artist = meta_info.get('xesam:artist')
    
    40
    +        if self.artist is not None:
    
    41
    +            self.artist = ', '.join(self.artist)
    
    42
    +
    
    43
    +        self.duration = float(meta_info.get('mpris:length', 0))
    
    44
    +        self.track_number = meta_info.get('xesam:trackNumber', 0)
    
    45
    +        self.paused = status == 'Paused'
    
    42 46
     
    
    43 47
     
    
    44 48
     class MusicTrackListener(GObject.GObject):
    
    ... ... @@ -166,22 +170,13 @@ class MusicTrackListener(GObject.GObject):
    166 170
             self.emit('music-track-changed', info)
    
    167 171
     
    
    168 172
         @staticmethod
    
    169
    -    def _properties_extract(properties):
    
    173
    +    def _get_music_info(properties):
    
    170 174
             meta = properties.get('Metadata')
    
    171 175
             if meta is None or not meta:
    
    172 176
                 return None
    
    173 177
     
    
    174
    -        info = MusicTrackInfo()
    
    175
    -        info.title = meta.get('xesam:title')
    
    176
    -        info.album = meta.get('xesam:album')
    
    177
    -        info.artist = meta.get('xesam:artist')
    
    178
    -        info.duration = float(meta.get('mpris:length', 0))
    
    179
    -        info.track_number = meta.get('xesam:trackNumber', 0)
    
    180
    -
    
    181 178
             status = properties.get('PlaybackStatus')
    
    182
    -        info.paused = status is not None and status == 'Paused'
    
    183
    -
    
    184
    -        return info
    
    179
    +        return MusicTrackInfo(meta, status)
    
    185 180
     
    
    186 181
         def get_playing_track(self, name):
    
    187 182
             '''Return a MusicTrackInfo for the currently playing
    
    ... ... @@ -208,9 +203,7 @@ class MusicTrackListener(GObject.GObject):
    208 203
                     return None
    
    209 204
                 raise
    
    210 205
             else:
    
    211
    -            info = self._properties_extract(result[0])
    
    212
    -            return info
    
    213
    -
    
    206
    +            return self._get_music_info(result[0])
    
    214 207
     
    
    215 208
     # here we test :)
    
    216 209
     if __name__ == '__main__':