Add support for “albumartist” tag (resolve #27)

This commit is contained in:
coderkun 2017-06-04 15:39:07 +02:00
commit c451c32437
7 changed files with 97 additions and 36 deletions

View file

@ -628,6 +628,8 @@ class Client(Base):
track.set_length(song['time'])
if 'date' in song:
track.set_date(song['date'])
if 'albumartist' in song:
track.set_albumartists(song['albumartist'])
return track
@ -653,6 +655,7 @@ class MCGAlbum:
def __init__(self, title, host, image_dir):
self._artists = []
self._albumartists = []
self._pathes = []
if type(title) is list:
title = title[0]
@ -672,6 +675,14 @@ class MCGAlbum:
def get_artists(self):
if self._albumartists:
return [artist for artist in self._artists if artist not in self._albumartists]
return self._artists
def get_albumartists(self):
if self._albumartists:
return self._albumartists
return self._artists
@ -699,6 +710,9 @@ class MCGAlbum:
for artist in track.get_artists():
if artist not in self._artists:
self._artists.append(artist)
for artist in track.get_albumartists():
if artist not in self._albumartists:
self._albumartists.append(artist)
if track.get_date() is not None and track.get_date() not in self._dates:
self._dates.append(track.get_date())
path = os.path.dirname(track.get_file())
@ -849,6 +863,7 @@ class MCGTrack:
file = file[0]
self._file = file
self._albumartists = []
self._track = None
self._length = 0
self._date = None
@ -859,6 +874,20 @@ class MCGTrack:
def get_artists(self):
if self._albumartists:
return [artist for artist in self._artists if artist not in self._albumartists]
return self._artists
def set_albumartists(self, artists):
if type(artists) is not list:
artists = [artists]
self._albumartists = artists
def get_albumartists(self):
if self._albumartists:
return self._albumartists
return self._artists
@ -915,6 +944,7 @@ class MCGPlaylistTrack(MCGTrack):
track.get_title(),
track.get_file()
)
self.set_albumartists(track.get_albumartists())
self.set_track(track.get_track())
self.set_length(track.get_length())
self.set_date(track.get_date())

View file

@ -3,6 +3,7 @@
import gi
gi.require_version('Gtk', '3.0')
import locale
import os
import urllib
@ -54,6 +55,26 @@ class Utils:
return pixbuf
def create_artists_label(album):
label = ', '.join(album.get_albumartists())
if album.get_artists():
label = locale.gettext("{} feat. {}").format(
label,
", ".join(album.get_artists())
)
return label
def create_track_title(track):
title = track.get_title()
if track.get_artists():
title = locale.gettext("{} feat. {}").format(
title,
", ".join(track.get_artists())
)
return title
class TracklistSize:

View file

@ -907,7 +907,7 @@ class CoverPanel(GObject.GObject):
)
self._album_artist_label.set_markup(
GObject.markup_escape_text(
', '.join(album.get_artists())
', '.join(album.get_albumartists())
)
)
@ -985,7 +985,7 @@ class CoverPanel(GObject.GObject):
cur_length,
Gtk.PositionType.RIGHT,
GObject.markup_escape_text(
track.get_title()
Utils.create_track_title(track)
)
)
length = length + track.get_length()
@ -1138,7 +1138,7 @@ class PlaylistPanel(GObject.GObject):
# Set labels
self._standalone_title.set_text(album.get_title())
self._standalone_artist.set_text(", ".join(album.get_artists()))
self._standalone_artist.set_text(", ".join(album.get_albumartists()))
# Show panel
self._open_standalone()
@ -1213,7 +1213,7 @@ class PlaylistPanel(GObject.GObject):
GObject.markup_escape_text("\n".join([
album.get_title(),
', '.join(album.get_dates()),
', '.join(album.get_artists())
Utils.create_artists_label(album)
])),
album.get_hash()
])
@ -1454,7 +1454,7 @@ class LibraryPanel(GObject.GObject):
# Set labels
self._standalone_title.set_text(album.get_title())
self._standalone_artist.set_text(", ".join(album.get_artists()))
self._standalone_artist.set_text(", ".join(album.get_albumartists()))
# Show panel
self._open_standalone()
@ -1581,7 +1581,7 @@ class LibraryPanel(GObject.GObject):
GObject.markup_escape_text("\n".join([
album.get_title(),
', '.join(album.get_dates()),
', '.join(album.get_artists())
Utils.create_artists_label(album)
])),
hash
])