Add the picked providers and a Must include group

This commit is contained in:
Fisto
2026-09-17 11:28:27 +02:00
parent 83dd9bc0fa
commit c6caa168be
11 changed files with 229 additions and 119 deletions
+17 -6
View File
@@ -50,21 +50,32 @@ export function resolutionCondition(preset: string): string | null {
}
/**
* The providers that dominate the archive, for the "Do not include" shortcuts.
* The providers that dominate the archive, for the "Do not include" and "Must include" shortcuts.
* Aggregated 2026-09-17 over media-scrape/db (`provider` column, distinct URLs; discord folds in
* cdn.discordapp.com and media.discordapp.net). Matching is a case-insensitive substring on
* `provider`, so "twitter" also covers fxtwitter.com. The 4chan hosts stay out: the default URL
* host exclusion already hides them.
* cdn.discordapp.com, media.discordapp.net, and images-ext-*.discordapp.net). Matching is a
* case-insensitive substring on `provider`, so "twitter" also covers fxtwitter.com, vxtwitter.com,
* and twitfix; "reddit" covers www.reddit.com and vxreddit. Entries with several substrings are
* joined with a comma and the UI shows "Giphy/Tenor": checking it applies both. 4chan's CDN hosts
* are hidden by the default URL host exclusion, so 2ch.hk stands in for the provider box.
*/
export const PROVIDER_FILTERS = [
"discord",
"youtube",
"tenor",
"giphy,tenor",
"twitch",
"twitter",
"reddit",
"streamable",
"instagram",
"facebook",
"steam",
"gyazo",
"tiktok",
"medal",
"sketchfab",
"gfycat",
"imgur"
"2ch.hk",
"imgur",
"funnyjunk",
"internet archive"
] as const;
+15
View File
@@ -119,6 +119,10 @@ export interface MediaFilterOptions {
excludeProviders?: string[];
/** Row sources to hide (attachment, sticker, embed). */
excludeSources?: string[];
/** Keep only providers matching one of these substrings; empty keeps all. */
includeProviders?: string[];
/** Keep only these row sources; empty keeps all. */
includeSources?: string[];
/** Bytes; rows with no known size drop out while this is set. */
sizeLessThan?: number;
sizeGreaterThan?: number;
@@ -609,6 +613,17 @@ export class ScrapeStore {
conditions.push(`COALESCE(source, '') NOT IN (${options.excludeSources.map(() => "?").join(", ")})`);
values.push(...options.excludeSources);
}
if (options.includeProviders?.length) {
const clauses = options.includeProviders.map(() => "lower(COALESCE(provider, '')) LIKE ?");
conditions.push(`(${clauses.join(" OR ")})`);
for (const provider of options.includeProviders) {
values.push(`%${provider.toLowerCase()}%`);
}
}
if (options.includeSources?.length) {
conditions.push(`COALESCE(source, '') IN (${options.includeSources.map(() => "?").join(", ")})`);
values.push(...options.includeSources);
}
if (options.sizeLessThan !== undefined) {
conditions.push("COALESCE(file_bytes, size) < ?");
values.push(options.sizeLessThan);