Types Improved

This commit is contained in:
killer069
2021-09-27 22:20:50 +05:30
parent 842d704bf2
commit 70d1774508
12 changed files with 104 additions and 131 deletions

View File

@@ -1,8 +1,8 @@
import { request } from './utils/request';
import { ParseSearchInterface, ParseSearchResult } from './utils/parser';
import { Video } from './classes/Video';
import { Channel } from './classes/Channel';
import { PlayList } from './classes/Playlist';
import { YouTubeVideo } from './classes/Video';
import { YouTubeChannel } from './classes/Channel';
import { YouTubePlayList } from './classes/Playlist';
enum SearchType {
Video = 'EgIQAQ%253D%253D',
@@ -10,10 +10,9 @@ enum SearchType {
Channel = 'EgIQAg%253D%253D'
}
export async function yt_search(
search: string,
options: ParseSearchInterface = {}
): Promise<(Video | Channel | PlayList)[]> {
export type YouTube = YouTubeVideo | YouTubeChannel | YouTubePlayList;
export async function yt_search(search: string, options: ParseSearchInterface = {}): Promise<YouTube[]> {
let url = 'https://www.youtube.com/results?search_query=' + search.replaceAll(' ', '+');
options.type ??= 'video';
if (!url.match('&sp=')) {