topi314 / LavaSrc

A collection of additional Lavaplayer/Lavalink Sources
Apache License 2.0
160 stars 51 forks source link

[Update proposal] Yandex Music #198

Closed llimonix closed 2 months ago

llimonix commented 4 months ago

@Krispeckt could you change the functionality of getsearch and instead of searching for a track, search for everything. Parse the best match and, depending on the best match, parse and add information. I tried to implement it, but I'm too stupid in java It looks like this now: image I would like it to look like this (example):

    private AudioItem getSearch(String query) throws IOException {
        var json = this.getJson(PUBLIC_API_BASE + "/search?text=" + URLEncoder.encode(query, StandardCharsets.UTF_8) + "&type=all&page=0");
        if (json.isNull() || json.get("result").get("best").isNull()) {
            return AudioReference.NO_TRACK;
        }
        var bestResult = json.get("result").get("best");
        var type = bestResult.get("type").text();
        switch (type) {
            case "track":
                var tracks = this.parseTracks(json.get("result").get("tracks").get("results"));
                if (tracks.isEmpty()) {
                    return AudioReference.NO_TRACK;
                }
                return new BasicAudioPlaylist("Yandex Music Search: " + query, tracks, null, true);

            case "album":
                var albumId = bestResult.get("result").get("id").text();
                return this.getAlbum(albumId);

            case "artist":
                var artistId = bestResult.get("result").get("id").text();
                return this.getArtist(artistId);

            case "playlist":
                var userId = bestResult.get("result").get("uid").text();
                var playlistId = bestResult.get("result").get("kind").text();
                return this.getPlaylist(userId, playlistId);

            default:
                return AudioReference.NO_TRACK;
        }
    }
Krispeckt commented 4 months ago

I can do it differently by using LavaSearch. There you will be able to get a search on the service and determine the best one for you yourself.At the moment Yandex music in the plugin does not support LavaSearch

Perhaps later I'll implement this

topi314 commented 4 months ago

As @Krispeckt said this should be implemented via the LavaSearch API This would mean you get back search results for all those types(tracks, albums, playlists, artists & text autocomplete). Lavaplayer does not support searching for anything other than tracks

llimonix commented 4 months ago

I can do it differently by using LavaSearch. There you will be able to get a search on the service and determine the best one for you yourself.At the moment Yandex music in the plugin does not support LavaSearch

Perhaps later I'll implement this

That would be great.

Krispeckt commented 2 months ago

This issue is closed 🥹