Skip to content

Commit

Permalink
add protocol module with types (#122)
Browse files Browse the repository at this point in the history
* add protocol module with types

* update yarn.lock

* maybe fix publishing of protocol module

* add default values, make some fields nullable & rename ExtendedAudioTrack -> ExtendedTrackInfo

* remove unused dependency & update readme

* revert yarn.lock change
  • Loading branch information
topi314 authored Oct 15, 2023
1 parent a04fd24 commit 4d8a476
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ repositories {
dependencies {
implementation "com.github.topi314.lavasrc:lavasrc:x.y.z"
implementation "com.github.topi314.lavasrc:lavasrc-protocol:x.y.z"
}
```
</details>
Expand All @@ -64,6 +65,11 @@ dependencies {
<artifactId>lavasrc</artifactId>
<version>x.y.z</version>
</dependency>
<dependency>
<groupId>com.github.topi314.lavasrc</groupId>
<artifactId>lavasrc-protocol</artifactId>
<version>x.y.z</version>
</dependency>
</dependencies>
```
</details>
Expand Down Expand Up @@ -253,7 +259,7 @@ LavaSrc adds the following fields to tracks & playlists in Lavalink
| artistUrl | ?string | The url of the artist |
| artistArtworkUrl | ?string | The url of the artist artwork |
| previewUrl | ?string | The url of the preview |
| isPreview | ?bool | Whether the track is a preview |
| isPreview | bool | Whether the track is a preview |

#### Playlist

Expand Down
38 changes: 38 additions & 0 deletions protocol/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
plugins {
id "java-library"
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
}

archivesBaseName = "lavasrc-protocol"

java {
sourceCompatibility = JavaVersion.VERSION_11
}

kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
js(IR) {
nodejs()
}

publishing {
publications {
maven(MavenPublication) {
artifactId archivesBaseName
}
}
}

sourceSets {
commonMain {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.github.topi314.lavasrc.protocol

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ExtendedPlaylistInfo(
val type: Type = Type.PLAYLIST,
val url: String? = null,
val artworkUrl: String? = null,
val author: String? = null,
val totalTracks: Int? = null,
) {
/**
* The type of the originating track list.
*/
@Serializable
enum class Type {
/**
* A playlist from a music service.
*/
@SerialName("playlist")
PLAYLIST,

/**
* An album listed on a music service.
*/
@SerialName("album")
ALBUM,

/**
* An auto-generated playlist about an author from a music service.
*/
@SerialName("artist")
ARTIST,

/**
* Recommendations from a music service (currently only Spotify).
*/
@SerialName("recommendations")
RECOMMENDATIONS
}
}

@Serializable
data class ExtendedTrackInfo(
val albumName: String? = null,
val albumUrl: String? = null,
val artistUrl: String? = null,
val artistArtworkUrl: String? = null,
val previewUrl: String? = null,
val isPreview: Boolean = false
)
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include(":main")
include(":plugin")
include(":protocol")

0 comments on commit 4d8a476

Please sign in to comment.