Add source filters and a full-window media view
This commit is contained in:
+16
-2
@@ -92,6 +92,7 @@ export interface MediaItemResult {
|
||||
itemId: number;
|
||||
channelId: string;
|
||||
kind: MediaKind;
|
||||
source: string | null;
|
||||
url: string;
|
||||
localUrl: string | null;
|
||||
thumbUrl: string | null;
|
||||
@@ -352,7 +353,14 @@ export class MediaService {
|
||||
|
||||
/** Read media rows across every scrape, newest scrape first. */
|
||||
queryMedia(
|
||||
options: { kind?: MediaKind; scrapeId?: string; limit?: number; offset?: number } = {}
|
||||
options: {
|
||||
kind?: MediaKind;
|
||||
source?: string;
|
||||
scrapeId?: string;
|
||||
channelId?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
} = {}
|
||||
): MediaItemResult[] {
|
||||
const limit = Math.max(1, Math.min(options.limit ?? 60, 500));
|
||||
const offset = Math.max(0, options.offset ?? 0);
|
||||
@@ -362,10 +370,15 @@ export class MediaService {
|
||||
for (const meta of this.engine.list()) {
|
||||
if (meta.state === "deleted") continue;
|
||||
if (options.scrapeId && meta.id !== options.scrapeId) continue;
|
||||
if (options.channelId && meta.channelId !== options.channelId) continue;
|
||||
|
||||
const store = new ScrapeStore(scrapeDir(this.rootDir, meta.id));
|
||||
try {
|
||||
const rows = store.queryMedia({ kind: options.kind, limit: limit + offset });
|
||||
const rows = store.queryMedia({
|
||||
kind: options.kind,
|
||||
source: options.source,
|
||||
limit: limit + offset
|
||||
});
|
||||
for (const row of rows) {
|
||||
if (skipped++ < offset) continue;
|
||||
if (results.length >= limit) break;
|
||||
@@ -374,6 +387,7 @@ export class MediaService {
|
||||
itemId: row.id,
|
||||
channelId: meta.channelId,
|
||||
kind: row.kind,
|
||||
source: row.source,
|
||||
url: row.url,
|
||||
localUrl: row.file_path ? `/api/media/${meta.id}/${row.id}/file` : null,
|
||||
thumbUrl: row.preview_hash ? `/api/media/${meta.id}/${row.id}/thumb` : null,
|
||||
|
||||
Reference in New Issue
Block a user