1.1.8
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:
commit
5e3ab7f3b0
@ -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.
|
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
|
## Validate
|
||||||
|
|
||||||
### so_validate(url : `string`)
|
### so_validate(url : `string`)
|
||||||
|
|||||||
@ -85,6 +85,23 @@ export async function stream(url: string, quality?: number): Promise<Stream> {
|
|||||||
: StreamType.Arbitrary;
|
: StreamType.Arbitrary;
|
||||||
return new Stream(s_data.url, type);
|
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
|
* Type for SoundCloud Stream
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -200,7 +200,7 @@ export class SpotifyAlbum {
|
|||||||
copyrights: SpotifyCopyright[];
|
copyrights: SpotifyCopyright[];
|
||||||
release_date: string;
|
release_date: string;
|
||||||
release_date_precision: string;
|
release_date_precision: string;
|
||||||
trackCount: number;
|
tracksCount: number;
|
||||||
private spotifyData: SpotifyDataOptions;
|
private spotifyData: SpotifyDataOptions;
|
||||||
private fetched_tracks: Map<string, SpotifyTrack[]>;
|
private fetched_tracks: Map<string, SpotifyTrack[]>;
|
||||||
constructor(data: any, spotifyData: SpotifyDataOptions) {
|
constructor(data: any, spotifyData: SpotifyDataOptions) {
|
||||||
@ -221,7 +221,7 @@ export class SpotifyAlbum {
|
|||||||
this.copyrights = data.copyrights;
|
this.copyrights = data.copyrights;
|
||||||
this.release_date = data.release_date;
|
this.release_date = data.release_date;
|
||||||
this.release_date_precision = data.release_date_precision;
|
this.release_date_precision = data.release_date_precision;
|
||||||
this.trackCount = data.total_tracks;
|
this.tracksCount = data.total_tracks;
|
||||||
const videos: SpotifyTrack[] = [];
|
const videos: SpotifyTrack[] = [];
|
||||||
data.tracks.items.forEach((v: any) => {
|
data.tracks.items.forEach((v: any) => {
|
||||||
videos.push(new SpotifyTrack(v));
|
videos.push(new SpotifyTrack(v));
|
||||||
@ -233,8 +233,8 @@ export class SpotifyAlbum {
|
|||||||
|
|
||||||
async fetch() {
|
async fetch() {
|
||||||
let fetching: number;
|
let fetching: number;
|
||||||
if (this.trackCount > 500) fetching = 500;
|
if (this.tracksCount > 500) fetching = 500;
|
||||||
else fetching = this.trackCount;
|
else fetching = this.tracksCount;
|
||||||
if (fetching <= 50) return;
|
if (fetching <= 50) return;
|
||||||
const work = [];
|
const work = [];
|
||||||
for (let i = 2; i <= Math.ceil(fetching / 50); i++) {
|
for (let i = 2; i <= Math.ceil(fetching / 50); i++) {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ export {
|
|||||||
YouTubeStream
|
YouTubeStream
|
||||||
} from './YouTube';
|
} from './YouTube';
|
||||||
export { spotify, sp_validate, refreshToken, is_expired, Spotify } from './Spotify';
|
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';
|
export { setToken } from './token';
|
||||||
|
|
||||||
enum AudioPlayerStatus {
|
enum AudioPlayerStatus {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user