pretty codes and LiveStream issues fixed 100%

This commit is contained in:
killer069
2021-09-28 21:05:43 +05:30
parent 9ab641d1f0
commit 20984ce9e9
5 changed files with 120 additions and 96 deletions

View File

@@ -13,7 +13,16 @@ interface SearchOptions {
import readline from 'readline';
import fs from 'fs';
import { sp_validate, yt_validate, so_validate, YouTubeStream, SoundCloudStream, YouTube, SoundCloud, Spotify } from '.';
import {
sp_validate,
yt_validate,
so_validate,
YouTubeStream,
SoundCloudStream,
YouTube,
SoundCloud,
Spotify
} 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';
@@ -39,17 +48,20 @@ export async function stream(url: string, options: StreamOptions = {}): Promise<
* @param options contains limit and source to choose.
* @returns
*/
export async function search(query: string, options: SearchOptions = {}): Promise<YouTube[] | Spotify[] | SoundCloud[]> {
export async function search(
query: string,
options: SearchOptions = {}
): Promise<YouTube[] | Spotify[] | SoundCloud[]> {
if (!options.source) options.source = { youtube: 'video' };
if (options.source.youtube) return await yt_search(query, { limit: options.limit, type: options.source.youtube });
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 throw new Error('Not possible to reach Here LOL. Easter Egg of play-dl if someone get this.')
else throw new Error('Not possible to reach Here LOL. Easter Egg of play-dl if someone get this.');
}
/**
* Command to be used
* Command to be used
* @param info
* @param options
* @returns