@manhgdev/soundcloud-package 0.1.0

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/.babelrc ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": {
7
+ "node": "18"
8
+ }
9
+ }
10
+ ]
11
+ ]
12
+ }
package/.eslintrc.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "env": {
3
+ "node": true,
4
+ "es2022": true
5
+ },
6
+ "extends": ["eslint:recommended"],
7
+ "parserOptions": {
8
+ "ecmaVersion": "latest",
9
+ "sourceType": "module"
10
+ },
11
+ "rules": {
12
+ "indent": ["error", 2],
13
+ "linebreak-style": ["error", "unix"],
14
+ "quotes": ["error", "single"],
15
+ "semi": ["error", "always"]
16
+ }
17
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Manh Dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,196 @@
1
+ # SoundCloud API Package
2
+
3
+ Gói thư viện JavaScript giúp tương tác với SoundCloud API một cách dễ dàng.
4
+
5
+ ## Giới thiệu
6
+
7
+ Dự án này cung cấp một wrapper cho SoundCloud API, giúp các nhà phát triển có thể tích hợp các tính năng của SoundCloud vào ứng dụng của họ một cách đơn giản và hiệu quả.
8
+
9
+ ## Tính năng
10
+
11
+ - Tìm kiếm bài hát, album, playlist và người dùng
12
+ - Phát nhạc và quản lý trình phát
13
+ - Tương tác với người dùng (thích, bình luận, repost)
14
+ - Quản lý playlist và collection
15
+ - Xem thông tin chi tiết về track, người dùng và playlist
16
+ - Tự động lấy và cập nhật client ID
17
+
18
+ ## Cài đặt
19
+
20
+ ```bash
21
+ bun add @manhgdev/soundcloud-package
22
+ ```
23
+
24
+ ## Khởi tạo
25
+
26
+ ```javascript
27
+ import SoundCloudAPI from '@manhgdev/soundcloud-package';
28
+
29
+ // Khởi tạo với tự động lấy client ID
30
+ const sc = new SoundCloudAPI({
31
+ autoFetchClientId: true // Mặc định là true, tự động lấy và cập nhật client ID
32
+ });
33
+
34
+ // Hoặc khởi tạo với client ID cụ thể
35
+ const sc2 = new SoundCloudAPI({
36
+ clientId: 'YOUR_CLIENT_ID',
37
+ autoFetchClientId: false // Tắt tính năng tự động lấy client ID
38
+ });
39
+
40
+ // Lấy client ID hiện tại
41
+ const clientId = await sc.getClientId();
42
+ ```
43
+
44
+ ## Hướng dẫn sử dụng chi tiết
45
+
46
+ ### Module Search
47
+
48
+ Module này cho phép tìm kiếm các nội dung trên SoundCloud.
49
+
50
+ ```javascript
51
+ // Tìm kiếm tất cả (tracks, users, albums, playlists)
52
+ const results = await sc.search.all('skrillex', { limit: 10 });
53
+
54
+ // Tìm kiếm bài hát
55
+ const tracks = await sc.search.tracks('dance & edm', {
56
+ limit: 10,
57
+ sort: 'popular'
58
+ });
59
+
60
+ // Tìm kiếm người dùng
61
+ const users = await sc.search.users('skrillex');
62
+
63
+ // Tìm kiếm album
64
+ const albums = await sc.search.albums('skrillex album');
65
+
66
+ // Tìm kiếm playlist
67
+ const playlists = await sc.search.playlists('workout playlist');
68
+
69
+ // Tìm kiếm theo thể loại
70
+ const electronicTracks = await sc.search.byGenre('electronic', {
71
+ limit: 20,
72
+ sort: 'popular'
73
+ });
74
+ ```
75
+
76
+ ### Module Tracks
77
+
78
+ Module này cho phép làm việc với các bài hát trên SoundCloud.
79
+
80
+ ```javascript
81
+ // Lấy nhiều bài hát theo ID
82
+ const tracks = await sc.tracks.getMultiple([123456, 789012]);
83
+
84
+ // Lấy bình luận của bài hát
85
+ const comments = await sc.tracks.getComments(123456, { limit: 10 });
86
+
87
+ // Lấy các bài hát liên quan
88
+ const relatedTracks = await sc.tracks.getRelated(123456, { limit: 10 });
89
+ ```
90
+
91
+ ### Module Users
92
+
93
+ Module này cho phép làm việc với người dùng trên SoundCloud.
94
+
95
+ ```javascript
96
+ // Lấy thông tin người dùng
97
+ const user = await sc.users.getUser(123456);
98
+
99
+ // Lấy spotlight của người dùng
100
+ const spotlight = await sc.users.getSpotlight(123456);
101
+
102
+ // Lấy danh sách người dùng được đề xuất
103
+ const featuredProfiles = await sc.users.getFeaturedProfiles(123456);
104
+
105
+ // Lấy danh sách bài hát được thích
106
+ const likes = await sc.users.getLikes(123456, { limit: 10 });
107
+
108
+ // Lấy danh sách người đang theo dõi
109
+ const followings = await sc.users.getFollowings(123456, { limit: 10 });
110
+
111
+ // Lấy danh sách nghệ sĩ liên quan
112
+ const relatedArtists = await sc.users.getRelatedArtists(123456, { limit: 10 });
113
+
114
+ // Lấy bình luận của người dùng
115
+ const comments = await sc.users.getComments(123456, { limit: 10 });
116
+
117
+ // Lấy stream của người dùng
118
+ const stream = await sc.users.getStream(123456, { limit: 10 });
119
+
120
+ // Lấy bài hát nổi bật của người dùng
121
+ const topTracks = await sc.users.getTopTracks(123456, { limit: 10 });
122
+
123
+ // Lấy tất cả bài hát của người dùng
124
+ const userTracks = await sc.users.getTracks(123456, { limit: 10 });
125
+
126
+ // Lấy playlist của người dùng
127
+ const userPlaylists = await sc.users.getPlaylists(123456, { limit: 10 });
128
+
129
+ // Lấy thông tin hồ sơ web của người dùng
130
+ const webProfiles = await sc.users.getWebProfiles(123456);
131
+ ```
132
+
133
+ ### Module Playlists
134
+
135
+ Module này cho phép làm việc với playlist trên SoundCloud.
136
+
137
+ ```javascript
138
+ // Lấy thông tin playlist
139
+ const playlist = await sc.playlists.getPlaylist(123456);
140
+
141
+ // Lấy danh sách người thích playlist
142
+ const likers = await sc.playlists.getLikers(123456, { limit: 10 });
143
+
144
+ // Lấy danh sách người repost playlist
145
+ const reposters = await sc.playlists.getReposters(123456, { limit: 10 });
146
+
147
+ // Lấy playlist theo thể loại
148
+ const genrePlaylists = await sc.playlists.getByGenre('electronic', { limit: 10 });
149
+ ```
150
+
151
+ ### Module Media
152
+
153
+ Module này cho phép làm việc với media và streaming trên SoundCloud.
154
+
155
+ ```javascript
156
+ // Lấy URL phát trực tuyến cho bài hát
157
+ const playbackUrl = await sc.media.getPlaybackUrl(123456);
158
+
159
+ // Lấy URL tải xuống cho bài hát
160
+ const downloadUrl = await sc.media.getDownloadUrl(123456);
161
+
162
+ // Phương thức chung để lấy URL media với protocol tùy chọn
163
+ const mediaUrl = await sc.media.getMediaUrl(123456, 'hls'); // hoặc 'progressive'
164
+ ```
165
+
166
+ ### Module Discover
167
+
168
+ Module này cho phép khám phá nội dung trên SoundCloud.
169
+
170
+ ```javascript
171
+ // Lấy nội dung trang chủ
172
+ const homeContent = await sc.discover.getHomeContent();
173
+
174
+ // Lấy bài hát mới theo thể loại
175
+ const recentTracks = await sc.discover.getRecentTracks('electronic');
176
+
177
+ // Lấy bài hát mới theo quốc gia
178
+ const recentTracksByCountry = await sc.discover.getRecentTracksByCountry();
179
+ ```
180
+
181
+ ## Tự động lấy Client ID
182
+
183
+ Package hỗ trợ tự động lấy và cập nhật client ID từ trang web SoundCloud. Tính năng này:
184
+
185
+ - Tự động lấy client ID mới khi cần thiết
186
+ - Lưu trữ client ID trong bộ nhớ tạm với thời gian hết hạn 3 phút
187
+ - Tự động làm mới client ID khi hết hạn
188
+ - Sử dụng client ID dự phòng nếu không thể lấy được client ID mới
189
+
190
+ ## Tài liệu API
191
+
192
+ Xem chi tiết các endpoint API trong file [endpoint.md](./endpoint.md)
193
+
194
+ ## Giấy phép
195
+
196
+ MIT