Skip to content

Commit

Permalink
Refactor JioSaavnAudioSourceManager class in main/src/main/java/com/g…
Browse files Browse the repository at this point in the history
…ithub/appujet/jiosaavn/source/JioSaavnAudioSourceManager.java
  • Loading branch information
appujet committed Apr 28, 2024
1 parent ad2f876 commit 4c2c3cc
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 25 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: appujet # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: sdip521 # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: appujet # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Technical issue
about: Use this if you are having a problem with Lavalink
title: ''
labels: ''
assignees: ''

---

## Description
<!-- Please describe the issue in details -->


## Version info
**Client used:** <!-- The library you use to connect to Lavalink -->

Output of `java -version`:
```
(paste here)
```

<!-- You must include your lavalink logs -->
<!-- If you can't provide a log, at least provide the output of "java -jar Lavalink.jar --version" -->
31 changes: 31 additions & 0 deletions .github/workflows/release-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release Beta

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
path: './'
fetch-depth: 0
- name: Set up java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: dependencies
run: ./gradlew --no-daemon dependencies
- name: Release to github
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
RELEASE_TARGET: ${{ github.sha }}
PRERELEASE: true
run: ./gradlew --no-daemon build githubRelease
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
workflow_dispatch:
inputs:
prerelease:
description: Whether or not this is a prerelease
type: boolean
default: false
required: true
# push:
# branches:
# - master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
path: './'
fetch-depth: 0
- name: Set up java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: dependencies
run: ./gradlew --no-daemon dependencies
- name: Release to github
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
USERNAME: ${{ secrets.USERNAME }}
PASSWORD: ${{ secrets.PASSWORD }}
RELEASE_TARGET: ${{ github.sha }}
run: ./gradlew --no-daemon build publish githubRelease -x test
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
## JioSaavn Plugin For Lavalink
# JioSaavn Plugin For Lavalink

