mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Deal with album artist when dragging songs
This commit is contained in:
parent
32a4e38bd1
commit
c1181fa283
@ -83,7 +83,7 @@ extension AlbumDetailView: NSTableViewDelegate {
|
||||
owner: self
|
||||
) as! NSTableCellView
|
||||
|
||||
if song.artist != song.album.artist {
|
||||
if song.artist != song.albumArtist {
|
||||
let string = NSMutableAttributedString()
|
||||
string.append(NSAttributedString(string: song.title))
|
||||
string.append(NSAttributedString(string: " – " + song.artist, attributes: [.foregroundColor: NSColor.secondaryLabelColor]))
|
||||
|
||||
@ -50,6 +50,7 @@ class AlbumTracksDataSource: NSObject, NSTableViewDataSource {
|
||||
type: .albumSongItem(song.mpdSong.uriString),
|
||||
title: song.title,
|
||||
artist: song.artist,
|
||||
albumArtist: song.albumArtist,
|
||||
album: song.album.title,
|
||||
uri: song.mpdSong.uriString
|
||||
),
|
||||
@ -70,10 +71,11 @@ class AlbumTracksDataSource: NSObject, NSTableViewDataSource {
|
||||
) { draggingItem, index, stop in
|
||||
guard let item = draggingItem.item as? NSPasteboardItem,
|
||||
let draggedSong = item.draggedSong(forType: .songPasteboardType),
|
||||
case let (title, artist, album, uri) = (
|
||||
case let (title, artist, album, albumArtist, uri) = (
|
||||
draggedSong.title,
|
||||
draggedSong.artist,
|
||||
draggedSong.album,
|
||||
draggedSong.albumArtist,
|
||||
draggedSong.uri
|
||||
)
|
||||
else { return }
|
||||
@ -83,6 +85,7 @@ class AlbumTracksDataSource: NSObject, NSTableViewDataSource {
|
||||
let draggedSongView = DraggedSongView(
|
||||
title: title,
|
||||
artist: artist,
|
||||
albumArtist: albumArtist,
|
||||
album: album,
|
||||
uri: uri
|
||||
)
|
||||
|
||||
@ -44,6 +44,7 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
||||
type: .queueItem(queueItem.queuePos),
|
||||
title: queueItem.song.title,
|
||||
artist: queueItem.song.artist,
|
||||
albumArtist: queueItem.song.albumArtist,
|
||||
album: queueItem.song.album.title,
|
||||
uri: queueItem.song.mpdSong.uriString
|
||||
),
|
||||
@ -129,10 +130,11 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
||||
guard let item = draggingItem.item as? NSPasteboardItem,
|
||||
let data = item.data(forType: .songPasteboardType),
|
||||
let draggedSong = try? PropertyListDecoder().decode(DraggedSong.self, from: data),
|
||||
case let (title, artist, album, uri) = (
|
||||
case let (title, artist, album, albumArtist, uri) = (
|
||||
draggedSong.title,
|
||||
draggedSong.artist,
|
||||
draggedSong.album,
|
||||
draggedSong.albumArtist,
|
||||
draggedSong.uri
|
||||
)
|
||||
else { return }
|
||||
@ -142,6 +144,7 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
||||
let draggedSongView = DraggedSongView(
|
||||
title: title,
|
||||
artist: artist,
|
||||
albumArtist: albumArtist,
|
||||
album: album,
|
||||
uri: uri
|
||||
)
|
||||
|
||||
@ -16,12 +16,14 @@ class DraggedSongView: NSViewController {
|
||||
|
||||
private let songTitle: String
|
||||
private let songArtist: String
|
||||
private let songAlbumArtist: String
|
||||
private let songAlbum: String
|
||||
private let songUri: String
|
||||
|
||||
init(title: String, artist: String, album: String, uri: String) {
|
||||
init(title: String, artist: String, albumArtist: String, album: String, uri: String) {
|
||||
songTitle = title
|
||||
songArtist = artist
|
||||
songAlbumArtist = albumArtist
|
||||
songAlbum = album
|
||||
songUri = uri
|
||||
|
||||
@ -60,7 +62,7 @@ class DraggedSongView: NSViewController {
|
||||
}
|
||||
|
||||
func setCoverArt() {
|
||||
let mpdAlbum = MPDClient.MPDAlbum(title: songAlbum, artist: songArtist)
|
||||
let mpdAlbum = MPDClient.MPDAlbum(title: songAlbum, artist: songAlbumArtist)
|
||||
|
||||
let provider = MPDAlbumArtImageDataProvider(
|
||||
songUri: songUri,
|
||||
|
||||
@ -73,7 +73,7 @@ extension MPDClient {
|
||||
|
||||
let mpdAlbum = MPDAlbum(
|
||||
title: mpdSong.album.title,
|
||||
artist: mpdSong.album.artist,
|
||||
artist: mpdSong.albumArtist,
|
||||
firstSong: mpdSong,
|
||||
date: mpdSong.date
|
||||
)
|
||||
|
||||
@ -10,6 +10,7 @@ struct DraggedSong: Codable {
|
||||
var type: DraggedSongType
|
||||
var title: String
|
||||
var artist: String
|
||||
var albumArtist: String
|
||||
var album: String
|
||||
var uri: String
|
||||
}
|
||||
|
||||
@ -25,6 +25,10 @@ struct Song {
|
||||
return mpdSong.getTag(.artist)
|
||||
}
|
||||
|
||||
var albumArtist: String {
|
||||
return mpdSong.getTag(.albumArtist)
|
||||
}
|
||||
|
||||
var duration: Time {
|
||||
return Time(timeInSeconds: mpdSong.duration)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user