Started off well
This commit is contained in:
31
Sources/MusicBrainzExe/main.swift
Normal file
31
Sources/MusicBrainzExe/main.swift
Normal file
@@ -0,0 +1,31 @@
|
||||
import Foundation
|
||||
import MusicBrainz
|
||||
|
||||
let client = MusicBrainzClient(
|
||||
clientAgent: .init(appName: "MusicD", version: "0.0.1", email: "test@gmail.com"))
|
||||
|
||||
do {
|
||||
print("--- Artist Search: 'Michael Jackson' ---")
|
||||
let artistSearch = try await client.search(
|
||||
.artist(name: "Michael Jackson", gender: .male, country: .us, type: .person), limit: 5)
|
||||
print("Total results: \(artistSearch.count)")
|
||||
for artist in artistSearch.entities {
|
||||
print("- \(artist.name) (\(artist.id))")
|
||||
if let disambiguation = artist.disambiguation {
|
||||
print(" (\(disambiguation))")
|
||||
}
|
||||
}
|
||||
|
||||
print("\n--- Release Search: 'Thriller' ---")
|
||||
let releaseSearch = try await client.search(.release(title: "Thriller"), limit: 5)
|
||||
print("Total results: \(releaseSearch.count)")
|
||||
for release in releaseSearch.entities {
|
||||
print("- \(release.title) (\(release.id))")
|
||||
if let date = release.date {
|
||||
print(" Date: \(date)")
|
||||
}
|
||||
}
|
||||
|
||||
} catch {
|
||||
print("Error: \(error)")
|
||||
}
|
||||
Reference in New Issue
Block a user