- This is a plugin for [Lavalink](https://github.com/lavalink-devs/Lavalink)
- This plugin allows you to play songs from JioSaavn in your discord server.
- This plugin uses the [JioSaavn API](https://github.com/sumitkolhe/jiosaavn-api) to fetch songs.
- Special thanks to [topi314](https://github.com/topi314/LavaSrc) and [duncte123](https://github.com/duncte123) because most of the code for this plugin is based on [Lavasrc](https://github.com/topi314/LavaSrc) and [skybot-lavalink-plugin](https://github.com/DuncteBot/skybot-lavalink-plugin).


## Configuration

For all supported urls and queries see [here](#supported-urls-and-queries)

(YES `plugins` IS AT ROOT IN THE YAML)

```yaml
server: # REST and WS server
port: 2333
address: 0.0.0.0
lavalink:
# plugins would go here, but they are auto-loaded when developing
# plugins:
# - dependency: "com.appujet:jiosaavan-plugin:VERSION"
# - dependency: "com.appujet:jiosaavn-plugin:VERSION"
# repository: "https://jitpack.io"
server:
password: "youshallnotpass"
Expand All @@ -45,7 +45,7 @@ lavalink:
#retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times

plugins:
jiosaavan:
jiosaavn:
apiURL: "https://saavn.dev/api" # JioSaavn API URL
metrics:
prometheus:
Expand All @@ -70,28 +70,32 @@ logging:
lavalink: INFO
```
## Advantages of Using JioSaavn
* No region-based content blocking (unlike Deezer and Yandex).
* A better alternative for playing mirrored audio sources not dependent on YouTube.
* Similar content library size as Spotify and Apple Music.
* Superior to Deezer as it doesn't require any decryption key and provides slightly higher bitrate audio than Deezer's 128KBPS MP3.
- No region-based content blocking (unlike Deezer and Yandex).
- A better alternative for playing mirrored audio sources not dependent on YouTube.
- Similar content library size as Spotify and Apple Music.
- Superior to Deezer as it doesn't require any decryption key and provides slightly higher bitrate audio than Deezer's 128KBPS MP3.
## Supported URLs and Queries
### JioSaavan
* `jssearch:animals architects`
* https://www.jiosaavn.com/song/apna-bana-le/ATIfejZ9bWw
* https://www.jiosaavn.com/album/bhediya/wSM2AOubajk_
* https://www.jiosaavn.com/artist/arijit-singh-songs/LlRWpHzy3Hk_
* https://www.jiosaavn.com/featured/jai-hanuman/8GIEhrr8clSO0eMLZZxqsA__
### JioSaavn
- `jssearch:animals architects` - Search for a song on JioSaavn.
- `jsrec:identifier` - Get a song recommendation based on the identifier.

- <https://www.jiosaavn.com/song/apna-bana-le/ATIfejZ9bWw>
- <https://www.jiosaavn.com/album/bhediya/wSM2AOubajk>_
- <https://www.jiosaavn.com/artist/arijit-singh-songs/LlRWpHzy3Hk>_
- <https://www.jiosaavn.com/featured/jai-hanuman/8GIEhrr8clSO0eMLZZxqsA>__

## How to get API URL ?
* You can host the api locally using [this guide](https://github.com/sumitkolhe/jiosaavn-api)
* You can easily deploy your own instance of the API by clicking the button below:

- You can host the api locally using [this guide](https://github.com/sumitkolhe/jiosaavn-api)

- You can easily deploy your own instance of the API by clicking the button below:

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/sumitkolhe/jiosaavn-api)

> [!TIP]
> To ensure the API provides results in the intended language, configure the [Serverless Function Region](https://vercel.com/docs/concepts/functions/serverless-functions/regions) in Vercel to `Mumbai, India (South) - > bom1`.

Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void encodeTrack(AudioTrack audioTrack, DataOutput dataOutput) {

@Override
public AudioTrack decodeTrack(AudioTrackInfo audioTrackInfo, DataInput dataInput) {
return new JioSaavanAudioTrack(audioTrackInfo, this);
return new JioSaavnAudioTrack(audioTrackInfo, this);
}

private AudioItem getSearchResult(String query) throws IOException {
Expand Down Expand Up @@ -123,7 +123,7 @@ public AudioItem getAlbum(String identifier) {
if (data.get("songs").isNull()) {
return AudioReference.NO_TRACK;
}
return new JioSaavanAudioPlaylist(
return new JioSaavnAudioPlaylist(
data.get("name").text(),
this.buildTracks(data.get("songs")),
ExtendedAudioPlaylist.Type.ALBUM,
Expand All @@ -144,7 +144,7 @@ public AudioItem getPlaylist(String identifier) {
if (data.get("songs").isNull()) {
return AudioReference.NO_TRACK;
}
return new JioSaavanAudioPlaylist(
return new JioSaavnAudioPlaylist(
data.get("name").text(),
this.buildTracks(data.get("songs")),
ExtendedAudioPlaylist.Type.PLAYLIST,
Expand All @@ -165,7 +165,7 @@ private AudioItem getArtist(String identifier) {
if (data.get("topSongs").isNull()) {
return AudioReference.NO_TRACK;
}
return new JioSaavanAudioPlaylist(
return new JioSaavnAudioPlaylist(
data.get("name").text(),
this.buildTracks(data.get("topSongs")),
ExtendedAudioPlaylist.Type.ARTIST,
Expand All @@ -189,7 +189,7 @@ public AudioItem getRecommendations(String identifier) {

var tracks = this.buildTracks(data);

return new JioSaavanAudioPlaylist(
return new JioSaavnAudioPlaylist(
"Recommendations",
tracks,
ExtendedAudioPlaylist.Type.RECOMMENDATIONS,
Expand Down Expand Up @@ -231,7 +231,7 @@ private AudioTrack buildTrack(JsonBrowser data) {
final long duration = data.get("duration").asLong(1) * 1000;
final String url = data.get("url").text();
var artist = cleanString(this.parseArtist(data));
return new JioSaavanAudioTrack(
return new JioSaavnAudioTrack(
new AudioTrackInfo(
title,
artist,
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
id("com.github.breadmoirai.github-release")
}

val pluginVersion = Version(0, 0, 2)
val pluginVersion = Version(0, 1, 0)

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

0 comments on commit 4c2c3cc

Please sign in to comment.