-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3e5c4f
commit d7e67d7
Showing
6 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import com.vanniktech.maven.publish.JavadocJar | ||
import com.vanniktech.maven.publish.KotlinMultiplatform | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
plugins { | ||
`lavalink-module` | ||
`lavalink-publishing` | ||
kotlin("plugin.serialization") | ||
} | ||
|
||
kotlin { | ||
jvm { | ||
compilations.all { | ||
compilerOptions.configure { | ||
jvmTarget = JvmTarget.JVM_17 | ||
} | ||
} | ||
} | ||
|
||
sourceSets { | ||
all { | ||
languageSettings.optIn("kotlin.contracts.ExperimentalContracts") | ||
languageSettings.optIn("dev.schlaubi.lavakord.PluginApi") | ||
languageSettings.optIn("dev.schlaubi.lavakord.UnsafeRestApi") | ||
} | ||
commonMain { | ||
dependencies { | ||
api(projects.core) | ||
implementation(libs.ktor.client.resources) | ||
api(libs.lyrics.protocol) | ||
} | ||
} | ||
} | ||
} | ||
|
||
mavenPublishing { | ||
configure(KotlinMultiplatform(JavadocJar.Dokka("dokkaHtml"))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package dev.schlaubi.lavakord.plugins.lyrics | ||
|
||
import dev.schlaubi.lavakord.Plugin | ||
import kotlinx.serialization.json.Json | ||
|
||
/** | ||
* Bindings for the [Lyrics plugin](https://github.com/DRSchlaubi/lyrics.kt). | ||
* | ||
* ```kotlin | ||
* plugins { | ||
* install(Lyrics) | ||
* } | ||
* ``` | ||
*/ | ||
public object Lyrics : Plugin { | ||
override val name: String = "lyrics" | ||
override val version: String = "1.0.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dev.schlaubi.lavakord.plugins.lyrics.rest | ||
|
||
import dev.schlaubi.lavakord.audio.Node | ||
import dev.schlaubi.lavakord.audio.player.Player | ||
import dev.schlaubi.lavakord.audio.player.guildId | ||
import dev.schlaubi.lavakord.audio.player.node | ||
import dev.schlaubi.lavakord.rest.get | ||
import dev.schlaubi.lyrics.protocol.Lyrics | ||
import dev.schlaubi.lyrics.protocol.SearchTrack | ||
|
||
/** | ||
* Requests the lyrics by [videoId]. | ||
*/ | ||
public suspend fun Node.requestLyrics(videoId: String): Lyrics = get(LyricsRoute.Video(videoId)) | ||
|
||
/** | ||
* Searches for [query]. | ||
*/ | ||
public suspend fun Node.searchLyrics(query: String): List<SearchTrack> = get(LyricsRoute.Search(query)) | ||
|
||
/** | ||
* Requests the lyrics of the currently playing track. | ||
*/ | ||
public suspend fun Player.requestLyrics(): Lyrics = node.get(LyricsRoute.CurrentLyrics(node.sessionId, guildId)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@file:Suppress("KDocMissingDocumentation") | ||
|
||
package dev.schlaubi.lavakord.plugins.lyrics.rest | ||
|
||
import dev.schlaubi.lavakord.rest.routes.V4Api | ||
import io.ktor.resources.* | ||
|
||
@Resource("lyrics") | ||
internal data class LyricsRoute(val parent: V4Api = V4Api()) { | ||
|
||
@Resource("lyrics/search/{query}") | ||
data class Search(val query: String, val parent: LyricsRoute = LyricsRoute()) | ||
|
||
@Resource("{videoId}") | ||
data class Video(val videoId: String, val parent: LyricsRoute = LyricsRoute()) | ||
|
||
@Resource("lyrics") | ||
data class CurrentLyrics(val players: V4Api.Sessions.Specific.Players.Specific) { | ||
constructor(sessionId: String, guildId: ULong) : this( | ||
V4Api.Sessions.Specific.Players.Specific( | ||
guildId, | ||
sessionId | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters