tunzo-player 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/api-calles.d.ts +25 -0
- package/dist/core/api-calles.js +95 -0
- package/package.json +2 -2
- package/src/core/api-calles.ts +120 -22
|
@@ -6,4 +6,29 @@ export declare class TunzoPlayerAPI {
|
|
|
6
6
|
* @returns Array of song result objects
|
|
7
7
|
*/
|
|
8
8
|
searchSongs(query: string, limit?: number): Promise<any[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Search for playlists
|
|
11
|
+
* @param query Search keyword
|
|
12
|
+
* @param limit Number of results (default: 1000)
|
|
13
|
+
*/
|
|
14
|
+
searchPlaylists(query: string, limit?: number): Promise<any[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Get playlist details
|
|
17
|
+
* @param id Playlist ID
|
|
18
|
+
* @param link Playlist URL/Link (optional but recommended if available)
|
|
19
|
+
* @param limit Number of songs to return (default: 1000)
|
|
20
|
+
*/
|
|
21
|
+
getPlaylistDetails(id: string, link?: string, limit?: number): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Search for albums
|
|
24
|
+
* @param query Search keyword
|
|
25
|
+
* @param limit Number of results (default: 1000)
|
|
26
|
+
*/
|
|
27
|
+
searchAlbums(query: string, limit?: number): Promise<any[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Get album details
|
|
30
|
+
* @param id Album ID
|
|
31
|
+
* @param link Album URL/Link (optional but recommended if available)
|
|
32
|
+
*/
|
|
33
|
+
getAlbumDetails(id: string, link?: string): Promise<any>;
|
|
9
34
|
}
|
package/dist/core/api-calles.js
CHANGED
|
@@ -34,5 +34,100 @@ class TunzoPlayerAPI {
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Search for playlists
|
|
39
|
+
* @param query Search keyword
|
|
40
|
+
* @param limit Number of results (default: 1000)
|
|
41
|
+
*/
|
|
42
|
+
searchPlaylists(query_1) {
|
|
43
|
+
return __awaiter(this, arguments, void 0, function* (query, limit = 1000) {
|
|
44
|
+
var _a;
|
|
45
|
+
try {
|
|
46
|
+
const response = yield fetch(`https://saavn.sumit.co/api/search/playlists?query=${encodeURIComponent(query)}&limit=${limit}`);
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
49
|
+
}
|
|
50
|
+
const json = yield response.json();
|
|
51
|
+
return ((_a = json === null || json === void 0 ? void 0 : json.data) === null || _a === void 0 ? void 0 : _a.results) || [];
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error("TunzoPlayerAPI Error (searchPlaylists):", error);
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get playlist details
|
|
61
|
+
* @param id Playlist ID
|
|
62
|
+
* @param link Playlist URL/Link (optional but recommended if available)
|
|
63
|
+
* @param limit Number of songs to return (default: 1000)
|
|
64
|
+
*/
|
|
65
|
+
getPlaylistDetails(id_1) {
|
|
66
|
+
return __awaiter(this, arguments, void 0, function* (id, link = "", limit = 1000) {
|
|
67
|
+
try {
|
|
68
|
+
let url = `https://saavn.sumit.co/api/playlists?id=${id}&limit=${limit}`;
|
|
69
|
+
if (link) {
|
|
70
|
+
url += `&link=${encodeURIComponent(link)}`;
|
|
71
|
+
}
|
|
72
|
+
const response = yield fetch(url);
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
75
|
+
}
|
|
76
|
+
const json = yield response.json();
|
|
77
|
+
return (json === null || json === void 0 ? void 0 : json.data) || null;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error("TunzoPlayerAPI Error (getPlaylistDetails):", error);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Search for albums
|
|
87
|
+
* @param query Search keyword
|
|
88
|
+
* @param limit Number of results (default: 1000)
|
|
89
|
+
*/
|
|
90
|
+
searchAlbums(query_1) {
|
|
91
|
+
return __awaiter(this, arguments, void 0, function* (query, limit = 1000) {
|
|
92
|
+
var _a;
|
|
93
|
+
try {
|
|
94
|
+
const response = yield fetch(`https://saavn.sumit.co/api/search/albums?query=${encodeURIComponent(query)}&limit=${limit}`);
|
|
95
|
+
if (!response.ok) {
|
|
96
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
97
|
+
}
|
|
98
|
+
const json = yield response.json();
|
|
99
|
+
return ((_a = json === null || json === void 0 ? void 0 : json.data) === null || _a === void 0 ? void 0 : _a.results) || [];
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
console.error("TunzoPlayerAPI Error (searchAlbums):", error);
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get album details
|
|
109
|
+
* @param id Album ID
|
|
110
|
+
* @param link Album URL/Link (optional but recommended if available)
|
|
111
|
+
*/
|
|
112
|
+
getAlbumDetails(id_1) {
|
|
113
|
+
return __awaiter(this, arguments, void 0, function* (id, link = "") {
|
|
114
|
+
try {
|
|
115
|
+
let url = `https://saavn.sumit.co/api/albums?id=${id}`;
|
|
116
|
+
if (link) {
|
|
117
|
+
url += `&link=${encodeURIComponent(link)}`;
|
|
118
|
+
}
|
|
119
|
+
const response = yield fetch(url);
|
|
120
|
+
if (!response.ok) {
|
|
121
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
122
|
+
}
|
|
123
|
+
const json = yield response.json();
|
|
124
|
+
return (json === null || json === void 0 ? void 0 : json.data) || null;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
console.error("TunzoPlayerAPI Error (getAlbumDetails):", error);
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
37
132
|
}
|
|
38
133
|
exports.TunzoPlayerAPI = TunzoPlayerAPI;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tunzo-player",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "A music playback service for Angular and Ionic apps with native audio control support.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publish:patch": "npm version patch && npm run build && npm publish",
|
|
10
10
|
"publish:minor": "npm version minor && npm run build && npm publish",
|
|
11
11
|
"publish:major": "npm version major && npm run build && npm publish",
|
|
12
|
-
"publish": "npm run build
|
|
12
|
+
"publish": "npm run build"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"music",
|
package/src/core/api-calles.ts
CHANGED
|
@@ -1,26 +1,124 @@
|
|
|
1
1
|
export class TunzoPlayerAPI {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const json = await response.json();
|
|
19
|
-
return json?.data?.results || [];
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.error("TunzoPlayerAPI Error:", error);
|
|
22
|
-
return [];
|
|
2
|
+
/**
|
|
3
|
+
* Search for songs using the saavn.dev API
|
|
4
|
+
* @param query Search keyword (e.g., artist name, song name)
|
|
5
|
+
* @param limit Number of results to return (default: 250)
|
|
6
|
+
* @returns Array of song result objects
|
|
7
|
+
*/
|
|
8
|
+
async searchSongs(query: string, limit: number = 250): Promise<any[]> {
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch(
|
|
11
|
+
`https://saavn.sumit.co/api/search/songs?query=${encodeURIComponent(query)}&limit=${limit}`
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
23
16
|
}
|
|
17
|
+
|
|
18
|
+
const json = await response.json();
|
|
19
|
+
return json?.data?.results || [];
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error("TunzoPlayerAPI Error:", error);
|
|
22
|
+
return [];
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Search for playlists
|
|
28
|
+
* @param query Search keyword
|
|
29
|
+
* @param limit Number of results (default: 1000)
|
|
30
|
+
*/
|
|
31
|
+
async searchPlaylists(query: string, limit: number = 1000): Promise<any[]> {
|
|
32
|
+
try {
|
|
33
|
+
const response = await fetch(
|
|
34
|
+
`https://saavn.sumit.co/api/search/playlists?query=${encodeURIComponent(query)}&limit=${limit}`
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const json = await response.json();
|
|
42
|
+
return json?.data?.results || [];
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error("TunzoPlayerAPI Error (searchPlaylists):", error);
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get playlist details
|
|
51
|
+
* @param id Playlist ID
|
|
52
|
+
* @param link Playlist URL/Link (optional but recommended if available)
|
|
53
|
+
* @param limit Number of songs to return (default: 1000)
|
|
54
|
+
*/
|
|
55
|
+
async getPlaylistDetails(id: string, link: string = "", limit: number = 1000): Promise<any> {
|
|
56
|
+
try {
|
|
57
|
+
let url = `https://saavn.sumit.co/api/playlists?id=${id}&limit=${limit}`;
|
|
58
|
+
if (link) {
|
|
59
|
+
url += `&link=${encodeURIComponent(link)}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const response = await fetch(url);
|
|
63
|
+
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const json = await response.json();
|
|
69
|
+
return json?.data || null;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error("TunzoPlayerAPI Error (getPlaylistDetails):", error);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Search for albums
|
|
78
|
+
* @param query Search keyword
|
|
79
|
+
* @param limit Number of results (default: 1000)
|
|
80
|
+
*/
|
|
81
|
+
async searchAlbums(query: string, limit: number = 1000): Promise<any[]> {
|
|
82
|
+
try {
|
|
83
|
+
const response = await fetch(
|
|
84
|
+
`https://saavn.sumit.co/api/search/albums?query=${encodeURIComponent(query)}&limit=${limit}`
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const json = await response.json();
|
|
92
|
+
return json?.data?.results || [];
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error("TunzoPlayerAPI Error (searchAlbums):", error);
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get album details
|
|
101
|
+
* @param id Album ID
|
|
102
|
+
* @param link Album URL/Link (optional but recommended if available)
|
|
103
|
+
*/
|
|
104
|
+
async getAlbumDetails(id: string, link: string = ""): Promise<any> {
|
|
105
|
+
try {
|
|
106
|
+
let url = `https://saavn.sumit.co/api/albums?id=${id}`;
|
|
107
|
+
if (link) {
|
|
108
|
+
url += `&link=${encodeURIComponent(link)}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const response = await fetch(url);
|
|
112
|
+
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const json = await response.json();
|
|
118
|
+
return json?.data || null;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error("TunzoPlayerAPI Error (getAlbumDetails):", error);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|