Skip to content

Commit

Permalink
chore: Bump project version to 0.1.7
Browse files Browse the repository at this point in the history
Fixed: Search issue
  • Loading branch information
appujet committed Aug 7, 2024
1 parent 315d3d1 commit 480fe06
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

project.group = "com.github.appujet"
project.version = "0.1.6"
project.version = "0.1.7"
val archivesBaseName = "jiosaavn"

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.tools.DataFormatTools;
import com.sedmelluq.discord.lavaplayer.tools.JsonBrowser;
import com.sedmelluq.discord.lavaplayer.track.AudioItem;
import com.sedmelluq.discord.lavaplayer.track.AudioReference;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import com.sedmelluq.discord.lavaplayer.track.*;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.DataInput;
import java.io.DataOutput;
Expand All @@ -25,6 +24,7 @@

public class JioSaavnAudioSourceManager extends ExtendedAudioSourceManager {
private static final Pattern JIOSAAVN_REGEX = Pattern.compile("(https?://)(www\\.)?jiosaavn\\.com/(song|album|featured|artist)/([a-zA-Z0-9-_]+)");
private static final Logger log = LoggerFactory.getLogger(JioSaavnAudioSourceManager.class);
public static String BASE_API = null;
public static final String SEARCH_PREFIX = "jssearch:";
public static final String RECOMMENDATIONS_PREFIX = "jsrec:";
Expand Down Expand Up @@ -88,20 +88,33 @@ public AudioTrack decodeTrack(AudioTrackInfo audioTrackInfo, DataInput dataInput
}

private AudioItem getSearchResult(String query) throws IOException {
final JsonBrowser json = this.fetchJson("/search?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8));
final JsonBrowser json = this.fetchJson("/search/songs?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8) + "&limit=50");

if (json.isNull() || json.get("data").isNull()) {
return AudioReference.NO_TRACK;
}
final JsonBrowser data = json.get("data");
if (data.get("songs").isNull()) {

if (data.get("results").isNull()) {
return AudioReference.NO_TRACK;
}
final JsonBrowser song = data.get("songs").get("results").index(0);
if (song.isNull()) {

final JsonBrowser songs = data.get("results");

if (songs.isNull() || !songs.isList()) {
return AudioReference.NO_TRACK;
}
var tracks = this.fetchJson("/songs?ids=" + song.get("id").text());
return this.buildTrack(tracks.get("data").index(0));

final List<AudioTrack> tracks = songs.values().stream()
.map(this::buildTrack)
.collect(Collectors.toList());

return new BasicAudioPlaylist(
"Search results for: " + query,
tracks,
null,
true
);
}

private AudioItem getTrack(String identifier) throws IOException {
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id("com.github.breadmoirai.github-release")
}

val pluginVersion = Version(0, 1, 6)
val pluginVersion = Version(0, 1, 7)

group = "com.github.appujet"
version = "$pluginVersion"
Expand Down

0 comments on commit 480fe06

Please sign in to comment.