diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 9e87d187..418781a7 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -9,6 +9,8 @@ jobs:
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
+ LAVALINK_MAVEN_USERNAME: ${{ secrets.LAVALINK_MAVEN_USERNAME }}
+ LAVALINK_MAVEN_PASSWORD: ${{ secrets.LAVALINK_MAVEN_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -26,7 +28,7 @@ jobs:
uses: gradle/gradle-build-action@v2
- name: Build and Publish
- run: ./gradlew build publish --no-daemon -PMAVEN_USERNAME=$MAVEN_USERNAME -PMAVEN_PASSWORD=$MAVEN_PASSWORD
+ run: ./gradlew build publish --no-daemon -PMAVEN_USERNAME=$MAVEN_USERNAME -PMAVEN_PASSWORD=$MAVEN_PASSWORD -PLAVALINK_MAVEN_USERNAME=$LAVALINK_MAVEN_USERNAME -PLAVALINK_MAVEN_PASSWORD=$LAVALINK_MAVEN_PASSWORD
- name: Upload main Artifact
uses: actions/upload-artifact@v3
diff --git a/README.md b/README.md
index b1e64204..0ccccf16 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,8 @@ dependencies {
```xml
+ TopiWTF-releases
+ Topis Maven Repo
https://maven.topi.wtf/releases
@@ -67,7 +69,7 @@ dependencies {
com.github.topi314.lavasrc
- lavasrc-protocol
+ lavasrc-protocol-jvm
x.y.z
@@ -177,17 +179,18 @@ This plugin requires Lavalink `v4` or greater
To install this plugin either download the latest release and place it into your `plugins` folder or add the following into your `application.yml`
> **Note**
-> For a full `application.yml` example see [here](https://github.com/TopiSenpai/LavaSrc/blob/master/application.yml.example)
+> For a full `application.yml` example see [here](application.example.yml)
Replace x.y.z with the latest version number
```yaml
lavalink:
plugins:
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:x.y.z"
- repository: "https://maven.topi.wtf/releases"
+ repository: "https://maven.lavalink.dev/releases" # this is optional for lavalink v4.0.0-beta.5 or greater
+ snapshot: false # set to true if you want to use snapshot builds (see below)
```
-Snapshot builds are available in https://maven.topi.wtf/snapshots with the short commit hash as the version
+Snapshot builds are available in https://maven.lavalink.dev/snapshots with the short commit hash as the version
### Configuration
diff --git a/application.yml.example b/application.example.yml
similarity index 98%
rename from application.yml.example
rename to application.example.yml
index a1c2862c..43dc0a8c 100644
--- a/application.yml.example
+++ b/application.example.yml
@@ -41,7 +41,6 @@ server: # REST and WS server
lavalink:
plugins:
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:x.y.z"
- repository: "https://maven.topi.wtf/releases"
server:
password: "youshallnotpass"
sources:
diff --git a/build.gradle b/build.gradle
index 9aa352dd..3621cb4e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -41,6 +41,7 @@ def getGitVersion() {
}
var isMavenDefined = findProperty("MAVEN_USERNAME") != null && findProperty("MAVEN_PASSWORD") != null
+var isLavalinkMavenDefined = findProperty("LAVALINK_MAVEN_USERNAME") != null && findProperty("LAVALINK_MAVEN_PASSWORD") != null
subprojects {
apply plugin: "java"
@@ -53,9 +54,10 @@ subprojects {
compileJava.options.encoding = "UTF-8"
publishing {
- if (isMavenDefined) {
- System.out.println("Publishing to Maven Repo")
- repositories {
+ repositories {
+ if (isMavenDefined) {
+ System.out.println("Publishing to Maven Repo")
+
def snapshots = "https://maven.topi.wtf/snapshots"
def releases = "https://maven.topi.wtf/releases"
@@ -66,6 +68,21 @@ subprojects {
username = findProperty("MAVEN_USERNAME")
password = findProperty("MAVEN_PASSWORD")
}
+
+ }
+ }
+ if (isLavalinkMavenDefined && name == "plugin") {
+ System.out.println("Publishing to Lavalink Maven Repo")
+ def lavalinkSnapshots = "https://maven.lavalink.dev/snapshots"
+ def lavalinkReleases = "https://maven.lavalink.dev/releases"
+
+ maven {
+ name = "Reposilite-Lavalink"
+ url = isSnapshot ? lavalinkSnapshots : lavalinkReleases
+ credentials {
+ username = findProperty("LAVALINK_MAVEN_USERNAME")
+ password = findProperty("LAVALINK_MAVEN_PASSWORD")
+ }
}
}
}
diff --git a/main/build.gradle b/main/build.gradle
index b76ad2f4..0646051b 100644
--- a/main/build.gradle
+++ b/main/build.gradle
@@ -14,8 +14,8 @@ java {
}
dependencies {
- api "com.github.topi314.lavasearch:lavasearch:1.0.0-beta.2"
- compileOnly "dev.arbjerg:lavaplayer:2.0.1"
+ api "com.github.topi314.lavasearch:lavasearch:1.0.0"
+ compileOnly "dev.arbjerg:lavaplayer:2.0.4"
implementation "org.jsoup:jsoup:1.15.3"
implementation "commons-io:commons-io:2.7"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
diff --git a/main/src/main/java/com/github/topi314/lavasrc/applemusic/AppleMusicSourceManager.java b/main/src/main/java/com/github/topi314/lavasrc/applemusic/AppleMusicSourceManager.java
index 7740c04c..e578b57a 100644
--- a/main/src/main/java/com/github/topi314/lavasrc/applemusic/AppleMusicSourceManager.java
+++ b/main/src/main/java/com/github/topi314/lavasrc/applemusic/AppleMusicSourceManager.java
@@ -282,7 +282,7 @@ public AudioSearchResult getSearchSuggestions(String query, Set parseTracks(JsonBrowser json, boolean preview, Map artistArtwork) {
var tracks = new ArrayList();
for (var value : json.get("data").values()) {
- tracks.add(this.parseTrack(value, preview, artistArtwork.get(this.parseArtistId(value))));
+ var artistId = this.parseArtistId(value);
+ String artworkUrl = null;
+ if (artistId != null) {
+ artworkUrl = artistArtwork.get(artistId);
+ }
+ tracks.add(this.parseTrack(value, preview, artworkUrl));
}
return tracks;
}
+ private List parseTrackList(JsonBrowser json, boolean preview) throws IOException {
+ var jsonData = JsonBrowser.newMap();
+ jsonData.put("data", json);
+ return parseTracks(jsonData, preview);
+ }
+
private List parseTracks(JsonBrowser json, boolean preview) throws IOException {
var ids = json.get("data").values().stream().map(this::parseArtistId).filter(Predicate.not(Objects::isNull)).collect(Collectors.toList());
return parseTracks(json, preview, getArtistCover(ids));
diff --git a/main/src/main/java/com/github/topi314/lavasrc/spotify/SpotifySourceManager.java b/main/src/main/java/com/github/topi314/lavasrc/spotify/SpotifySourceManager.java
index fde925ca..58d9e593 100644
--- a/main/src/main/java/com/github/topi314/lavasrc/spotify/SpotifySourceManager.java
+++ b/main/src/main/java/com/github/topi314/lavasrc/spotify/SpotifySourceManager.java
@@ -17,6 +17,7 @@
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
@@ -43,6 +44,7 @@ public class SpotifySourceManager extends MirroringAudioSourceManager implements
public static final String RECOMMENDATIONS_PREFIX = "sprec:";
public static final String PREVIEW_PREFIX = "spprev:";
public static final long PREVIEW_LENGTH = 30000;
+ public static final String SHARE_URL = "https://spotify.link/";
public static final int PLAYLIST_MAX_PAGE_ITEMS = 100;
public static final int ALBUM_MAX_PAGE_ITEMS = 50;
public static final String API_BASE = "https://api.spotify.com/v1/";
@@ -146,6 +148,21 @@ public AudioItem loadItem(String identifier, boolean preview) {
return this.getRecommendations(identifier.substring(RECOMMENDATIONS_PREFIX.length()).trim(), preview);
}
+ // If the identifier is a share URL, we need to follow the redirect to find out the real url behind it
+ if (identifier.startsWith(SHARE_URL)) {
+ var request = new HttpHead(identifier);
+ request.setConfig(RequestConfig.custom().setRedirectsEnabled(false).build());
+ try (var response = this.httpInterfaceManager.getInterface().execute(request)) {
+ if (response.getStatusLine().getStatusCode() == 307) {
+ var location = response.getFirstHeader("Location").getValue();
+ if (location.startsWith("https://open.spotify.com/")) {
+ return this.loadItem(location, preview);
+ }
+ }
+ return null;
+ }
+ }
+
var matcher = URL_PATTERN.matcher(identifier);
if (!matcher.find()) {
return null;
diff --git a/plugin/build.gradle b/plugin/build.gradle
index b8c27f22..199b2bf8 100644
--- a/plugin/build.gradle
+++ b/plugin/build.gradle
@@ -1,12 +1,12 @@
plugins {
- id "dev.arbjerg.lavalink.gradle-plugin" version "1.0.14"
+ id "dev.arbjerg.lavalink.gradle-plugin" version "1.0.15"
}
archivesBaseName = "lavasrc-plugin"
lavalinkPlugin {
name = "lavasrc-plugin"
- apiVersion = "4.0.0-beta.3"
- serverVersion = "4.0.0-beta.3"
+ apiVersion = "4.0.0"
+ serverVersion = "4.0.0"
configurePublishing = false
}
@@ -15,8 +15,8 @@ targetCompatibility = JavaVersion.VERSION_17
dependencies {
implementation project(":main")
- compileOnly "com.github.topi314.lavasearch:lavasearch:1.0.0-beta.2"
- implementation "com.github.topi314.lavasearch:lavasearch-plugin-api:1.0.0-beta.2"
+ compileOnly "com.github.topi314.lavasearch:lavasearch:1.0.0"
+ implementation "com.github.topi314.lavasearch:lavasearch-plugin-api:1.0.0"
}
publishing {