Added decipher_info function for converting from video_basic_info to video_info data.
 Changed SpotifyAlbum property from trackCount to tracksCount
 Added getFreeClientID to get free soundCloud client ID.
This commit is contained in:
Killer069 2021-10-18 17:22:29 +05:30 committed by GitHub
commit 5e3ab7f3b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 5 deletions

View File

@ -12,6 +12,20 @@ let data = await soundcloud(url) //Gets the data
console.log(data.type) // Console logs the type of data that you got.
```
### getFreeClientID()
_This returns free client ID._
```js
const client_id = await getFreeClientID()
setToken({
soundcloud : {
client_id : client_id
}
}) // This will set client ID for use in play-dl.
```
## Validate
### so_validate(url : `string`)

View File

@ -85,6 +85,23 @@ export async function stream(url: string, quality?: number): Promise<Stream> {
: StreamType.Arbitrary;
return new Stream(s_data.url, type);
}
/**
* Function to get Free Client ID of soundcloud.
* @returns client ID
*/
export async function getFreeClientID(): Promise<string>{
const data = await request('https://soundcloud.com/')
const splitted = data.split('<script crossorigin src="')
const urls: string[] = []
splitted.forEach((r) => {
if(r.startsWith('https')) {
urls.push(r.split('"')[0])
}
})
const data2 = await request(urls[urls.length - 1])
return data2.split(',client_id:"')[1].split('"')[0]
}
/**
* Type for SoundCloud Stream
*/

View File

@ -200,7 +200,7 @@ export class SpotifyAlbum {
copyrights: SpotifyCopyright[];
release_date: string;
release_date_precision: string;
trackCount: number;
tracksCount: number;
private spotifyData: SpotifyDataOptions;
private fetched_tracks: Map<string, SpotifyTrack[]>;
constructor(data: any, spotifyData: SpotifyDataOptions) {
@ -221,7 +221,7 @@ export class SpotifyAlbum {
this.copyrights = data.copyrights;
this.release_date = data.release_date;
this.release_date_precision = data.release_date_precision;
this.trackCount = data.total_tracks;
this.tracksCount = data.total_tracks;
const videos: SpotifyTrack[] = [];
data.tracks.items.forEach((v: any) => {
videos.push(new SpotifyTrack(v));
@ -233,8 +233,8 @@ export class SpotifyAlbum {
async fetch() {
let fetching: number;
if (this.trackCount > 500) fetching = 500;
else fetching = this.trackCount;
if (this.tracksCount > 500) fetching = 500;
else fetching = this.tracksCount;
if (fetching <= 50) return;
const work = [];
for (let i = 2; i <= Math.ceil(fetching / 50); i++) {

View File

@ -9,7 +9,7 @@ export {
YouTubeStream
} from './YouTube';
export { spotify, sp_validate, refreshToken, is_expired, Spotify } from './Spotify';
export { soundcloud, so_validate, SoundCloud, SoundCloudStream } from './SoundCloud';
export { soundcloud, so_validate, SoundCloud, SoundCloudStream, getFreeClientID } from './SoundCloud';
export { setToken } from './token';
enum AudioPlayerStatus {