3 Commits

Author SHA1 Message Date
Jorrin
7cb4686e02 Merge branch 'dev' into feature/filter-duplicate-embeds 2024-04-03 22:12:33 +02:00
Jorrin
3b00d6ffc8 remove unused flag in filemoon 2024-04-03 18:37:45 +02:00
Jorrin
2f4e76747d filter out duplicate embeds 2024-04-03 18:34:04 +02:00
3 changed files with 10 additions and 9 deletions

View File

@@ -1,8 +1,6 @@
import { load } from 'cheerio';
import { unpack } from 'unpacker';
import { flags } from '@/entrypoint/utils/targets';
import { SubtitleResult } from './types';
import { makeEmbed } from '../../base';
import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '../../captions';

View File

@@ -59,12 +59,14 @@ export async function scrapeInvidualSource(
if (!output) throw new Error('output is null');
// filter output with only valid embeds that are not disabled
output.embeds = output.embeds.filter((embed) => {
const e = list.embeds.find((v) => v.id === embed.embedId);
if (!e || e.disabled) return false;
return true;
});
// filter output with only valid embeds that are not disabled, and remove duplicates
output.embeds = output.embeds
.filter((embed) => {
const e = list.embeds.find((v) => v.id === embed.embedId);
if (!e || e.disabled) return false;
return true;
})
.filter((v, i, a) => a.findIndex((t) => t.embedId === v.embedId) === i);
if ((!output.stream || output.stream.length === 0) && output.embeds.length === 0)
throw new NotFoundError('No streams found');

View File

@@ -112,12 +112,13 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt
};
}
// filter disabled and run embed scrapers on listed embeds
// filter disabled, filter out duplicates, run embed scrapers on listed embeds
const sortedEmbeds = output.embeds
.filter((embed) => {
const e = list.embeds.find((v) => v.id === embed.embedId);
return e && !e.disabled;
})
.filter((v, i, a) => a.findIndex((t) => t.embedId === v.embedId) === i)
.sort((a, b) => embedIds.indexOf(a.embedId) - embedIds.indexOf(b.embedId));
if (sortedEmbeds.length > 0) {