Spaces:
Sleeping
Sleeping
Update server/jiosaavn.js
Browse files- server/jiosaavn.js +39 -14
server/jiosaavn.js
CHANGED
|
@@ -1,22 +1,47 @@
|
|
| 1 |
import axios from 'axios';
|
| 2 |
|
| 3 |
-
// Update to your deployed endpoint base
|
| 4 |
const BASE = 'https://jio-saavn-api-eta.vercel.app';
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return data;
|
| 11 |
}
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
|
|
|
| 1 |
import axios from 'axios';
|
| 2 |
|
|
|
|
| 3 |
const BASE = 'https://jio-saavn-api-eta.vercel.app';
|
| 4 |
|
| 5 |
+
const http = axios.create({
|
| 6 |
+
baseURL: BASE,
|
| 7 |
+
timeout: 12000
|
| 8 |
+
});
|
| 9 |
+
|
| 10 |
+
export async function searchUniversal(query) {
|
| 11 |
+
// /result/?query=
|
| 12 |
+
const { data } = await http.get(`/result/?query=${encodeURIComponent(query)}`);
|
| 13 |
+
return data;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
export async function getSong(queryOrId) {
|
| 17 |
+
// Supports ?query= or ?id=
|
| 18 |
+
const path = String(queryOrId).startsWith('id:')
|
| 19 |
+
? `/song/?id=${encodeURIComponent(queryOrId.slice(3))}`
|
| 20 |
+
: `/song/?query=${encodeURIComponent(queryOrId)}`;
|
| 21 |
+
const { data } = await http.get(path);
|
| 22 |
return data;
|
| 23 |
}
|
| 24 |
|
| 25 |
+
export async function getAlbum(queryOrId) {
|
| 26 |
+
const path = String(queryOrId).startsWith('id:')
|
| 27 |
+
? `/album/?id=${encodeURIComponent(queryOrId.slice(3))}`
|
| 28 |
+
: `/album/?query=${encodeURIComponent(queryOrId)}`;
|
| 29 |
+
const { data } = await http.get(path);
|
| 30 |
+
return data;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
export async function getPlaylist(queryOrId) {
|
| 34 |
+
const path = String(queryOrId).startsWith('id:')
|
| 35 |
+
? `/playlist/?id=${encodeURIComponent(queryOrId.slice(3))}`
|
| 36 |
+
: `/playlist/?query=${encodeURIComponent(queryOrId)}`;
|
| 37 |
+
const { data } = await http.get(path);
|
| 38 |
+
return data;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
export async function getLyrics(queryOrId) {
|
| 42 |
+
const path = String(queryOrId).startsWith('id:')
|
| 43 |
+
? `/lyrics/?id=${encodeURIComponent(queryOrId.slice(3))}`
|
| 44 |
+
: `/lyrics/?query=${encodeURIComponent(queryOrId)}`;
|
| 45 |
+
const { data } = await http.get(path);
|
| 46 |
+
return data;
|
| 47 |
}
|