Add sort and exclusion filters to the media grid
This commit is contained in:
+34
-1
@@ -10,6 +10,7 @@ import { isAbsolute, join } from "node:path";
|
||||
import {
|
||||
BackfillQueue,
|
||||
betterCandidate,
|
||||
sortCandidates,
|
||||
dirSizeBytes,
|
||||
isNearLimit,
|
||||
planRetention,
|
||||
@@ -22,6 +23,7 @@ import {
|
||||
type MediaRow,
|
||||
type BackfillSettings,
|
||||
type BackfillStatus,
|
||||
type MediaSort,
|
||||
type ScrapeBackend,
|
||||
type ScrapeMeta
|
||||
} from "../../media-scrape/src/index.js";
|
||||
@@ -708,6 +710,14 @@ export class MediaService {
|
||||
cachedOnly?: boolean;
|
||||
exts?: string[];
|
||||
excludeHosts?: string[];
|
||||
excludeExts?: string[];
|
||||
excludeProviders?: string[];
|
||||
excludeSources?: string[];
|
||||
sizeLessThan?: number;
|
||||
sizeGreaterThan?: number;
|
||||
lengthLessThan?: number;
|
||||
lengthGreaterThan?: number;
|
||||
sort?: MediaSort;
|
||||
aspect?: string;
|
||||
resolution?: string;
|
||||
after?: string;
|
||||
@@ -829,10 +839,18 @@ export class MediaService {
|
||||
cachedOnly?: boolean;
|
||||
exts?: string[];
|
||||
excludeHosts?: string[];
|
||||
excludeExts?: string[];
|
||||
excludeProviders?: string[];
|
||||
excludeSources?: string[];
|
||||
sizeLessThan?: number;
|
||||
sizeGreaterThan?: number;
|
||||
lengthLessThan?: number;
|
||||
lengthGreaterThan?: number;
|
||||
aspect?: string;
|
||||
resolution?: string;
|
||||
after?: string;
|
||||
before?: string;
|
||||
sort?: MediaSort;
|
||||
}): Array<{ meta: ScrapeMeta; row: MediaRow }> {
|
||||
const candidates = new Map<string, { meta: ScrapeMeta; row: MediaRow }>();
|
||||
|
||||
@@ -856,6 +874,13 @@ export class MediaService {
|
||||
cachedOnly: options.cachedOnly,
|
||||
exts: options.exts,
|
||||
excludeHosts: options.excludeHosts,
|
||||
excludeExts: options.excludeExts,
|
||||
excludeProviders: options.excludeProviders,
|
||||
excludeSources: options.excludeSources,
|
||||
sizeLessThan: options.sizeLessThan,
|
||||
sizeGreaterThan: options.sizeGreaterThan,
|
||||
lengthLessThan: options.lengthLessThan,
|
||||
lengthGreaterThan: options.lengthGreaterThan,
|
||||
aspect: options.aspect,
|
||||
resolution: options.resolution,
|
||||
after: options.after,
|
||||
@@ -893,7 +918,7 @@ export class MediaService {
|
||||
}
|
||||
}
|
||||
|
||||
return [...candidates.values()];
|
||||
return sortCandidates([...candidates.values()], options.sort ?? "newest");
|
||||
}
|
||||
|
||||
/** Read media rows across every scrape, richest per URL, newest scrape first. */
|
||||
@@ -909,6 +934,14 @@ export class MediaService {
|
||||
cachedOnly?: boolean;
|
||||
exts?: string[];
|
||||
excludeHosts?: string[];
|
||||
excludeExts?: string[];
|
||||
excludeProviders?: string[];
|
||||
excludeSources?: string[];
|
||||
sizeLessThan?: number;
|
||||
sizeGreaterThan?: number;
|
||||
lengthLessThan?: number;
|
||||
lengthGreaterThan?: number;
|
||||
sort?: MediaSort;
|
||||
aspect?: string;
|
||||
resolution?: string;
|
||||
after?: string;
|
||||
|
||||
Reference in New Issue
Block a user