forked from github-mirror/Verome-API
Update search filter params for better results
This commit is contained in:
20
lib.ts
20
lib.ts
@@ -28,9 +28,12 @@ export class YTMusic {
|
|||||||
// Normalize the query to handle Arabic and other Unicode characters properly
|
// Normalize the query to handle Arabic and other Unicode characters properly
|
||||||
const normalizedQuery = query.normalize("NFC");
|
const normalizedQuery = query.normalize("NFC");
|
||||||
|
|
||||||
|
const filterParams = this.getFilterParams(filter);
|
||||||
const params: any = continuationToken
|
const params: any = continuationToken
|
||||||
? { continuation: continuationToken }
|
? { continuation: continuationToken }
|
||||||
: { query: normalizedQuery, params: this.getFilterParams(filter) };
|
: filterParams
|
||||||
|
? { query: normalizedQuery, params: filterParams }
|
||||||
|
: { query: normalizedQuery };
|
||||||
|
|
||||||
const data = await this.makeRequest("search", params);
|
const data = await this.makeRequest("search", params);
|
||||||
return this.parseSearchResults(data);
|
return this.parseSearchResults(data);
|
||||||
@@ -243,15 +246,18 @@ export class YTMusic {
|
|||||||
return response.json();
|
return response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getFilterParams(filter?: string): string {
|
private getFilterParams(filter?: string): string | undefined {
|
||||||
|
// Return undefined for no filter (searches everything)
|
||||||
|
if (!filter) return undefined;
|
||||||
|
|
||||||
const filterMap: Record<string, string> = {
|
const filterMap: Record<string, string> = {
|
||||||
songs: "Eg-KAQwIARAAGAAgACgAMABqChAEEAUQAxAKEAk%3D",
|
songs: "EgWKAQIIAWoKEAMQBBAJEAoQBQ%3D%3D",
|
||||||
videos: "Eg-KAQwIABABGAAgACgAMABqChAEEAUQAxAKEAk%3D",
|
videos: "EgWKAQIQAWoKEAMQBBAJEAoQBQ%3D%3D",
|
||||||
albums: "Eg-KAQwIABAAGAEgACgAMABqChAEEAUQAxAKEAk%3D",
|
albums: "EgWKAQIYAWoKEAMQBBAJEAoQBQ%3D%3D",
|
||||||
artists: "EgWKAQIgAWoKEAMQBBAJEAoQBQ%3D%3D",
|
artists: "EgWKAQIgAWoKEAMQBBAJEAoQBQ%3D%3D",
|
||||||
playlists: "Eg-KAQwIABAAGAAgACgBMABqChAEEAUQAxAKEAk%3D",
|
playlists: "EgWKAQIoAWoKEAMQBBAJEAoQBQ%3D%3D",
|
||||||
};
|
};
|
||||||
return filterMap[filter || ""] || filterMap.songs;
|
return filterMap[filter] || undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
private parseSearchResults(data: any) {
|
private parseSearchResults(data: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user