I think we're done
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
public struct Artist: MusicBrainzSearchable {
|
||||
public struct Artist: MusicBrainzSearchable, Identifiable, Hashable, Equatable {
|
||||
public static let entityType: MusicBrainzEntity = .artist
|
||||
|
||||
public let id: String
|
||||
@@ -11,9 +11,11 @@ public struct Artist: MusicBrainzSearchable {
|
||||
public let disambiguation: String?
|
||||
public let lifeSpan: LifeSpan?
|
||||
public let relations: [Relation]?
|
||||
public let releases: [Release]?
|
||||
public let releaseGroups: [ReleaseGroup]?
|
||||
public let score: Int?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
enum CodingKeys: String, CodingKey, Hashable, Equatable {
|
||||
case id
|
||||
case name
|
||||
case sortName = "sort-name"
|
||||
@@ -22,6 +24,8 @@ public struct Artist: MusicBrainzSearchable {
|
||||
case disambiguation
|
||||
case lifeSpan = "life-span"
|
||||
case relations
|
||||
case releases
|
||||
case releaseGroups = "release-groups"
|
||||
case score
|
||||
}
|
||||
|
||||
@@ -31,7 +35,15 @@ public struct Artist: MusicBrainzSearchable {
|
||||
for rel in relations {
|
||||
if rel.type == "image" || rel.type == "wikimedia commons" {
|
||||
if let resource = rel.url?.resource {
|
||||
return URL(string: resource)
|
||||
var urlString = resource
|
||||
// Handle Wikimedia Commons page URLs by converting to Special:FilePath
|
||||
if urlString.contains("commons.wikimedia.org/wiki/File:") {
|
||||
let filename = urlString.components(separatedBy: "/wiki/File:").last ?? ""
|
||||
if !filename.isEmpty {
|
||||
urlString = "https://commons.wikimedia.org/wiki/Special:FilePath/\(filename)"
|
||||
}
|
||||
}
|
||||
return URL(string: urlString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user