soundcloud.ts
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -91,2 +91,3 @@ import type { Dispatcher } from "undici" | ||
const response = await this.makeRequest(this.proxy || this.web, this.buildOptions(this.proxy ? webURL : "/")) | ||
if (!response || typeof response !== "string") throw new Error("Could not find client ID") | ||
const urls = response.match( | ||
@@ -100,2 +101,3 @@ /(?!<script.*?src=")https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*\.js)(?=.*?>)/g | ||
: request(urls.pop()).then(r => r.body.text())) | ||
if (!script || typeof script !== "string") continue | ||
const clientId = script.match(/[{,]client_id:"(\w+)"/)?.[1] | ||
@@ -102,0 +104,0 @@ if (typeof clientId === "string") return clientId |
@@ -15,17 +15,17 @@ import { Pool } from "undici"; | ||
*/ | ||
get: (endpoint: string, params?: Record<string, any>) => Promise<any>; | ||
get: (endpoint: string, params?: Record<string, any>) => Promise<unknown>; | ||
/** | ||
* Gets an endpoint from the Soundcloud V2 API. | ||
*/ | ||
getV2: (endpoint: string, params?: Record<string, any>) => Promise<any>; | ||
getV2: (endpoint: string, params?: Record<string, any>) => Promise<unknown>; | ||
/** | ||
* Some endpoints use the main website as the URL. | ||
*/ | ||
getWebsite: (endpoint: string, params?: Record<string, any>) => Promise<any>; | ||
getWebsite: (endpoint: string, params?: Record<string, any>) => Promise<unknown>; | ||
/** | ||
* Gets a URL, such as download, stream, attachment, etc. | ||
*/ | ||
getURL: (URI: string, params?: Record<string, any>) => Promise<any>; | ||
getURL: (URI: string, params?: Record<string, any>) => Promise<unknown>; | ||
private readonly makeGet; | ||
post: (endpoint: string, params?: Record<string, any>) => Promise<any>; | ||
post: (endpoint: string, params?: Record<string, any>) => Promise<unknown>; | ||
getClientIdWeb: () => Promise<string>; | ||
@@ -32,0 +32,0 @@ getClientIdMobile: () => Promise<string>; |
@@ -44,3 +44,3 @@ "use strict"; | ||
var webURL = "https://soundcloud.com"; | ||
var API = exports.API = /** @class */ (function () { | ||
var API = /** @class */ (function () { | ||
function API(clientId, oauthToken, proxy) { | ||
@@ -150,2 +150,4 @@ var _this = this; | ||
response = _b.sent(); | ||
if (!response || typeof response !== "string") | ||
throw new Error("Could not find client ID"); | ||
urls = response.match(/(?!<script.*?src=")https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*\.js)(?=.*?>)/g); | ||
@@ -160,2 +162,4 @@ if (!urls || urls.length === 0) | ||
script = _b.sent(); | ||
if (!script || typeof script !== "string") | ||
return [3 /*break*/, 4]; | ||
clientId = (_a = script.match(/[{,]client_id:"(\w+)"/)) === null || _a === void 0 ? void 0 : _a[1]; | ||
@@ -260,1 +264,2 @@ if (typeof clientId === "string") | ||
}()); | ||
exports.API = API; |
@@ -1,10 +0,5 @@ | ||
import type { SoundcloudApp, SoundcloudAppV2 } from "../types"; | ||
import type { SoundcloudAppV2 } from "../types"; | ||
import { Base } from "./Base"; | ||
export declare class Apps extends Base { | ||
/** | ||
* @deprecated use getV2 | ||
* Gets Soundcloud apps. | ||
*/ | ||
get: () => Promise<SoundcloudApp[]>; | ||
/** | ||
* Gets Soundcloud apps, using the Soundcloud v2 API. | ||
@@ -11,0 +6,0 @@ */ |
@@ -61,17 +61,2 @@ "use strict"; | ||
/** | ||
* @deprecated use getV2 | ||
* Gets Soundcloud apps. | ||
*/ | ||
_this.get = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/apps")]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Gets Soundcloud apps, using the Soundcloud v2 API. | ||
@@ -78,0 +63,0 @@ */ |
@@ -5,7 +5,2 @@ import type { SoundcloudComment } from "../types"; | ||
/** | ||
* @deprecated use getV2 | ||
* Gets a comment using its ID. | ||
*/ | ||
get: (commentID: number) => Promise<SoundcloudComment>; | ||
/** | ||
* Gets a comment from its ID, using the Soundcloud v2 API. | ||
@@ -12,0 +7,0 @@ */ |
@@ -61,17 +61,2 @@ "use strict"; | ||
/** | ||
* @deprecated use getV2 | ||
* Gets a comment using its ID. | ||
*/ | ||
_this.get = function (commentID) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/comments/".concat(commentID))]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Gets a comment from its ID, using the Soundcloud v2 API. | ||
@@ -78,0 +63,0 @@ */ |
@@ -1,93 +0,8 @@ | ||
import type { SoundcloudActivityCollection, SoundcloudConnection, SoundcloudUser } from "../types"; | ||
import type { SoundcloudUser } from "../types"; | ||
import { Base } from "."; | ||
export declare class Me extends Base { | ||
/** | ||
* @deprecated use getV2 | ||
* Gets your own profile, or your ID if pass in a true param. | ||
*/ | ||
get: <B extends boolean>(returnID?: B) => Promise<B extends true ? number : SoundcloudUser>; | ||
/** | ||
* Gets your own profile, using the Soundcloud v2 API. | ||
*/ | ||
getV2: () => Promise<SoundcloudUser>; | ||
/** | ||
* @deprecated | ||
* Gets activities from your homepage. | ||
*/ | ||
activities: () => Promise<SoundcloudActivityCollection>; | ||
/** | ||
* @deprecated | ||
* Gets affiliated activities. | ||
*/ | ||
activitiesAffiliated: () => Promise<SoundcloudActivityCollection>; | ||
/** | ||
* @deprecated | ||
* Gets exclusive activities. | ||
*/ | ||
activitiesExclusive: () => Promise<SoundcloudActivityCollection>; | ||
/** | ||
* @deprecated | ||
* Gets your own activities only. | ||
*/ | ||
activitiesOwn: () => Promise<SoundcloudActivityCollection>; | ||
/** | ||
* @deprecated | ||
* Gets your app connections, id any. | ||
*/ | ||
connections: () => Promise<SoundcloudConnection[]>; | ||
/** | ||
* @deprecated | ||
* Gets a connection from its ID. | ||
*/ | ||
connection: (connectionID: number) => Promise<SoundcloudConnection>; | ||
/** | ||
* @deprecated | ||
* Gets your tracks. | ||
*/ | ||
tracks: () => Promise<import("../types").SoundcloudTrack[]>; | ||
/** | ||
* @deprecated | ||
* Gets your comments. | ||
*/ | ||
comments: () => Promise<import("../types").SoundcloudComment[]>; | ||
/** | ||
* @deprecated | ||
* Gets your favorites. | ||
*/ | ||
favorites: () => Promise<import("../types").SoundcloudTrack[]>; | ||
/** | ||
* @deprecated | ||
* Gets a favorite. | ||
*/ | ||
favorite: (userResolvable: string | number) => Promise<import("../types").SoundcloudTrack>; | ||
/** | ||
* @deprecated | ||
* Gets your followers. | ||
*/ | ||
followers: () => Promise<import("../types").SoundcloudUserCollection>; | ||
/** | ||
* @deprecated | ||
* Gets a follower. | ||
*/ | ||
follower: (userResolvable: string | number) => Promise<SoundcloudUser>; | ||
/** | ||
* @deprecated | ||
* Gets your followings. | ||
*/ | ||
followings: () => Promise<import("../types").SoundcloudUserCollection>; | ||
/** | ||
* @deprecated | ||
* Gets a following. | ||
*/ | ||
following: (userResolvable: string | number) => Promise<SoundcloudUser>; | ||
/** | ||
* @deprecated | ||
* Gets your playlists. | ||
*/ | ||
playlists: () => Promise<import("../types").SoundcloudPlaylist[]>; | ||
/** | ||
* @deprecated | ||
* Gets your social networking profiles. | ||
*/ | ||
webProfiles: () => Promise<import("../types").SoundcloudWebProfile[]>; | ||
} |
@@ -61,19 +61,2 @@ "use strict"; | ||
/** | ||
* @deprecated use getV2 | ||
* Gets your own profile, or your ID if pass in a true param. | ||
*/ | ||
_this.get = function (returnID) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/me")]; | ||
case 1: | ||
response = _a.sent(); | ||
if (returnID) | ||
return [2 /*return*/, response.id]; | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Gets your own profile, using the Soundcloud v2 API. | ||
@@ -92,242 +75,2 @@ */ | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets activities from your homepage. | ||
*/ | ||
_this.activities = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/me/activities")]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets affiliated activities. | ||
*/ | ||
_this.activitiesAffiliated = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/me/activities/tracks/affiliated")]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets exclusive activities. | ||
*/ | ||
_this.activitiesExclusive = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/me/activities/tracks/exclusive")]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets your own activities only. | ||
*/ | ||
_this.activitiesOwn = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/me/activities/all/own")]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets your app connections, id any. | ||
*/ | ||
_this.connections = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/me/connections")]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets a connection from its ID. | ||
*/ | ||
_this.connection = function (connectionID) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/me/connections/".concat(connectionID))]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets your tracks. | ||
*/ | ||
_this.tracks = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.tracks(id)]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets your comments. | ||
*/ | ||
_this.comments = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.comments(id)]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets your favorites. | ||
*/ | ||
_this.favorites = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.favorites(id)]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets a favorite. | ||
*/ | ||
_this.favorite = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.favorite(id, userResolvable)]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets your followers. | ||
*/ | ||
_this.followers = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.followers(id)]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets a follower. | ||
*/ | ||
_this.follower = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.follower(id, userResolvable)]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets your followings. | ||
*/ | ||
_this.followings = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.followings(id)]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets a following. | ||
*/ | ||
_this.following = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.following(id, userResolvable)]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets your playlists. | ||
*/ | ||
_this.playlists = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.playlists(id)]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets your social networking profiles. | ||
*/ | ||
_this.webProfiles = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var id; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get(true)]; | ||
case 1: | ||
id = _a.sent(); | ||
return [2 /*return*/, this.sc.users.webProfiles(id)]; | ||
} | ||
}); | ||
}); }; | ||
return _this; | ||
@@ -334,0 +77,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import type { SoundcloudPlaylist, SoundcloudPlaylistFilter, SoundcloudPlaylistFilterV2, SoundcloudPlaylistSearchV2, SoundcloudPlaylistV2, SoundcloudSecretToken } from "../types"; | ||
import type { SoundcloudPlaylistFilterV2, SoundcloudPlaylistSearchV2, SoundcloudPlaylistV2 } from "../types"; | ||
import { Base } from "."; | ||
@@ -9,7 +9,2 @@ export declare class Playlists extends Base { | ||
/** | ||
* @deprecated use searchV2 | ||
* Searches for playlists. | ||
*/ | ||
search: (params?: SoundcloudPlaylistFilter) => Promise<SoundcloudPlaylist[]>; | ||
/** | ||
* Searches for playlists using the v2 API. | ||
@@ -19,7 +14,2 @@ */ | ||
/** | ||
* @deprecated use getV2 | ||
* Fetches a playlist from URL or ID. | ||
*/ | ||
get: (playlistResolvable: string | number) => Promise<any>; | ||
/** | ||
* Fetches a playlist from URL or ID using Soundcloud v2 API. | ||
@@ -29,7 +19,2 @@ */ | ||
/** | ||
* @deprecated | ||
* Requires Authentication - Gets the secret token from one of your playlists. | ||
*/ | ||
secretToken: (playlistResolvable: string | number) => Promise<SoundcloudSecretToken>; | ||
/** | ||
* Searches for playlists (web scraping) | ||
@@ -36,0 +21,0 @@ */ |
@@ -74,3 +74,3 @@ "use strict"; | ||
_c = (_b = playlist.tracks).concat; | ||
return [4 /*yield*/, this.sc.tracks.getArrayV2(unresolvedTracks)]; | ||
return [4 /*yield*/, this.sc.tracks.getArrayV2(unresolvedTracks, true)]; | ||
case 1: | ||
@@ -83,17 +83,2 @@ _a.tracks = _c.apply(_b, [_d.sent()]); | ||
/** | ||
* @deprecated use searchV2 | ||
* Searches for playlists. | ||
*/ | ||
_this.search = function (params) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/playlists", params)]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Searches for playlists using the v2 API. | ||
@@ -113,22 +98,2 @@ */ | ||
/** | ||
* @deprecated use getV2 | ||
* Fetches a playlist from URL or ID. | ||
*/ | ||
_this.get = function (playlistResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var playlistID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(playlistResolvable, true)]; | ||
case 1: | ||
playlistID = _a.sent(); | ||
if (Object.prototype.hasOwnProperty.call(playlistID, "id")) | ||
return [2 /*return*/, playlistID]; | ||
return [4 /*yield*/, this.api.get("/playlists/".concat(playlistID))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Fetches a playlist from URL or ID using Soundcloud v2 API. | ||
@@ -151,22 +116,2 @@ */ | ||
/** | ||
* @deprecated | ||
* Requires Authentication - Gets the secret token from one of your playlists. | ||
*/ | ||
_this.secretToken = function (playlistResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var playlistID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(playlistResolvable)]; | ||
case 1: | ||
playlistID = _a.sent(); | ||
return [4 /*yield*/, this.api | ||
.get("/playlists/".concat(playlistID, "/secret-token")) | ||
.catch(function () { return Promise.reject("Oauth Token is required for this endpoint."); })]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Searches for playlists (web scraping) | ||
@@ -173,0 +118,0 @@ */ |
import { Base } from "."; | ||
export declare class Resolve extends Base { | ||
/** | ||
* @deprecated | ||
* Gets the ID of a user/playlist/track from the Soundcloud URL. | ||
*/ | ||
get: (resolvable: string | number, full?: boolean) => Promise<any>; | ||
/** | ||
* Gets the ID from the html source. | ||
@@ -10,0 +5,0 @@ */ |
@@ -62,27 +62,2 @@ "use strict"; | ||
/** | ||
* @deprecated | ||
* Gets the ID of a user/playlist/track from the Soundcloud URL. | ||
*/ | ||
_this.get = function (resolvable, full) { return __awaiter(_this, void 0, void 0, function () { | ||
var id, resolved; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!String(resolvable).match(/\d{8,}/) && !String(resolvable).includes("soundcloud")) { | ||
resolvable = "https://soundcloud.com/".concat(resolvable); | ||
} | ||
id = resolvable; | ||
if (!String(resolvable).includes("soundcloud")) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.api.get("resolve", { url: resolvable })]; | ||
case 1: | ||
resolved = _a.sent(); | ||
if (full) | ||
return [2 /*return*/, resolved]; | ||
id = resolved.id; | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, id]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Gets the ID from the html source. | ||
@@ -89,0 +64,0 @@ */ |
@@ -1,10 +0,5 @@ | ||
import type { SoundcloudComment, SoundcloudSecretToken, SoundcloudTrack, SoundcloudTrackFilter, SoundcloudTrackFilterV2, SoundcloudTrackSearchV2, SoundcloudTrackV2, SoundcloudUser } from "../types"; | ||
import type { SoundcloudTrackFilterV2, SoundcloudTrackSearchV2, SoundcloudTrackV2 } from "../types"; | ||
import { Base } from "."; | ||
export declare class Tracks extends Base { | ||
/** | ||
* @deprecated Use searchV2 | ||
* Searches for tracks. | ||
*/ | ||
search: (params?: SoundcloudTrackFilter) => Promise<SoundcloudTrack[]>; | ||
/** | ||
* Searches for tracks using the v2 API. | ||
@@ -14,7 +9,2 @@ */ | ||
/** | ||
* @deprecated use getV2 | ||
* Fetches a track by URL or ID. | ||
*/ | ||
get: (trackResolvable: string | number) => Promise<any>; | ||
/** | ||
* Fetches a track from URL or ID using Soundcloud v2 API. | ||
@@ -26,29 +16,4 @@ */ | ||
*/ | ||
getArrayV2: (trackIds: number[]) => Promise<SoundcloudTrackV2[]>; | ||
getArrayV2: (trackIds: number[], keepOrder?: boolean) => Promise<SoundcloudTrackV2[]>; | ||
/** | ||
* @deprecated | ||
* Fetches all comments on a track. | ||
*/ | ||
comments: (trackResolvable: string | number) => Promise<SoundcloudComment[]>; | ||
/** | ||
* @deprecated | ||
* Gets a specific comment. | ||
*/ | ||
comment: (trackResolvable: string | number, commentID: number) => Promise<SoundcloudComment>; | ||
/** | ||
* @deprecated | ||
* Get all users who favorited the track. | ||
*/ | ||
favoriters: (trackResolvable: string | number) => Promise<SoundcloudUser[]>; | ||
/** | ||
* @deprecated | ||
* Get a specific favoriter. | ||
*/ | ||
favoriter: (trackResolvable: string | number, userResolvable: string | number) => Promise<SoundcloudUser>; | ||
/** | ||
* @deprecated | ||
* Requires Authentication - Gets the secret token from one of your own tracks. | ||
*/ | ||
secretToken: (trackResolvable: string | number) => Promise<SoundcloudSecretToken>; | ||
/** | ||
* Searches for tracks (web scraping) | ||
@@ -55,0 +20,0 @@ */ |
@@ -53,2 +53,11 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -63,17 +72,2 @@ exports.Tracks = void 0; | ||
/** | ||
* @deprecated Use searchV2 | ||
* Searches for tracks. | ||
*/ | ||
_this.search = function (params) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/tracks", params)]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Searches for tracks using the v2 API. | ||
@@ -93,22 +87,2 @@ */ | ||
/** | ||
* @deprecated use getV2 | ||
* Fetches a track by URL or ID. | ||
*/ | ||
_this.get = function (trackResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var id, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(trackResolvable, true)]; | ||
case 1: | ||
id = _a.sent(); | ||
if (Object.prototype.hasOwnProperty.call(id, "id")) | ||
return [2 /*return*/, id]; | ||
return [4 /*yield*/, this.api.get("/tracks/".concat(id))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Fetches a track from URL or ID using Soundcloud v2 API. | ||
@@ -133,120 +107,35 @@ */ | ||
*/ | ||
_this.getArrayV2 = function (trackIds) { return __awaiter(_this, void 0, void 0, function () { | ||
var chunks, i, response, tracks; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (trackIds.length === 0) | ||
return [2 /*return*/, [] | ||
// Max 50 ids per request => split into chunks of 50 ids | ||
]; | ||
chunks = []; | ||
i = 0; | ||
while (i < trackIds.length) | ||
chunks.push(trackIds.slice(i, (i += 50))); | ||
response = []; | ||
return [4 /*yield*/, Promise.all(chunks.map(function (chunk) { return _this.api.getV2("/tracks", { ids: chunk.join(",") }); }))]; | ||
case 1: | ||
tracks = _a.sent(); | ||
return [2 /*return*/, response.concat.apply(response, tracks)]; | ||
} | ||
_this.getArrayV2 = function (trackIds_1) { | ||
var args_1 = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args_1[_i - 1] = arguments[_i]; | ||
} | ||
return __awaiter(_this, __spreadArray([trackIds_1], args_1, true), void 0, function (trackIds, keepOrder) { | ||
var chunks, i, response, tracks, result; | ||
var _this = this; | ||
if (keepOrder === void 0) { keepOrder = false; } | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (trackIds.length === 0) | ||
return [2 /*return*/, [] | ||
// Max 50 ids per request => split into chunks of 50 ids | ||
]; | ||
chunks = []; | ||
i = 0; | ||
while (i < trackIds.length) | ||
chunks.push(trackIds.slice(i, (i += 50))); | ||
response = []; | ||
return [4 /*yield*/, Promise.all(chunks.map(function (chunk) { return _this.api.getV2("/tracks", { ids: chunk.join(",") }); }))]; | ||
case 1: | ||
tracks = _a.sent(); | ||
result = response.concat.apply(response, tracks); | ||
if (keepOrder) | ||
return [2 /*return*/, result.sort(function (a, b) { return trackIds.indexOf(a.id) - trackIds.indexOf(b.id); })]; | ||
return [2 /*return*/, result]; | ||
} | ||
}); | ||
}); | ||
}); }; | ||
}; | ||
/** | ||
* @deprecated | ||
* Fetches all comments on a track. | ||
*/ | ||
_this.comments = function (trackResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var trackID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(trackResolvable)]; | ||
case 1: | ||
trackID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/tracks/".concat(trackID, "/comments"))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets a specific comment. | ||
*/ | ||
_this.comment = function (trackResolvable, commentID) { return __awaiter(_this, void 0, void 0, function () { | ||
var trackID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(trackResolvable)]; | ||
case 1: | ||
trackID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/tracks/".concat(trackID, "/comments/").concat(commentID))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Get all users who favorited the track. | ||
*/ | ||
_this.favoriters = function (trackResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var trackID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(trackResolvable)]; | ||
case 1: | ||
trackID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/tracks/".concat(trackID, "/favoriters"))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Get a specific favoriter. | ||
*/ | ||
_this.favoriter = function (trackResolvable, userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var trackID, userID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(trackResolvable)]; | ||
case 1: | ||
trackID = _a.sent(); | ||
return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 2: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/tracks/".concat(trackID, "/favoriters/").concat(userID))]; | ||
case 3: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Requires Authentication - Gets the secret token from one of your own tracks. | ||
*/ | ||
_this.secretToken = function (trackResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var trackID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(trackResolvable)]; | ||
case 1: | ||
trackID = _a.sent(); | ||
return [4 /*yield*/, this.api | ||
.get("/tracks/".concat(trackID, "/secret-token")) | ||
.catch(function () { return Promise.reject("Oauth Token is required for this endpoint."); })]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Searches for tracks (web scraping) | ||
@@ -253,0 +142,0 @@ */ |
@@ -1,10 +0,5 @@ | ||
import type { SoundcloudComment, SoundcloudPlaylist, SoundcloudTrack, SoundcloudTrackV2, SoundcloudUser, SoundcloudUserCollection, SoundcloudUserFilter, SoundcloudUserFilterV2, SoundcloudUserSearchV2, SoundcloudUserV2, SoundcloudWebProfile } from "../types"; | ||
import type { SoundcloudTrackV2, SoundcloudUserFilterV2, SoundcloudUserSearchV2, SoundcloudUserV2, SoundcloudWebProfile } from "../types"; | ||
import { Base } from "."; | ||
export declare class Users extends Base { | ||
/** | ||
* @deprecated use searchV2 | ||
* Searches for users. | ||
*/ | ||
search: (params?: SoundcloudUserFilter) => Promise<SoundcloudUser[]>; | ||
/** | ||
* Searches for users using the v2 API. | ||
@@ -14,7 +9,2 @@ */ | ||
/** | ||
* @deprecated use getV2 | ||
* Gets a user by URL or ID. | ||
*/ | ||
get: (userResolvable: string | number) => Promise<any>; | ||
/** | ||
* Fetches a user from URL or ID using Soundcloud v2 API. | ||
@@ -24,7 +14,2 @@ */ | ||
/** | ||
* @deprecated | ||
* Gets all the tracks by the user. | ||
*/ | ||
tracks: (userResolvable: string | number) => Promise<SoundcloudTrack[]>; | ||
/** | ||
* Gets all the tracks by the user using Soundcloud v2 API. | ||
@@ -34,37 +19,2 @@ */ | ||
/** | ||
* @deprecated | ||
* Gets all the playlists by the user. | ||
*/ | ||
playlists: (userResolvable: string | number) => Promise<SoundcloudPlaylist[]>; | ||
/** | ||
* @deprecated | ||
* Gets all the users the user is following. | ||
*/ | ||
followings: (userResolvable: string | number) => Promise<SoundcloudUserCollection>; | ||
/** | ||
* @deprecated | ||
* Gets a specific following. | ||
*/ | ||
following: (userResolvable: string | number, anotherUserResolvable: string | number) => Promise<SoundcloudUser>; | ||
/** | ||
* @deprecated | ||
* Gets all of a users followers. | ||
*/ | ||
followers: (userResolvable: string | number) => Promise<SoundcloudUserCollection>; | ||
/** | ||
* @deprecated | ||
* Gets a specific follower. | ||
*/ | ||
follower: (userResolvable: string | number, anotherUserResolvable: string | number) => Promise<SoundcloudUser>; | ||
/** | ||
* @deprecated | ||
* Gets all comments by the user. | ||
*/ | ||
comments: (userResolvable: string | number) => Promise<SoundcloudComment[]>; | ||
/** | ||
* @deprecated use likes | ||
* Gets all of a users favorite tracks. | ||
*/ | ||
favorites: (userResolvable: string | number) => Promise<SoundcloudTrack[]>; | ||
/** | ||
* Gets all of a users liked tracks. | ||
@@ -74,7 +24,2 @@ */ | ||
/** | ||
* @deprecated | ||
* Gets a specific favorite track. | ||
*/ | ||
favorite: (userResolvable: string | number, trackResolvable: string | number) => Promise<SoundcloudTrack>; | ||
/** | ||
* Gets all the web profiles on a users sidebar. | ||
@@ -81,0 +26,0 @@ */ |
@@ -63,17 +63,2 @@ "use strict"; | ||
/** | ||
* @deprecated use searchV2 | ||
* Searches for users. | ||
*/ | ||
_this.search = function (params) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.get("/users", params)]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Searches for users using the v2 API. | ||
@@ -93,22 +78,2 @@ */ | ||
/** | ||
* @deprecated use getV2 | ||
* Gets a user by URL or ID. | ||
*/ | ||
_this.get = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable, true)]; | ||
case 1: | ||
userID = _a.sent(); | ||
if (Object.prototype.hasOwnProperty.call(userID, "id")) | ||
return [2 /*return*/, userID]; | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Fetches a user from URL or ID using Soundcloud v2 API. | ||
@@ -131,20 +96,2 @@ */ | ||
/** | ||
* @deprecated | ||
* Gets all the tracks by the user. | ||
*/ | ||
_this.tracks = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 1: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID, "/tracks"))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Gets all the tracks by the user using Soundcloud v2 API. | ||
@@ -194,134 +141,2 @@ */ | ||
/** | ||
* @deprecated | ||
* Gets all the playlists by the user. | ||
*/ | ||
_this.playlists = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 1: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID, "/playlists"))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets all the users the user is following. | ||
*/ | ||
_this.followings = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 1: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID, "/followings"))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets a specific following. | ||
*/ | ||
_this.following = function (userResolvable, anotherUserResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, followingID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 1: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.sc.resolve.get(anotherUserResolvable)]; | ||
case 2: | ||
followingID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID, "/followings/").concat(followingID))]; | ||
case 3: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets all of a users followers. | ||
*/ | ||
_this.followers = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 1: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID, "/followers"))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets a specific follower. | ||
*/ | ||
_this.follower = function (userResolvable, anotherUserResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, followerID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 1: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.sc.resolve.get(anotherUserResolvable)]; | ||
case 2: | ||
followerID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID, "/followers/").concat(followerID))]; | ||
case 3: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated | ||
* Gets all comments by the user. | ||
*/ | ||
_this.comments = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 1: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID, "/comments"))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* @deprecated use likes | ||
* Gets all of a users favorite tracks. | ||
*/ | ||
_this.favorites = function (userResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 1: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID, "/favorites"))]; | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Gets all of a users liked tracks. | ||
@@ -371,23 +186,2 @@ */ | ||
/** | ||
* @deprecated | ||
* Gets a specific favorite track. | ||
*/ | ||
_this.favorite = function (userResolvable, trackResolvable) { return __awaiter(_this, void 0, void 0, function () { | ||
var userID, trackID, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.sc.resolve.get(userResolvable)]; | ||
case 1: | ||
userID = _a.sent(); | ||
return [4 /*yield*/, this.sc.resolve.get(trackResolvable)]; | ||
case 2: | ||
trackID = _a.sent(); | ||
return [4 /*yield*/, this.api.get("/users/".concat(userID, "/favorites/").concat(trackID))]; | ||
case 3: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Gets all the web profiles on a users sidebar. | ||
@@ -394,0 +188,0 @@ */ |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="mocha" /> | ||
@@ -7,2 +6,3 @@ /// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { SoundcloudTrackV2 } from "../types"; | ||
@@ -9,0 +9,0 @@ import { Base } from "."; |
@@ -94,3 +94,3 @@ "use strict"; | ||
]; | ||
var Util = exports.Util = /** @class */ (function (_super) { | ||
var Util = /** @class */ (function (_super) { | ||
__extends(Util, _super); | ||
@@ -583,1 +583,2 @@ function Util() { | ||
}(_1.Base)); | ||
exports.Util = Util; |
@@ -1,2 +0,2 @@ | ||
import type { SoundcloudApp, SoundcloudAppV2 } from "../types" | ||
import type { SoundcloudAppV2 } from "../types" | ||
import { Base } from "./Base" | ||
@@ -6,10 +6,2 @@ | ||
/** | ||
* @deprecated use getV2 | ||
* Gets Soundcloud apps. | ||
*/ | ||
public get = async () => { | ||
const response = await this.api.get("/apps") | ||
return response as Promise<SoundcloudApp[]> | ||
} | ||
/** | ||
* Gets Soundcloud apps, using the Soundcloud v2 API. | ||
@@ -16,0 +8,0 @@ */ |
@@ -6,11 +6,2 @@ import type { SoundcloudComment } from "../types" | ||
/** | ||
* @deprecated use getV2 | ||
* Gets a comment using its ID. | ||
*/ | ||
public get = async (commentID: number) => { | ||
const response = await this.api.get(`/comments/${commentID}`) | ||
return response as Promise<SoundcloudComment> | ||
} | ||
/** | ||
* Gets a comment from its ID, using the Soundcloud v2 API. | ||
@@ -17,0 +8,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
import type { SoundcloudActivityCollection, SoundcloudConnection, SoundcloudUser } from "../types" | ||
import type { SoundcloudUser } from "../types" | ||
import { Base } from "." | ||
@@ -6,12 +6,2 @@ | ||
/** | ||
* @deprecated use getV2 | ||
* Gets your own profile, or your ID if pass in a true param. | ||
*/ | ||
public get = async <B extends boolean>(returnID?: B): Promise<B extends true ? number : SoundcloudUser> => { | ||
const response = await this.api.get("/me") | ||
if (returnID) return response.id | ||
return response | ||
} | ||
/** | ||
* Gets your own profile, using the Soundcloud v2 API. | ||
@@ -23,146 +13,2 @@ */ | ||
} | ||
/** | ||
* @deprecated | ||
* Gets activities from your homepage. | ||
*/ | ||
public activities = async () => { | ||
const response = await this.api.get("/me/activities") | ||
return response as Promise<SoundcloudActivityCollection> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets affiliated activities. | ||
*/ | ||
public activitiesAffiliated = async () => { | ||
const response = await this.api.get("/me/activities/tracks/affiliated") | ||
return response as Promise<SoundcloudActivityCollection> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets exclusive activities. | ||
*/ | ||
public activitiesExclusive = async () => { | ||
const response = await this.api.get("/me/activities/tracks/exclusive") | ||
return response as Promise<SoundcloudActivityCollection> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets your own activities only. | ||
*/ | ||
public activitiesOwn = async () => { | ||
const response = await this.api.get("/me/activities/all/own") | ||
return response as Promise<SoundcloudActivityCollection> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets your app connections, id any. | ||
*/ | ||
public connections = async () => { | ||
const response = await this.api.get("/me/connections") | ||
return response as Promise<SoundcloudConnection[]> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets a connection from its ID. | ||
*/ | ||
public connection = async (connectionID: number) => { | ||
const response = await this.api.get(`/me/connections/${connectionID}`) | ||
return response as Promise<SoundcloudConnection> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets your tracks. | ||
*/ | ||
public tracks = async () => { | ||
const id = await this.get(true) | ||
return this.sc.users.tracks(id) | ||
} | ||
/** | ||
* @deprecated | ||
* Gets your comments. | ||
*/ | ||
public comments = async () => { | ||
const id = await this.get(true) | ||
return this.sc.users.comments(id) | ||
} | ||
/** | ||
* @deprecated | ||
* Gets your favorites. | ||
*/ | ||
public favorites = async () => { | ||
const id = await this.get(true) | ||
return this.sc.users.favorites(id) | ||
} | ||
/** | ||
* @deprecated | ||
* Gets a favorite. | ||
*/ | ||
public favorite = async (userResolvable: string | number) => { | ||
const id = await this.get(true) | ||
return this.sc.users.favorite(id, userResolvable) | ||
} | ||
/** | ||
* @deprecated | ||
* Gets your followers. | ||
*/ | ||
public followers = async () => { | ||
const id = await this.get(true) | ||
return this.sc.users.followers(id) | ||
} | ||
/** | ||
* @deprecated | ||
* Gets a follower. | ||
*/ | ||
public follower = async (userResolvable: string | number) => { | ||
const id = await this.get(true) | ||
return this.sc.users.follower(id, userResolvable) | ||
} | ||
/** | ||
* @deprecated | ||
* Gets your followings. | ||
*/ | ||
public followings = async () => { | ||
const id = await this.get(true) | ||
return this.sc.users.followings(id) | ||
} | ||
/** | ||
* @deprecated | ||
* Gets a following. | ||
*/ | ||
public following = async (userResolvable: string | number) => { | ||
const id = await this.get(true) | ||
return this.sc.users.following(id, userResolvable) | ||
} | ||
/** | ||
* @deprecated | ||
* Gets your playlists. | ||
*/ | ||
public playlists = async () => { | ||
const id = await this.get(true) | ||
return this.sc.users.playlists(id) | ||
} | ||
/** | ||
* @deprecated | ||
* Gets your social networking profiles. | ||
*/ | ||
public webProfiles = async () => { | ||
const id = await this.get(true) | ||
return this.sc.users.webProfiles(id) | ||
} | ||
} |
import type { | ||
SoundcloudPlaylist, | ||
SoundcloudPlaylistFilter, | ||
SoundcloudPlaylistFilterV2, | ||
SoundcloudPlaylistSearchV2, | ||
SoundcloudPlaylistV2, | ||
SoundcloudSecretToken, | ||
} from "../types" | ||
@@ -19,3 +16,3 @@ import { Base } from "." | ||
if (unresolvedTracks.length === 0) return playlist | ||
playlist.tracks = playlist.tracks.concat(await this.sc.tracks.getArrayV2(unresolvedTracks)) | ||
playlist.tracks = playlist.tracks.concat(await this.sc.tracks.getArrayV2(unresolvedTracks, true)) | ||
return playlist | ||
@@ -25,11 +22,2 @@ } | ||
/** | ||
* @deprecated use searchV2 | ||
* Searches for playlists. | ||
*/ | ||
public search = async (params?: SoundcloudPlaylistFilter) => { | ||
const response = await this.api.get("/playlists", params) | ||
return response as Promise<SoundcloudPlaylist[]> | ||
} | ||
/** | ||
* Searches for playlists using the v2 API. | ||
@@ -43,13 +31,2 @@ */ | ||
/** | ||
* @deprecated use getV2 | ||
* Fetches a playlist from URL or ID. | ||
*/ | ||
public get = async (playlistResolvable: string | number) => { | ||
const playlistID = await this.sc.resolve.get(playlistResolvable, true) | ||
if (Object.prototype.hasOwnProperty.call(playlistID, "id")) return playlistID | ||
const response = await this.api.get(`/playlists/${playlistID}`) | ||
return response as Promise<SoundcloudPlaylist> | ||
} | ||
/** | ||
* Fetches a playlist from URL or ID using Soundcloud v2 API. | ||
@@ -59,3 +36,3 @@ */ | ||
const playlistID = await this.sc.resolve.getV2(playlistResolvable) | ||
const response = await this.api.getV2(`/playlists/${playlistID}`) | ||
const response = <SoundcloudPlaylistV2>await this.api.getV2(`/playlists/${playlistID}`) | ||
return this.fetch(response) as Promise<SoundcloudPlaylistV2> | ||
@@ -65,14 +42,2 @@ } | ||
/** | ||
* @deprecated | ||
* Requires Authentication - Gets the secret token from one of your playlists. | ||
*/ | ||
public secretToken = async (playlistResolvable: string | number) => { | ||
const playlistID = await this.sc.resolve.get(playlistResolvable) | ||
const response = await this.api | ||
.get(`/playlists/${playlistID}/secret-token`) | ||
.catch(() => Promise.reject("Oauth Token is required for this endpoint.")) | ||
return response as Promise<SoundcloudSecretToken> | ||
} | ||
/** | ||
* Searches for playlists (web scraping) | ||
@@ -79,0 +44,0 @@ */ |
@@ -6,19 +6,2 @@ import { Base } from "." | ||
/** | ||
* @deprecated | ||
* Gets the ID of a user/playlist/track from the Soundcloud URL. | ||
*/ | ||
public get = async (resolvable: string | number, full?: boolean) => { | ||
if (!String(resolvable).match(/\d{8,}/) && !String(resolvable).includes("soundcloud")) { | ||
resolvable = `https://soundcloud.com/${resolvable}` | ||
} | ||
let id = resolvable | ||
if (String(resolvable).includes("soundcloud")) { | ||
const resolved = await this.api.get("resolve", { url: resolvable }) | ||
if (full) return resolved | ||
id = resolved.id | ||
} | ||
return id | ||
} | ||
/** | ||
* Gets the ID from the html source. | ||
@@ -48,3 +31,3 @@ */ | ||
if (String(resolvable).includes("soundcloud")) { | ||
const resolved = await this.api.getV2("resolve", { url: resolvable }) | ||
const resolved = <any>await this.api.getV2("resolve", { url: resolvable }) | ||
if (full) return resolved | ||
@@ -51,0 +34,0 @@ id = resolved.id |
import type { | ||
SoundcloudComment, | ||
SoundcloudSecretToken, | ||
SoundcloudTrack, | ||
SoundcloudTrackFilter, | ||
SoundcloudTrackFilterV2, | ||
SoundcloudTrackSearchV2, | ||
SoundcloudTrackV2, | ||
SoundcloudUser, | ||
} from "../types" | ||
@@ -16,11 +11,2 @@ import { Base } from "." | ||
/** | ||
* @deprecated Use searchV2 | ||
* Searches for tracks. | ||
*/ | ||
public search = async (params?: SoundcloudTrackFilter) => { | ||
const response = await this.api.get("/tracks", params) | ||
return response as Promise<SoundcloudTrack[]> | ||
} | ||
/** | ||
* Searches for tracks using the v2 API. | ||
@@ -34,13 +20,2 @@ */ | ||
/** | ||
* @deprecated use getV2 | ||
* Fetches a track by URL or ID. | ||
*/ | ||
public get = async (trackResolvable: string | number) => { | ||
const id = await this.sc.resolve.get(trackResolvable, true) | ||
if (Object.prototype.hasOwnProperty.call(id, "id")) return id | ||
const response = await this.api.get(`/tracks/${id}`) | ||
return response as Promise<SoundcloudTrack> | ||
} | ||
/** | ||
* Fetches a track from URL or ID using Soundcloud v2 API. | ||
@@ -57,3 +32,3 @@ */ | ||
*/ | ||
public getArrayV2 = async (trackIds: number[]) => { | ||
public getArrayV2 = async (trackIds: number[], keepOrder: boolean = false) => { | ||
if (trackIds.length === 0) return [] | ||
@@ -65,60 +40,9 @@ // Max 50 ids per request => split into chunks of 50 ids | ||
const response: SoundcloudTrackV2[] = [] | ||
const tracks = await Promise.all(chunks.map(chunk => this.api.getV2("/tracks", { ids: chunk.join(",") }))) | ||
return response.concat(...tracks) | ||
const tracks = <SoundcloudTrackV2[][]>await Promise.all(chunks.map(chunk => this.api.getV2("/tracks", { ids: chunk.join(",") }))) | ||
const result = response.concat(...tracks) | ||
if (keepOrder) return result.sort((a, b) => trackIds.indexOf(a.id) - trackIds.indexOf(b.id)); | ||
return result | ||
} | ||
/** | ||
* @deprecated | ||
* Fetches all comments on a track. | ||
*/ | ||
public comments = async (trackResolvable: string | number) => { | ||
const trackID = await this.sc.resolve.get(trackResolvable) | ||
const response = await this.api.get(`/tracks/${trackID}/comments`) | ||
return response as Promise<SoundcloudComment[]> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets a specific comment. | ||
*/ | ||
public comment = async (trackResolvable: string | number, commentID: number) => { | ||
const trackID = await this.sc.resolve.get(trackResolvable) | ||
const response = await this.api.get(`/tracks/${trackID}/comments/${commentID}`) | ||
return response as Promise<SoundcloudComment> | ||
} | ||
/** | ||
* @deprecated | ||
* Get all users who favorited the track. | ||
*/ | ||
public favoriters = async (trackResolvable: string | number) => { | ||
const trackID = await this.sc.resolve.get(trackResolvable) | ||
const response = await this.api.get(`/tracks/${trackID}/favoriters`) | ||
return response as Promise<SoundcloudUser[]> | ||
} | ||
/** | ||
* @deprecated | ||
* Get a specific favoriter. | ||
*/ | ||
public favoriter = async (trackResolvable: string | number, userResolvable: string | number) => { | ||
const trackID = await this.sc.resolve.get(trackResolvable) | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const response = await this.api.get(`/tracks/${trackID}/favoriters/${userID}`) | ||
return response as Promise<SoundcloudUser> | ||
} | ||
/** | ||
* @deprecated | ||
* Requires Authentication - Gets the secret token from one of your own tracks. | ||
*/ | ||
public secretToken = async (trackResolvable: string | number) => { | ||
const trackID = await this.sc.resolve.get(trackResolvable) | ||
const response = await this.api | ||
.get(`/tracks/${trackID}/secret-token`) | ||
.catch(() => Promise.reject("Oauth Token is required for this endpoint.")) | ||
return response as Promise<SoundcloudSecretToken> | ||
} | ||
/** | ||
* Searches for tracks (web scraping) | ||
@@ -158,5 +82,5 @@ */ | ||
const trackID = await this.sc.resolve.getV2(trackResolvable) | ||
const response = await this.api.getV2(`/tracks/${trackID}/related`, { limit }) | ||
return response.collection as Promise<SoundcloudTrackV2[]> | ||
const response = <SoundcloudTrackSearchV2>await this.api.getV2(`/tracks/${trackID}/related`, { limit }) | ||
return response.collection | ||
} | ||
} |
import type { | ||
SoundcloudComment, | ||
SoundcloudPlaylist, | ||
SoundcloudTrack, | ||
SoundcloudTrackSearchV2, | ||
SoundcloudTrackV2, | ||
SoundcloudUser, | ||
SoundcloudUserCollection, | ||
SoundcloudUserFilter, | ||
SoundcloudUserFilterV2, | ||
@@ -20,11 +15,2 @@ SoundcloudUserSearchV2, | ||
/** | ||
* @deprecated use searchV2 | ||
* Searches for users. | ||
*/ | ||
public search = async (params?: SoundcloudUserFilter) => { | ||
const response = await this.api.get("/users", params) | ||
return response as Promise<SoundcloudUser[]> | ||
} | ||
/** | ||
* Searches for users using the v2 API. | ||
@@ -38,13 +24,2 @@ */ | ||
/** | ||
* @deprecated use getV2 | ||
* Gets a user by URL or ID. | ||
*/ | ||
public get = async (userResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable, true) | ||
if (Object.prototype.hasOwnProperty.call(userID, "id")) return userID | ||
const response = await this.api.get(`/users/${userID}`) | ||
return response as Promise<SoundcloudUser> | ||
} | ||
/** | ||
* Fetches a user from URL or ID using Soundcloud v2 API. | ||
@@ -59,11 +34,2 @@ */ | ||
/** | ||
* @deprecated | ||
* Gets all the tracks by the user. | ||
*/ | ||
public tracks = async (userResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const response = await this.api.get(`/users/${userID}/tracks`) | ||
return response as Promise<SoundcloudTrack[]> | ||
} | ||
/** | ||
* Gets all the tracks by the user using Soundcloud v2 API. | ||
@@ -73,3 +39,3 @@ */ | ||
const userID = await this.sc.resolve.getV2(userResolvable) | ||
const response = await this.api.getV2(`/users/${userID}/tracks`) | ||
const response = <SoundcloudTrackSearchV2>await this.api.getV2(`/users/${userID}/tracks`) | ||
let nextHref = response.next_href | ||
@@ -80,82 +46,10 @@ while (nextHref) { | ||
url.searchParams.forEach((value, key) => (params[key] = value)) | ||
const nextPage = await this.api.getURL(url.origin + url.pathname, params) | ||
const nextPage = <SoundcloudTrackSearchV2>await this.api.getURL(url.origin + url.pathname, params) | ||
response.collection.push(...nextPage.collection) | ||
nextHref = nextPage.next_href | ||
} | ||
return response.collection as Promise<SoundcloudTrackV2[]> | ||
return response.collection as SoundcloudTrackV2[] | ||
} | ||
/** | ||
* @deprecated | ||
* Gets all the playlists by the user. | ||
*/ | ||
public playlists = async (userResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const response = await this.api.get(`/users/${userID}/playlists`) | ||
return response as Promise<SoundcloudPlaylist[]> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets all the users the user is following. | ||
*/ | ||
public followings = async (userResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const response = await this.api.get(`/users/${userID}/followings`) | ||
return response as Promise<SoundcloudUserCollection> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets a specific following. | ||
*/ | ||
public following = async (userResolvable: string | number, anotherUserResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const followingID = await this.sc.resolve.get(anotherUserResolvable) | ||
const response = await this.api.get(`/users/${userID}/followings/${followingID}`) | ||
return response as Promise<SoundcloudUser> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets all of a users followers. | ||
*/ | ||
public followers = async (userResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const response = await this.api.get(`/users/${userID}/followers`) | ||
return response as Promise<SoundcloudUserCollection> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets a specific follower. | ||
*/ | ||
public follower = async (userResolvable: string | number, anotherUserResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const followerID = await this.sc.resolve.get(anotherUserResolvable) | ||
const response = await this.api.get(`/users/${userID}/followers/${followerID}`) | ||
return response as Promise<SoundcloudUser> | ||
} | ||
/** | ||
* @deprecated | ||
* Gets all comments by the user. | ||
*/ | ||
public comments = async (userResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const response = await this.api.get(`/users/${userID}/comments`) | ||
return response as Promise<SoundcloudComment[]> | ||
} | ||
/** | ||
* @deprecated use likes | ||
* Gets all of a users favorite tracks. | ||
*/ | ||
public favorites = async (userResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const response = await this.api.get(`/users/${userID}/favorites`) | ||
return response as Promise<SoundcloudTrack[]> | ||
} | ||
/** | ||
* Gets all of a users liked tracks. | ||
@@ -165,3 +59,3 @@ */ | ||
const userID = await this.sc.resolve.getV2(userResolvable) | ||
const response = await this.api.getV2(`/users/${userID}/likes`, { limit: 50, offset: 0 }) | ||
const response = <SoundcloudTrackSearchV2>await this.api.getV2(`/users/${userID}/likes`, { limit: 50, offset: 0 }) | ||
const tracks: SoundcloudTrackV2[] = [] | ||
@@ -173,3 +67,3 @@ let nextHref = response.next_href | ||
url.searchParams.forEach((value, key) => (params[key] = value)) | ||
const nextPage = await this.api.getURL(url.origin + url.pathname, params) | ||
const nextPage = <SoundcloudTrackSearchV2>await this.api.getURL(url.origin + url.pathname, params) | ||
tracks.push(...nextPage.collection) | ||
@@ -182,13 +76,2 @@ nextHref = nextPage.next_href | ||
/** | ||
* @deprecated | ||
* Gets a specific favorite track. | ||
*/ | ||
public favorite = async (userResolvable: string | number, trackResolvable: string | number) => { | ||
const userID = await this.sc.resolve.get(userResolvable) | ||
const trackID = await this.sc.resolve.get(trackResolvable) | ||
const response = await this.api.get(`/users/${userID}/favorites/${trackID}`) | ||
return response as Promise<SoundcloudTrack> | ||
} | ||
/** | ||
* Gets all the web profiles on a users sidebar. | ||
@@ -199,3 +82,3 @@ */ | ||
const response = await this.api.getV2(`/users/soundcloud:users:${userID}/web-profiles`) | ||
return response as Promise<SoundcloudWebProfile[]> | ||
return <SoundcloudWebProfile[]>response | ||
} | ||
@@ -202,0 +85,0 @@ |
@@ -50,3 +50,3 @@ import type { SoundcloudTrackV2, SoundcloudTranscoding } from "../types" | ||
.then(r => r.json()) | ||
.then(r => r.url as string) | ||
.then(r => (<{ url: string }>r).url) | ||
} catch { | ||
@@ -58,3 +58,3 @@ client_id = await this.api.getClientId(true) | ||
.then(r => r.json()) | ||
.then(r => r.url as string) | ||
.then(r => (<{ url: string }>r).url) | ||
} catch { | ||
@@ -162,3 +162,3 @@ return null | ||
.then(r => r.json()) | ||
.then(r => r.url) | ||
.then(r => (<{ url: string }>r).url) | ||
const destDir = path.join(__dirname, `tmp_${temp++}`) | ||
@@ -165,0 +165,0 @@ if (!fs.existsSync(destDir)) fs.mkdirSync(destDir, { recursive: true }) |
{ | ||
"name": "soundcloud.ts", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Soundcloud API v2 wrapper with typings.", | ||
@@ -15,5 +15,5 @@ "main": "dist/soundcloud.js", | ||
"test": "ts-mocha --timeout 30000 -p tsconfig.json test/**/*.spec.ts", | ||
"test:coverage": "nyc npm run test", | ||
"test:coverage": "nyc pnpm run test", | ||
"prettier": "prettier --write \"**/*.{ts,json,yml,yaml,md}\"", | ||
"prepack": "npm run build" | ||
"prepack": "pnpm run build" | ||
}, | ||
@@ -43,21 +43,19 @@ "repository": { | ||
"@istanbuljs/nyc-config-typescript": "^1.0.2", | ||
"@tenpi/tslint": "^1.1.0", | ||
"@tenpi/typedoc": "0.0.3", | ||
"@types/chai": "^4.3.5", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.3.3", | ||
"chai": "^4.3.7", | ||
"dotenv": "^16.3.1", | ||
"eslint": "^8.44.0", | ||
"eslint-config-distube": "^1.6.4", | ||
"ffmpeg-static": "^5.1.0", | ||
"mocha": "^10.2.0", | ||
"@types/chai": "^4.3.16", | ||
"@types/mocha": "^10.0.6", | ||
"@types/node": "^20.12.12", | ||
"chai": "^4.4.1", | ||
"dotenv": "^16.4.5", | ||
"eslint": "^8.57.0", | ||
"eslint-config-distube": "^1.7.0", | ||
"mocha": "^10.4.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.8.8", | ||
"prettier": "^3.2.5", | ||
"ts-mocha": "^10.0.0", | ||
"typedoc": "^0.24.8", | ||
"typescript": "^5.1.6" | ||
"typedoc": "^0.25.13", | ||
"typescript": "^5.4.5" | ||
}, | ||
"dependencies": { | ||
"undici": "^5.22.1" | ||
"undici": "^6.17.0" | ||
}, | ||
@@ -64,0 +62,0 @@ "nyc": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15
187109
4081
+ Addedundici@6.21.0(transitive)
- Removed@fastify/busboy@2.1.1(transitive)
- Removedundici@5.28.4(transitive)
Updatedundici@^6.17.0