From 8bc8c42e6abfb60ea5d155da7a0e1e2981862c19 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Thu, 1 Aug 2024 22:02:30 +0200 Subject: [PATCH] no duplicate urls --- ext/js/media/audio-downloader.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/js/media/audio-downloader.js b/ext/js/media/audio-downloader.js index 14f95eb444..eae46b20ae 100644 --- a/ext/js/media/audio-downloader.js +++ b/ext/js/media/audio-downloader.js @@ -192,8 +192,8 @@ export class AudioDownloader { const responseText = await response.text(); const dom = this._createSimpleDOMParser(responseText); - /** @type {import('audio-downloader').Info[]} */ - const results = []; + /** @type {Set} */ + const urls = new Set(); for (const row of dom.getElementsByClassName('dc-result-row')) { try { const audio = dom.getElementByTagName('audio', row); @@ -207,12 +207,12 @@ export class AudioDownloader { if (!this._validateLanguagePod101Row(language, dom, row, term, reading)) { continue; } url = this._normalizeUrl(url, response.url); - results.push({type: 'url', url}); + urls.add(url); } catch (e) { // NOP } } - return results; + return [...urls].map((url) => ({type: 'url', url})); } /**