Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jjotaum/amusekit
A swift package to facilitate Apple Music API integration for iOS, MacOS, tvOS & watchOS projects.
https://github.com/jjotaum/amusekit
ios macos musickit swift tvos watchos
Last synced: 24 days ago
JSON representation
A swift package to facilitate Apple Music API integration for iOS, MacOS, tvOS & watchOS projects.
- Host: GitHub
- URL: https://github.com/jjotaum/amusekit
- Owner: jjotaum
- License: mit
- Created: 2020-06-16T01:19:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-23T19:59:10.000Z (over 1 year ago)
- Last Synced: 2024-10-09T16:27:17.253Z (about 1 month ago)
- Topics: ios, macos, musickit, swift, tvos, watchos
- Language: Swift
- Homepage:
- Size: 142 KB
- Stars: 15
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AmuseKit
A swift package to facilitate Apple Music Api integration for iOS, MacOS, tvOS & watchOS projects.## USAGE
### Import
```swift
import AmuseKit
```### Init AmuseKit provider.
You can initialize AmuseKit using a StorageConfiguration that specifies service name and keys that will be used to save developer token & user token on keychain.
```swift
let configuration = AmuseKit.StorageConfiguration(serviceName: "KEYCHAIN_SERVICE_NAME",
developerTokenKey: "DEV_TOKEN_KEYCHAIN_KEY",
userTokenKey: "USER_TOKEN_KEYCHAIN_KEY")
let amuseProvider = AmuseKit.DataProvider(configuration)
amuseProvider.setDeveloperToken("YOUR_DEV_TOKEN")
```### Set User Token.
```swift
amuseProvider.setUserToken("USER_TOKEN")
```### Set User Country Code.
```swift
amuseProvider.setUserCountryCode("USER_COUNTRY_CODE")
```### Retrieve Apple Music catalog resources by ids.
Supported values are: `albums, artists, musicVideos, playlists, songs`.
```swift
let response = try await amuseProvider.catalog(.albums, ids: ["123", "456", "789"])
print(response.data)
``````swift
amuseProvider.catalog(.albums, ids: ["123", "456", "789"])
.sink { _ in
} receiveValue: { response in
print(response.data)
}
```### Search on Apple Music catalog.
```swift
let response = try await amuseProvider.catalogSearch(searchTerm: "YOUR_QUERY_TEXT")
print(response.results?.albums)
print(response.results?.artists)
print(response.results?.musicVideos)
print(response.results?.playlists)
print(response.results?.songs)
print(response.results?.stations)
``````swift
amuseProvider.catalogSearch(searchTerm: "YOUR_QUERY_TEXT")
.sink { _ in
} receiveValue: { response in
// content will be found under results properties.
print(response.results?.albums)
print(response.results?.artists)
print(response.results?.musicVideos)
print(response.results?.playlists)
print(response.results?.songs)
print(response.results?.stations)
}
```### Search on Apple Music catalog for specific resources types.
```swift
let response = try await amuseProvider.catalogSearch([.playlists, .songs], searchTerm: "YOUR_QUERY_TEXT")
print(response.results?.playlists)
print(response.results?.songs)
``````swift
amuseProvider.catalogSearch([.playlists, .songs], searchTerm: "YOUR_QUERY_TEXT")
.sink { _ in
} receiveValue: { response in
print(response.results?.playlists)
print(response.results?.songs)
}
```### Retrieve User Library resources.
Supported values are: `albums, artists, musicVideos, playlists, songs`.
```swift
let response = try await dataProvider.library(.albums)
print(response.data)
``````swift
amuseProvider.library(.albums)
.sink { _ in
} receiveValue: { response in
print(response.data)
}
```### Search on User Library.
```swift
let response = try await amuseProvider.librarySearch(searchTerm: "YOUR_QUERY_TEXT")
print(response.results?.albums)
print(response.results?.artists)
print(response.results?.musicVideos)
print(response.results?.playlists)
print(response.results?.songs)
``````swift
amuseProvider.librarySearch(searchTerm: "YOUR_QUERY_TEXT")
.sink { _ in
} receiveValue: { response in
// content will be found under results properties.
print(response.results?.albums)
print(response.results?.artists)
print(response.results?.musicVideos)
print(response.results?.playlists)
print(response.results?.songs)
}
```### Search on User Library for specific resources types.
```swift
let response = try await amuseProvider.librarySearch([.playlists, .songs], searchTerm: "YOUR_QUERY_TEXT")
print(response.results?.playlists)
print(response.results?.songs)
``````swift
amuseProvider.librarySearch([.playlists, .songs], searchTerm: "YOUR_QUERY_TEXT")
.sink { _ in
} receiveValue: { response in
print(response.results?.playlists)
print(response.results?.songs)
}
```