1.2.0
Search Function order is fixed.
This commit is contained in:
commit
22b11c8067
@ -156,7 +156,7 @@ export async function sp_search(
|
||||
if (query.length === 0) throw new Error('Pass some query to search.');
|
||||
if (limit > 50 || limit < 0) throw new Error(`You crossed limit range of Spotify [ 0 - 50 ]`);
|
||||
const response = await request(
|
||||
`https://api.spotify.com/v1/search?type=${type}&q=${query.replaceAll(' ', '+')}&limit=${limit}&market=${
|
||||
`https://api.spotify.com/v1/search?type=${type}&q=${query}&limit=${limit}&market=${
|
||||
spotifyData.market
|
||||
}`,
|
||||
{
|
||||
|
||||
@ -21,7 +21,7 @@ export type YouTube = YouTubeVideo | YouTubeChannel | YouTubePlayList;
|
||||
* @returns YouTube type.
|
||||
*/
|
||||
export async function yt_search(search: string, options: ParseSearchInterface = {}): Promise<YouTube[]> {
|
||||
let url = 'https://www.youtube.com/results?search_query=' + search.replaceAll(' ', '+');
|
||||
let url = 'https://www.youtube.com/results?search_query=' + search;
|
||||
options.type ??= 'video';
|
||||
if (!url.match('&sp=')) {
|
||||
url += '&sp=';
|
||||
|
||||
@ -77,7 +77,7 @@ export async function search(
|
||||
options: SearchOptions = {}
|
||||
): Promise<YouTube[] | Spotify[] | SoundCloud[]> {
|
||||
if (!options.source) options.source = { youtube: 'video' };
|
||||
|
||||
query = encodeURIComponent(query)
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user