mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 11:13:25 +00:00
filter out duplicate embeds
This commit is contained in:
@@ -59,12 +59,14 @@ export async function scrapeInvidualSource(
|
|||||||
|
|
||||||
if (!output) throw new Error('output is null');
|
if (!output) throw new Error('output is null');
|
||||||
|
|
||||||
// filter output with only valid embeds that are not disabled
|
// filter output with only valid embeds that are not disabled, and remove duplicates
|
||||||
output.embeds = output.embeds.filter((embed) => {
|
output.embeds = output.embeds
|
||||||
const e = list.embeds.find((v) => v.id === embed.embedId);
|
.filter((embed) => {
|
||||||
if (!e || e.disabled) return false;
|
const e = list.embeds.find((v) => v.id === embed.embedId);
|
||||||
return true;
|
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)
|
if ((!output.stream || output.stream.length === 0) && output.embeds.length === 0)
|
||||||
throw new NotFoundError('No streams found');
|
throw new NotFoundError('No streams found');
|
||||||
|
@@ -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
|
const sortedEmbeds = output.embeds
|
||||||
.filter((embed) => {
|
.filter((embed) => {
|
||||||
const e = list.embeds.find((v) => v.id === embed.embedId);
|
const e = list.embeds.find((v) => v.id === embed.embedId);
|
||||||
return e && !e.disabled;
|
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));
|
.sort((a, b) => embedIds.indexOf(a.embedId) - embedIds.indexOf(b.embedId));
|
||||||
|
|
||||||
if (sortedEmbeds.length > 0) {
|
if (sortedEmbeds.length > 0) {
|
||||||
|
Reference in New Issue
Block a user