Quellcode durchsuchen

fix: ?q param instead of ?artist and ?song

Sv443 vor 11 Monaten
Ursprung
Commit
4f106b123c
2 geänderte Dateien mit 5 neuen und 7 gelöschten Zeilen
  1. 2 4
      src/features/lyrics.ts
  2. 3 3
      src/utils/xhr.ts

+ 2 - 4
src/features/lyrics.ts

@@ -223,10 +223,8 @@ export async function fetchLyricsUrls(artist: string, song: string): Promise<Omi
     const startTs = Date.now();
     const fetchUrl = constructUrl(`${getFeature("geniUrlBase")}/search`, {
       disableFuzzy: null,
-      utm_source: scriptInfo.name,
-      utm_content: `v${scriptInfo.version}${mode === "development" ? "-dev" : ""}`,
-      artist,
-      song,
+      utm_source: `${scriptInfo.name} v${scriptInfo.version}${mode === "development" ? "-pre" : ""}`,
+      q: `${artist} ${song}`,
     });
 
     log("Requesting lyrics from geniURL:", fetchUrl);

+ 3 - 3
src/utils/xhr.ts

@@ -5,14 +5,14 @@ import { error } from "./logging";
 
 /**
  * Constructs a URL from a base URL and a record of query parameters.  
- * If a value is null, the parameter will be valueless.  
+ * If a value is null, the parameter will be valueless. If a value is undefined, the parameter will be omitted.  
  * All values will be stringified using their `toString()` method and then URI-encoded.
  * @returns Returns a string instead of a URL object
  */
 export function constructUrlString(baseUrl: string, params: Record<string, Stringifiable | null>) {
   return `${baseUrl}?${
     Object.entries(params)
-      .filter(([,v]) => v !== undefined)
+      .filter(([, v]) => v !== undefined)
       .map(([key, val]) => `${key}${val === null ? "" : `=${encodeURIComponent(String(val))}`}`)
       .join("&")
   }`;
@@ -20,7 +20,7 @@ export function constructUrlString(baseUrl: string, params: Record<string, Strin
 
 /**
  * Constructs a URL object from a base URL and a record of query parameters.  
- * If a value is null, the parameter will be valueless.  
+ * If a value is null, the parameter will be valueless. If a value is undefined, the parameter will be omitted.  
  * All values will be URI-encoded.  
  * @returns Returns a URL object instead of a string
  */