Skip to content

A Kotlin Multiplatform library for (unofficially) using the YouTube Music API, optionally with user authentication.

License

Notifications You must be signed in to change notification settings

KuwaLee/ytm-kt

 
 

Repository files navigation

ytm-kt

A Kotlin Multiplatform library for (unofficially) using the YouTube Music API, optionally with user authentication. This library was originally a part of SpMp.

Setup

ytm-kt currently supports the following Kotlin platforms:

  • JVM
    • Android
    • Desktop
  • Native
    • Linux x86_64
    • Linux arm64
    • Windows x86_64

Gradle:

  1. Add the Maven Central repository to your dependency resolution configuration
repositories {
  mavenCentral()
}
  1. To your dependencies, add the line corresponding to the target platform (replace <version> with the desired ytm-kt version)
  • JVM (Android): implementation("dev.toastbits.ytmkt:ytmkt-android:<version>")
  • JVM (desktop): implementation("dev.toastbits.ytmkt:ytmkt-jvm:<version>")
  • Native (Linux x86_64): implementation("dev.toastbits.ytmkt:ytmkt-linuxx64:<version>")
  • Native (Linux arm64): implementation("dev.toastbits.ytmkt:ytmkt-linuxarm64:<version>")
  • Native (Windows x86_64): implementation("dev.toastbits.ytmkt:ytmkt-mingwx64:<version>")

Usage

API endpoints are accessed through the YtmApi interface. To use this interface, either implement it yourself or use one of the built-in implementations:

Example usage

// Initialise the Youtubei api implementation
val api: YtmApi =
    YoutubeiApi(
        data_language = "en-GB" // The language we want data (such as song names) to be in
    )

// Download the home page recommendations feed
val song_feed_result: Result<SongFeedLoadResult> = api.SongFeed.getSongFeed()

// Print feed row titles in our desired language
for (layout in song_feed_result.getOrThrow().layouts) {
  val title_text: String = layout.title.getString("en-GB") // The language we want UI strings to be in
  println("Layout $title_text has ${layout.items.size} items")
}

See the sample application for a more detailed example

Documentation

TODO

About

A Kotlin Multiplatform library for (unofficially) using the YouTube Music API, optionally with user authentication.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 100.0%