play-dl-fix/play-dl/token.ts
2021-12-07 10:43:23 +05:30

41 lines
1.0 KiB
TypeScript

import { setUserAgent } from './Request/useragent';
import { setSoundCloudToken } from './SoundCloud';
import { setSpotifyToken } from './Spotify';
import { setCookieToken } from './YouTube/utils/cookie';
interface tokenOptions {
spotify?: {
client_id: string;
client_secret: string;
refresh_token: string;
market: string;
};
soundcloud?: {
client_id: string;
};
youtube?: {
cookie: string;
};
useragent?: string[];
}
/**
* Sets
*
* i> YouTube :- cookies.
*
* ii> SoundCloud :- client ID.
*
* iii> Spotify :- client ID, client secret, refresh token, market.
*
* iv> Useragents :- array of string.
*
* locally in memory.
* @param options {@link tokenOptions}
*/
export function setToken(options: tokenOptions) {
if (options.spotify) setSpotifyToken(options.spotify);
if (options.soundcloud) setSoundCloudToken(options.soundcloud);
if (options.youtube) setCookieToken(options.youtube);
if (options.useragent) setUserAgent(options.useragent);
}