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.4.2
A swift package to facilitate Apple Music Api integration for iOS, MacOS, tvOS & watchOS projects.
⭐️ 14
🕓 10 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/jjotaum/AmuseKit.git", from: "0.4.2")

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 multiple Albums from Apple Music catalog by ids.

amuseProvider.catalog(.albums, ids: ["123", "456", "789"])
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

Retrieve multiple Artists from Apple Music catalog by ids.

amuseProvider.catalog(.artists, ids: ["123", "456", "789"])
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

Retrieve multiple Music Videos from Apple Music catalog by ids.

amuseProvider.catalog(.musicVideos, ids: ["123", "456", "789"])
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

Retrieve multiple Playlists from Apple Music catalog by ids.

amuseProvider.catalog(.playlists, ids: ["123", "456", "789"])
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

Retrieve multiple Songs from Apple Music catalog by ids.

amuseProvider.catalog(.songs, ids: ["123", "456", "789"])
    .sink { _ in
    } receiveValue: { response in
        print(response.data)
    }

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)
    }

Retrieve All User's Library Albums.

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

Retrieve All User's Library Artists.

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

Retrieve All User Library Music Videos.

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

Retrieve All User's Library Playlists.

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

Retrieve All User's Library Songs.

amuseProvider.library(.songs)
    .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)
    }

GitHub

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

Release Notes

0.4.2
10 weeks ago

What's Changed

  • Add LICENSE file
  • Fix wrong path being returned for music videos catalog requests
  • Improve custom error descriptions
  • Improve routers unit tests
  • Improve DataProvider unit tests
  • Modify methods encapsulation to public
  • Fix router generated path for catalog resources

Full Changelog: https://github.com/jjotaum/AmuseKit/compare/0.4.1...0.4.2

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