Browse Source

ref: cleanup

Sv443 1 year ago
parent
commit
d5eca9852f
2 changed files with 5 additions and 22 deletions
  1. 1 18
      src/features/lyrics.ts
  2. 4 4
      src/observers.ts

+ 1 - 18
src/features/lyrics.ts

@@ -1,4 +1,4 @@
-import { ConfigManager, clamp, compress, decompress, fetchAdvanced, insertAfter } from "@sv443-network/userutils";
+import { ConfigManager, compress, decompress, fetchAdvanced, insertAfter } from "@sv443-network/userutils";
 import { constructUrlString, error, getResourceUrl, info, log, onSelectorOld, warn, t, tp } from "../utils";
 import { emitInterface } from "../interface";
 import { compressionFormat, scriptInfo } from "../constants";
@@ -8,18 +8,9 @@ import type { LyricsCacheEntry } from "../types";
 export const geniUrlBase = "https://api.sv443.net/geniurl";
 /** GeniURL endpoint that gives song metadata when provided with a `?q` or `?artist` and `?song` parameter - [more info](https://api.sv443.net/geniurl) */
 const geniURLSearchTopUrl = `${geniUrlBase}/search/top`;
-/**
- * The threshold to pass to geniURL's fuzzy filtering.  
- * From fuse.js docs: At what point does the match algorithm give up. A threshold of 0.0 requires a perfect match (of both letters and location), a threshold of 1.0 would match anything.  
- * Set to undefined to use the default.
- */
-const threshold = 0.55;
 /** Ratelimit budget timeframe in seconds - should reflect what's in geniURL's docs */
 const geniUrlRatelimitTimeframe = 30;
 
-const thresholdParam = threshold ? `&threshold=${clamp(threshold, 0, 1)}` : "";
-void thresholdParam; // TODO: re-add once geniURL 1.4 is released
-
 //#MARKER new cache
 
 /** How many cache entries can exist at a time - this is used to cap memory usage */
@@ -39,14 +30,6 @@ const lyricsCache = new ConfigManager<LyricsCache>({
   formatVersion: 1,
   encodeData: (data) => compress(data, compressionFormat, "string"),
   decodeData: (data) => decompress(data, compressionFormat, "string"),
-  // migrations: {
-  //   // 1 -> 2
-  //   2: (oldData: Record<string, unknown>) => {
-  //     return {
-  //       cache: oldData.cache,
-  //     };
-  //   },
-  // }
 });
 
 export async function initLyricsCache() {

+ 4 - 4
src/observers.ts

@@ -1,7 +1,7 @@
 import { SelectorListenerOptions, SelectorObserver, SelectorObserverOptions } from "@sv443-network/userutils";
 import type { ObserverName } from "./types";
 import { emitInterface } from "./interface";
-import { error } from "./utils";
+import { error, log } from "./utils";
 
 /** Options that are applied to every SelectorObserver instance */
 const defaultObserverOptions: SelectorObserverOptions = {
@@ -28,7 +28,7 @@ export function initObservers() {
     });
     observers.body.addListener(playerBarSelector, {
       listener: () => {
-        console.log("#DBG-UU enabling playerBar observer");
+        log("#DBG-UU enabling playerBar observer");
         observers.playerBar.enable();
       },
     });
@@ -42,7 +42,7 @@ export function initObservers() {
     });
     observers.playerBarInfo.addListener(playerBarInfoSelector, {
       listener: () => {
-        console.log("#DBG-UU enabling playerBarTitle observer");
+        log("#DBG-UU enabling playerBarTitle observer");
         observers.playerBarInfo.enable();
       },
     });
@@ -51,7 +51,7 @@ export function initObservers() {
     observers.playerBarInfo.addListener("yt-formatted-string.title", {
       continuous: true,
       listener: (titleElem) => {
-        console.log("#DBG-UU >>>>> title changed", titleElem.title);
+        log("#DBG-UU >>>>> title changed", titleElem.title);
       },
     });