Some huge changes

This commit is contained in:
killer069
2021-11-18 15:38:25 +05:30
parent e53e892606
commit 81e6bc0092
58 changed files with 648 additions and 181 deletions

View File

@@ -11,7 +11,7 @@ export {
} from './YouTube';
export { spotify, sp_validate, refreshToken, is_expired, Spotify } from './Spotify';
export { soundcloud, so_validate, SoundCloud, SoundCloudStream, getFreeClientID } from './SoundCloud';
export { deezer, dz_validate, dz_search, dz_advanced_track_search, Deezer } from './Deezer';
export { deezer, dz_validate, dz_advanced_track_search, Deezer } from './Deezer';
export { setToken } from './token';
enum AudioPlayerStatus {
@@ -30,6 +30,7 @@ interface SearchOptions {
soundcloud?: 'tracks' | 'playlists' | 'albums';
deezer?: 'track' | 'playlist' | 'album';
};
fuzzy?: boolean;
}
import readline from 'node:readline';
@@ -46,11 +47,17 @@ import {
} from '.';
import { SpotifyAuthorize, sp_search } from './Spotify';
import { check_id, so_search, stream as so_stream, stream_from_info as so_stream_info } from './SoundCloud';
import { InfoData, stream as yt_stream, StreamOptions, stream_from_info as yt_stream_info } from './YouTube/stream';
import { SoundCloudTrack } from './SoundCloud/classes';
import { stream as yt_stream, StreamOptions, stream_from_info as yt_stream_info } from './YouTube/stream';
import { SoundCloudPlaylist, SoundCloudTrack } from './SoundCloud/classes';
import { yt_search } from './YouTube/search';
import { EventEmitter } from 'stream';
import { Deezer, dz_search, dz_validate } from './Deezer';
import { InfoData } from './YouTube/utils/constants';
import { YouTubeVideo } from './YouTube/classes/Video';
import { YouTubePlayList } from './YouTube/classes/Playlist';
import { YouTubeChannel } from './YouTube/classes/Channel';
import { SpotifyAlbum, SpotifyPlaylist, SpotifyTrack } from './Spotify/classes';
import { DeezerAlbum, DeezerPlaylist, DeezerTrack } from './Deezer/classes';
/**
* Main stream Command for streaming through various sources
* @param url The video / track url to make stream of
@@ -79,7 +86,21 @@ export async function stream(url: string, options: StreamOptions = {}): Promise<
* @param query string to search.
* @param options contains limit and source to choose.
* @returns Array of YouTube or Spotify or SoundCloud or Deezer
deezer?: 'track' | 'playlist' | 'album';
*/
export async function search( query: string, options: { source : { deezer : "album" } } & SearchOptions) : Promise<DeezerAlbum[]>;
export async function search( query: string, options: { source : { deezer : "playlist" } } & SearchOptions) : Promise<DeezerPlaylist[]>;
export async function search( query: string, options: { source : { deezer : "track" } } & SearchOptions) : Promise<DeezerTrack[]>;
export async function search( query: string, options: { source : { soundcloud : "albums" } } & SearchOptions) : Promise<SoundCloudPlaylist[]>;
export async function search( query: string, options: { source : { soundcloud : "playlists" } } & SearchOptions) : Promise<SoundCloudPlaylist[]>;
export async function search( query: string, options: { source : { soundcloud : "tracks" } } & SearchOptions) : Promise<SoundCloudTrack[]>;
export async function search( query: string, options: { source : { spotify : "album" } } & SearchOptions) : Promise<SpotifyAlbum[]>;
export async function search( query: string, options: { source : { spotify : "playlist" } } & SearchOptions) : Promise<SpotifyPlaylist[]>;
export async function search( query: string, options: { source : { spotify : "track" } } & SearchOptions) : Promise<SpotifyTrack[]>;
export async function search( query: string, options: { source : { youtube : "channel" } } & SearchOptions) : Promise<YouTubeChannel[]>;
export async function search( query: string, options: { source : { youtube : "playlist" } } & SearchOptions) : Promise<YouTubePlayList[]>;
export async function search( query: string, options: { source : { youtube : "video" } } & SearchOptions) : Promise<YouTubeVideo[]>;
export async function search(
query: string,
options: SearchOptions = {}
@@ -90,7 +111,7 @@ export async function search(
else if (options.source.spotify) return await sp_search(query, options.source.spotify, options.limit);
else if (options.source.soundcloud) return await so_search(query, options.source.soundcloud, options.limit);
else if (options.source.deezer)
return await dz_search(query, { limit: options.limit, type: options.source.deezer });
return await dz_search(query, { limit: options.limit, type: options.source.deezer, fuzzy : options.fuzzy });
else throw new Error('Not possible to reach Here LOL. Easter Egg of play-dl if someone get this.');
}