I think we're done
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
public struct Recording: MusicBrainzSearchable {
|
||||
public struct Recording: MusicBrainzSearchable, Identifiable, Hashable, Equatable {
|
||||
public static let entityType: MusicBrainzEntity = .recording
|
||||
|
||||
public let id: String
|
||||
@@ -12,7 +12,7 @@ public struct Recording: MusicBrainzSearchable {
|
||||
public let relations: [Relation]?
|
||||
public let score: Int?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
enum CodingKeys: String, CodingKey, Hashable, Equatable {
|
||||
case id
|
||||
case title
|
||||
case length
|
||||
@@ -22,4 +22,16 @@ public struct Recording: MusicBrainzSearchable {
|
||||
case relations
|
||||
case score
|
||||
}
|
||||
|
||||
public var youtubeURL: URL? {
|
||||
guard let relations else { return nil }
|
||||
for rel in relations {
|
||||
if let resource = rel.url?.resource {
|
||||
if rel.type == "youtube" || resource.contains("youtube.com") || resource.contains("youtu.be") {
|
||||
return URL(string: resource)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user