Ver Fonte

feat: configurable lyrics error toast

Sv443 há 7 meses atrás
pai
commit
a532c22395

+ 9 - 9
assets/translations/README.md

@@ -16,15 +16,15 @@ To submit or edit a translation, please follow [this guide](../../contributing.m
 ### Translation progress:
 |   | Locale | Translated keys | Based on |
 | :----: | ------ | --------------- | :------: |
-|  | [`en_US`](./en_US.json) | `300` (default locale) |  |
-| ✅ | [`de_DE`](./de_DE.json) | `300/300` (100%) | ─ |
-|  | [`en_UK`](./en_UK.json) | `300/300` (100%) | `en_US` |
-| ✅ | [`es_ES`](./es_ES.json) | `300/300` (100%) | ─ |
-| ✅ | [`fr_FR`](./fr_FR.json) | `300/300` (100%) | ─ |
-| ✅ | [`hi_IN`](./hi_IN.json) | `300/300` (100%) | ─ |
-| ✅ | [`ja_JA`](./ja_JA.json) | `300/300` (100%) | ─ |
-| ✅ | [`pt_BR`](./pt_BR.json) | `300/300` (100%) | ─ |
-| ✅ | [`zh_CN`](./zh_CN.json) | `300/300` (100%) | ─ |
+|  | [`en_US`](./en_US.json) | `301` (default locale) |  |
+| ✅ | [`de_DE`](./de_DE.json) | `301/301` (100%) | ─ |
+|  | [`en_UK`](./en_UK.json) | `301/301` (100%) | `en_US` |
+| ✅ | [`es_ES`](./es_ES.json) | `301/301` (100%) | ─ |
+| ✅ | [`fr_FR`](./fr_FR.json) | `301/301` (100%) | ─ |
+| ✅ | [`hi_IN`](./hi_IN.json) | `301/301` (100%) | ─ |
+| ✅ | [`ja_JA`](./ja_JA.json) | `301/301` (100%) | ─ |
+| ✅ | [`pt_BR`](./pt_BR.json) | `301/301` (100%) | ─ |
+| ✅ | [`zh_CN`](./zh_CN.json) | `301/301` (100%) | ─ |
 
 <sub>
 ✅ - Fully translated

+ 1 - 0
assets/translations/de_DE.json

@@ -284,6 +284,7 @@
     "feature_btn_autoLikeOpenMgmtDialog_running": "Wird geöffnet...",
 
     "feature_desc_geniusLyrics": "Füge einen Knopf zu dem aktuell spielenden Song hinzu, um den Songtext auf genius.com zu öffnen",
+    "feature_desc_errorOnLyricsNotFound": "Zeige einen Error, wenn die Songtext-Seite für den aktuell spielenden Song nicht gefunden werden konnte",
     "feature_desc_geniUrlBase": "Base URL deiner geniURL Instanz, siehe https://github.com/Sv443/geniURL",
     "feature_helptext_geniUrlBase": "Wenn du deine eigene geniURL Instanz laufen hast (zum Beispiel um Rate Limiting zu umgehen), kannst du hier ihre Base URL eingeben, um sie für die genius.com Songtext-Suche zu benutzen.\nWenn du nicht weißt, was das ist, kannst du diese Option so lassen, wie sie ist.",
     "feature_desc_geniUrlToken": "Auth Token deiner geniURL Instanz",

+ 1 - 0
assets/translations/en_US.json

@@ -284,6 +284,7 @@
     "feature_btn_autoLikeOpenMgmtDialog_running": "Opening...",
 
     "feature_desc_geniusLyrics": "Add a button to the media controls of the currently playing song to open its lyrics on genius.com",
+    "feature_desc_errorOnLyricsNotFound": "Show an error when the lyrics page for the currently playing song couldn't be found",
     "feature_desc_geniUrlBase": "Base URL of your geniURL instance, see https://github.com/Sv443/geniURL",
     "feature_helptext_geniUrlBase": "If you have your own instance of geniURL running (for example to bypass rate limiting), you can enter its base URL here to use it for the genius.com lyrics button.\nIf you don't know what this is, you can leave this option as is.",
     "feature_desc_geniUrlToken": "Auth token for your geniURL instance",

+ 1 - 0
assets/translations/es_ES.json

@@ -276,6 +276,7 @@
     "feature_btn_autoLikeOpenMgmtDialog_running": "Abriendo...",
 
     "feature_desc_geniusLyrics": "Agregue un botón a los controles multimedia de la canción que se está reproduciendo actualmente para abrir sus letras en genius.com",
+    "feature_desc_errorOnLyricsNotFound": "Mostrar un error cuando no se pudo encontrar la página de letras para la canción que se está reproduciendo actualmente",
     "feature_desc_geniUrlBase": "Base URL de su instancia de geniURL, consulte https://github.com/Sv443/geniURL",
     "feature_helptext_geniUrlBase": "Si tiene su propia instancia de geniURL en ejecución (por ejemplo, para evitar la limitación de velocidad), puede ingresar su base URL aquí para usarla para el botón de letras de genius.com.\nSi no sabe qué es esto, puede dejar esta opción como está.",
     "feature_desc_geniUrlToken": "Token de autenticación para su instancia de geniURL",

+ 1 - 0
assets/translations/fr_FR.json

@@ -276,6 +276,7 @@
     "feature_btn_autoLikeOpenMgmtDialog_running": "Ouverture...",
 
     "feature_desc_geniusLyrics": "Ajouter un bouton aux contrôles multimédias de la chanson en cours de lecture pour ouvrir ses paroles sur genius.com",
+    "feature_desc_errorOnLyricsNotFound": "Afficher une erreur lorsque la page de paroles pour la chanson en cours de lecture n'a pas pu être trouvée",
     "feature_desc_geniUrlBase": "URL de base de votre instance geniURL, voir https://github.com/Sv443/geniURL",
     "feature_helptext_geniUrlBase": "Si vous avez votre propre instance de geniURL en cours d'exécution (par exemple pour contourner la limitation du taux), vous pouvez entrer son URL de base ici pour l'utiliser pour le bouton de paroles de genius.com.\nSi vous ne savez pas ce que c'est, vous pouvez laisser cette option telle quelle.",
     "feature_desc_geniUrlToken": "Jeton d'authentification pour votre instance geniURL",

+ 1 - 0
assets/translations/hi_IN.json

@@ -276,6 +276,7 @@
     "feature_btn_autoLikeOpenMgmtDialog_running": "खोल रहा है...",
 
     "feature_desc_geniusLyrics": "वर्तमान में चल रहे गीत के मीडिया नियंत्रणों में एक बटन जो genius.com पर इसके बोल खोलता है",
+    "feature_desc_errorOnLyricsNotFound": "वर्तमान में चल रहे गीत के लिए बोल पृष्ठ नहीं मिलने पर एक त्रुटि दिखाएं",
     "feature_desc_geniUrlBase": "आपके geniURL इंस्टेंस का बेस URL, https://github.com/Sv443/geniURL देखें",
     "feature_helptext_geniUrlBase": "यदि आपके पास अपना geniURL इंस्टेंस चल रहा है (उदाहरण के लिए रेट लिमिटिंग को छोड़ने के लिए), तो आप इसका बेस URL यहां दर्ज कर सकते हैं ताकि आप genius.com बोल बटन के लिए इसका उपयोग कर सकें।\nयदि आप नहीं जानते कि यह क्या है, तो आप इस विकल्प को वैसे ही छोड़ सकते हैं।",
     "feature_desc_geniUrlToken": "आपके geniURL इंस्टेंस के लिए एक ऑथ टोकन",

+ 1 - 0
assets/translations/ja_JA.json

@@ -276,6 +276,7 @@
     "feature_btn_autoLikeOpenMgmtDialog_running": "開いています...",
 
     "feature_desc_geniusLyrics": "現在再生中の曲のメディアコントロールにボタンを追加して、genius.com で歌詞を開く",
+    "feature_desc_errorOnLyricsNotFound": "現在再生中の曲の歌詞ページが見つからなかった場合にエラーを表示する",
     "feature_desc_geniUrlBase": "geniURL インスタンスのベース URL。https://github.com/Sv443/geniURL を参照してください。",
     "feature_helptext_geniUrlBase": "自分の geniURL インスタンスを実行している場合(例えばレート制限をバイパスするため)、ここにそのベース URL を入力して、genius.com の歌詞ボタンに使用できます。\nこれが何かわからない場合は、このオプションをそのままにしておくことができます。",
     "feature_desc_geniUrlToken": "geniURL インスタンスの認証トークン",

+ 1 - 0
assets/translations/pt_BR.json

@@ -276,6 +276,7 @@
     "feature_btn_autoLikeOpenMgmtDialog_running": "Abrindo...",
 
     "feature_desc_geniusLyrics": "Adicione um botão aos controles de mídia da música que está tocando atualmente para abrir suas letras em genius.com",
+    "feature_desc_errorOnLyricsNotFound": "Mostrar um erro quando a página de letras para a música que está tocando atualmente não pôde ser encontrada",
     "feature_desc_geniUrlBase": "URL base da sua instância geniURL, veja https://github.com/Sv443/geniURL",
     "feature_helptext_geniUrlBase": "Se você tiver sua própria instância do geniURL em execução (por exemplo, para evitar limites de taxa), você pode inserir sua URL base aqui para usá-la para o botão de letras do genius.com.\nSe você não sabe o que é isso, pode deixar esta opção como está.",
     "feature_desc_geniUrlToken": "Token de autenticação para sua instância geniURL",

+ 1 - 0
assets/translations/zh_CN.json

@@ -282,6 +282,7 @@
     "feature_btn_autoLikeOpenMgmtDialog_running": "正在打开...",
 
     "feature_desc_geniusLyrics": "在当前播放的歌曲的媒体控件中添加一个按钮,以在 genius.com 上打开其歌词",
+    "feature_desc_errorOnLyricsNotFound": "当找不到当前播放歌曲的歌词页面时显示一个错误",
     "feature_desc_geniUrlBase": "geniURL 实例的基本 URL,请参阅 https://github.com/Sv443/geniURL",
     "feature_helptext_geniUrlBase": "如果您有自己运行的 geniURL 实例(例如为了绕过速率限制),您可以在此处输入其基本 URL 以在 genius.com 歌词按钮中使用它。\n如果您不知道这是什么,您可以将此选项保留为默认值。",
     "feature_desc_geniUrlToken": "您的 geniURL 实例的身份验证令牌",

+ 1 - 0
src/config.ts

@@ -100,6 +100,7 @@ export const migrations: DataMigrationsDict = {
       useDefaultConfig(oldData, [
         "showToastOnGenericError", "sponsorBlockIntegration",
         "themeSongIntegration", "themeSongLightness",
+        "errorOnLyricsNotFound",
       ]), [
         { key: "toastDuration", oldDefault: 3 },
       ]

+ 7 - 0
src/features/index.ts

@@ -571,6 +571,13 @@ export const featInfo = {
     type: "toggle",
     category: "lyrics",
     default: true,
+    reloadRequired: false,
+    enable: noop,
+  },
+  errorOnLyricsNotFound: {
+    type: "toggle",
+    category: "lyrics",
+    default: true,
   },
   geniUrlBase: {
     type: "text",

+ 5 - 5
src/features/lyrics.ts

@@ -192,7 +192,7 @@ export async function getCurrentLyricsUrl() {
     return url;
   }
   catch(err) {
-    error("Couldn't resolve lyrics URL:", err);
+    getFeature("errorOnLyricsNotFound") && error("Couldn't resolve lyrics URL:", err);
     return undefined;
   }
 }
@@ -203,7 +203,7 @@ export async function fetchLyricsUrlTop(artist: string, song: string): Promise<s
     return (await fetchLyricsUrls(artist, song))?.[0]?.url;
   }
   catch(err) {
-    error("Couldn't get lyrics URL due to error:", err);
+    getFeature("errorOnLyricsNotFound") && error("Couldn't get lyrics URL due to error:", err);
     return undefined;
   }
 }
