I think we're done
This commit is contained in:
@@ -12,32 +12,42 @@ do {
|
||||
if let artist = artistSearch.entities.first {
|
||||
print("- Found Artist: \(artist.name) (\(artist.id))")
|
||||
|
||||
// Fetch artist with URL relationships to find an image
|
||||
print(" Fetching artist details (with url-rels)...")
|
||||
let detailedArtist = try await client.fetch(.artist, id: artist.id, includes: ["url-rels"])
|
||||
// Fetch artist with URL relationships and releases
|
||||
print(" Fetching artist details (with url-rels + releases)...")
|
||||
let detailedArtist = try await client.fetch(
|
||||
.artist, id: artist.id, includes: ["url-rels", "releases"])
|
||||
|
||||
if let imageURL = detailedArtist.imageURL {
|
||||
print(" Artist Image URL: \(imageURL)")
|
||||
} else {
|
||||
print(" No image found for artist.")
|
||||
print(" Artist Image Shortcut: \(imageURL)")
|
||||
}
|
||||
}
|
||||
|
||||
print("\n--- Release Search: 'Thriller' ---")
|
||||
let releaseSearch = try await client.search(.release(title: "Thriller"), limit: 1)
|
||||
|
||||
if let release = releaseSearch.entities.first {
|
||||
print("- Found Release: \(release.title) (\(release.id))")
|
||||
|
||||
// Fetch cover art from Cover Art Archive
|
||||
print(" Fetching cover art...")
|
||||
do {
|
||||
let coverArt = try await client.fetchCoverArt(releaseId: release.id)
|
||||
if let front = coverArt.frontImage {
|
||||
print(" Front Cover Image: \(front.image)")
|
||||
print(" Thumbnails: \(front.thumbnails)")
|
||||
if let releases = detailedArtist.releases {
|
||||
print(" Releases count: \(releases.count)")
|
||||
for release in releases.prefix(5) {
|
||||
print(" - \(release.title) (\(release.id))")
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch tracks for the first release
|
||||
if let release = detailedArtist.releases?.first {
|
||||
print("\n--- Fetching tracks for release: '\(release.title)' ---")
|
||||
let detailedRelease = try await client.fetch(
|
||||
.release, id: release.id, includes: ["recordings"])
|
||||
if let media = detailedRelease.media {
|
||||
for medium in media {
|
||||
print(
|
||||
" Medium \(medium.position) (\(medium.format?.rawValue ?? "Unknown format")):"
|
||||
)
|
||||
if let tracks = medium.tracks {
|
||||
for track in tracks {
|
||||
print(" \(track.number). \(track.title)")
|
||||
if let youtubeURL = track.recording?.youtubeURL {
|
||||
print(" YouTube: \(youtubeURL)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
print(" Could not fetch cover art: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user