Skip to content

Commit

Permalink
Merge pull request #47 from caiyue1993/bugfix/equivalent-return-type
Browse files Browse the repository at this point in the history
Fix the equivalent decode format
  • Loading branch information
rudrankriyam authored Oct 16, 2024
2 parents 6adae9e + 4076861 commit 22a9a74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ I am slowly adding all the methods used in MusadoraKit to it, so you can refer t

## Apps Using MusadoraKit

- [Music Mate](https://apps.apple.com/app/musicmate-music-map-friends/id1605379758): Meet music friends on the world map.
- [Sonar](https://apps.apple.com/ca/app/sonar-music-community/id1626147292): Music & Community. Stream, Share & Discover
- [Tuneder](https://apps.apple.com/us/app/tuneder-song-discovery/id6450867856?itsct=apps_box_badge&itscg=30200): An [open-source](https://github.com/adityasaravana/Tuneder) iOS app that helps Apple Music users discover new songs with a Tinder-like UI.
- Musadora: Apple Music client focused on playlists
Expand Down
6 changes: 3 additions & 3 deletions Sources/MusadoraKit/Equivalents/CatalogEquivalent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public extension MCatalog {
/// - Returns: The equivalent music item of type `T` found in the specified storefront.
/// - Throws:
/// - An error if the network request fails or the response cannot be decoded.
static func equivalent<T: StorefrontRequestable>(id: MusicItemID, targetStorefront: String) async throws -> T {
static func equivalent<T: StorefrontRequestable>(id: MusicItemID, targetStorefront: String) async throws -> MusicItemCollection<T> {
var components = AppleMusicURLComponents()
components.path = "catalog/\(targetStorefront)/\(T.resourcePath)/\(id)"
components.queryItems = [URLQueryItem(name: "filter[equivalents]", value: id.rawValue)]
Expand All @@ -95,7 +95,7 @@ public extension MCatalog {

let request = MusicDataRequest(urlRequest: .init(url: url))
let response = try await request.response()
let item = try JSONDecoder().decode(T.self, from: response.data)
return item
let items = try JSONDecoder().decode(MusicItemCollection<T>.self, from: response.data)
return items
}
}

0 comments on commit 22a9a74

Please sign in to comment.