From 8341291497fc552227edc9142b8a04f288ab9f06 Mon Sep 17 00:00:00 2001 From: Kevin Raoofi Date: Wed, 11 Nov 2020 14:50:32 -0500 Subject: [PATCH] Use a set to deduplicate subscriptions --- src/tools/YTtoLBRY.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/tools/YTtoLBRY.tsx b/src/tools/YTtoLBRY.tsx index e553455..df7d200 100644 --- a/src/tools/YTtoLBRY.tsx +++ b/src/tools/YTtoLBRY.tsx @@ -2,7 +2,7 @@ import { Fragment, h, render } from 'preact'; import { useState } from 'preact/hooks'; import { getSettingsAsync, redirectDomains } from '../common/settings'; -import { YTDescriptor, getFileContent, ytService } from '../common/yt'; +import { getFileContent, ytService } from '../common/yt'; /** * Parses the subscription file and queries the API for lbry channels @@ -14,10 +14,8 @@ async function lbryChannelsFromFile(file: File) { const ext = file.name.split('.').pop()?.toLowerCase(); const content = await getFileContent(file); - const ids: YTDescriptor[] = (ext === 'xml' || ext == 'opml' ? ytService.readOpml(content) : ytService.readJson(content)) - .map(id => ({ id, type: 'channel' })); - - const lbryUrls = await ytService.resolveById(...ids); + const ids = new Set((ext === 'xml' || ext == 'opml' ? ytService.readOpml(content) : ytService.readJson(content))) + const lbryUrls = await ytService.resolveById(...Array.from(ids).map(id => ({ id, type: 'channel' } as const))); const { redirect } = await getSettingsAsync('redirect'); const urlPrefix = redirectDomains[redirect].prefix; return lbryUrls.map(channel => urlPrefix + channel);