Skip to content

Commit

Permalink
no duplicate urls
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanVukovic99 committed Aug 1, 2024
1 parent 04525b3 commit 8bc8c42
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ext/js/media/audio-downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>} */
const urls = new Set();
for (const row of dom.getElementsByClassName('dc-result-row')) {
try {
const audio = dom.getElementByTagName('audio', row);
Expand All @@ -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}));
}

/**
Expand Down

0 comments on commit 8bc8c42

Please sign in to comment.