@@ -243,14 +243,14 @@ export async function fetchLyricsUrls(artist: string, song: string): Promise<Omi
       return undefined;
     }
     else if(fetchRes.status < 200 || fetchRes.status >= 300) {
-      error(`Couldn't fetch lyrics URLs from geniURL - status: ${fetchRes.status} - response: ${(await fetchRes.json()).message ?? await fetchRes.text() ?? "(none)"}`);
+      getFeature("errorOnLyricsNotFound") && error(`Couldn't fetch lyrics URLs from geniURL - status: ${fetchRes.status} - response: ${(await fetchRes.json()).message ?? await fetchRes.text() ?? "(none)"}`);
       return undefined;
     }
 
     const result = await fetchRes.json();
 
     if(typeof result === "object" && result.error || !result || !result.all) {
-      error("Couldn't fetch lyrics URL:", result.message);
+      getFeature("errorOnLyricsNotFound") && error("Couldn't fetch lyrics URL:", result.message);
       return undefined;
     }
 
@@ -292,7 +292,7 @@ export async function fetchLyricsUrls(artist: string, song: string): Promise<Omi
     }));
   }
   catch(err) {
-    error("Couldn't get lyrics URL due to error:", err);
+    getFeature("errorOnLyricsNotFound") && error("Couldn't get lyrics URL due to error:", err);
     return undefined;
   }
 }

+ 2 - 0
src/types.ts

@@ -583,6 +583,8 @@ export interface FeatureConfig {
   //#region lyrics
   /** Add a button to the media controls to open the current song's lyrics on genius.com in a new tab */
   geniusLyrics: boolean;
+  /** Whether to show an error when no lyrics were found */
+  errorOnLyricsNotFound: boolean;
   /** Base URL to use for GeniURL */
   geniUrlBase: string;
   /** Token to use for GeniURL */