mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
- Remove music dir prefs + Add refresh album art option to album list context menu + Wire up album view context menu + Force an idle after transport commands + Add "clear cache" button
35 lines
758 B
Swift
35 lines
758 B
Swift
//
|
|
// MPDAlbumArtImageDataProvider.swift
|
|
// Persephone
|
|
//
|
|
// Created by Daniel Barber on 2/1/20.
|
|
// Copyright © 2020 Dan Barber. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import Kingfisher
|
|
|
|
public struct MPDAlbumArtImageDataProvider: ImageDataProvider {
|
|
let songUri: String
|
|
|
|
init(songUri: String, cacheKey: String? = nil) {
|
|
self.songUri = songUri
|
|
self.cacheKey = cacheKey ?? songUri
|
|
}
|
|
|
|
public var cacheKey: String
|
|
|
|
public func data(handler: @escaping (Result<Data, Error>) -> Void) {
|
|
App.mpdClient.fetchAlbumArt(songUri: songUri, imageData: nil) { imageData in
|
|
guard let imageData = imageData
|
|
else { return }
|
|
|
|
handler(.success(imageData))
|
|
}
|
|
}
|
|
|
|
public var contentURL: String? {
|
|
return songUri
|
|
}
|
|
}
|