Swiftpack.co - jjotaum/AmuseKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by jjotaum.
jjotaum/AmuseKit 0.3.0
A swift package to facilitate Apple Music Api integration for iOS, MacOS, tvOS & watchOS projects.
⭐️ 11
🕓 18 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/jjotaum/AmuseKit.git", from: "0.3.0")

AmuseKit

A swift package to facilitate Apple Music Api integration for iOS, MacOS, tvOS & watchOS projects.

USAGE

Import

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.

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.

amuseProvider.setUserToken("USER_TOKEN")

Set User Country Code.

amuseProvider.setUserCountryCode("USER_COUNTRY_CODE")

Retrieve All User's Library Playlists.

amuseProvider.libraryPlaylists()
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

Retrieve All User's Library Albums.

amuseProvider.libraryAlbums()
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

Retrieve All User's Library Artists.

amuseProvider.libraryArtists()
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

Retrieve All User's Library Songs.

amuseProvider.librarySongs()
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

Retrieve All User Library Music Videos.

amuseProvider.libraryMusicVideos()
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

Search on User's Library.

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?.playlists)
        print(response.results?.songs)
    }

Search on User's Library for specific types.

amuseProvider.librarySearch([.playlists, .songs], searchTerm: "YOUR_QUERY_TEXT")
    .sink { _ in
    } receiveValue: { response in
        print(response.results?.playlists)
        print(response.results?.songs)
    }

Search on Apple Music catalog.

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?.playlists)
        print(response.results?.songs)
    }

Search on Apple Music catalog for specific types.

amuseProvider.catalogSearch([.playlists, .songs], searchTerm: "YOUR_QUERY_TEXT")
    .sink { _ in
    } receiveValue: { response in
        print(response.results?.playlists)
        print(response.results?.songs)
    }

GitHub

link
Stars: 11
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.3.0
18 weeks ago
  • Add support to retrieve library artists
  • Add support to retrieve library music videos
  • Update resources models to match apple revision (Some model were not matching Apple specs anymore).
  • Update library search logic to make it match new Apple API's updates

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics