add more management capabilities
This commit is contained in:
@@ -107,6 +107,7 @@ export function moviesFromDb(libraryId: string): Movie[] {
|
||||
posterUrl: meta.posterUrl ?? null,
|
||||
backdropUrl: meta.backdropUrl ?? null,
|
||||
videoPath: row.file_path ?? '',
|
||||
manuallyEdited: meta.manuallyEdited === true,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -94,11 +94,16 @@ async function scanMovies(library: Library, libraryRoot: string): Promise<void>
|
||||
INSERT INTO media_items (library_id, item_key, item_type, title, year, plot, genres, metadata, file_path, fingerprint, scanned_at)
|
||||
VALUES (@library_id, @item_key, @item_type, @title, @year, @plot, @genres, @metadata, @file_path, @fingerprint, @scanned_at)
|
||||
ON CONFLICT(item_key) DO UPDATE SET
|
||||
title = excluded.title,
|
||||
year = excluded.year,
|
||||
plot = excluded.plot,
|
||||
genres = excluded.genres,
|
||||
metadata = excluded.metadata,
|
||||
title = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1 THEN media_items.title ELSE excluded.title END,
|
||||
year = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1 THEN media_items.year ELSE excluded.year END,
|
||||
plot = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1 THEN media_items.plot ELSE excluded.plot END,
|
||||
genres = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1 THEN media_items.genres ELSE excluded.genres END,
|
||||
metadata = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1
|
||||
THEN json_set(media_items.metadata, '$.rating', json_extract(excluded.metadata, '$.rating'),
|
||||
'$.runtime', json_extract(excluded.metadata, '$.runtime'),
|
||||
'$.posterUrl', json_extract(excluded.metadata, '$.posterUrl'),
|
||||
'$.backdropUrl', json_extract(excluded.metadata, '$.backdropUrl'))
|
||||
ELSE excluded.metadata END,
|
||||
file_path = excluded.file_path,
|
||||
fingerprint = excluded.fingerprint,
|
||||
scanned_at = excluded.scanned_at
|
||||
@@ -194,11 +199,16 @@ async function scanTv(library: Library, libraryRoot: string): Promise<void> {
|
||||
INSERT INTO media_items (library_id, item_key, item_type, title, year, plot, genres, metadata, file_path, fingerprint, scanned_at)
|
||||
VALUES (@library_id, @item_key, @item_type, @title, @year, @plot, @genres, @metadata, @file_path, @fingerprint, @scanned_at)
|
||||
ON CONFLICT(item_key) DO UPDATE SET
|
||||
title = excluded.title,
|
||||
year = excluded.year,
|
||||
plot = excluded.plot,
|
||||
genres = excluded.genres,
|
||||
metadata = excluded.metadata,
|
||||
title = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1 THEN media_items.title ELSE excluded.title END,
|
||||
year = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1 THEN media_items.year ELSE excluded.year END,
|
||||
plot = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1 THEN media_items.plot ELSE excluded.plot END,
|
||||
genres = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1 THEN media_items.genres ELSE excluded.genres END,
|
||||
metadata = CASE WHEN json_extract(media_items.metadata, '$.manuallyEdited') = 1
|
||||
THEN json_set(media_items.metadata, '$.status', json_extract(excluded.metadata, '$.status'),
|
||||
'$.seasonCount', json_extract(excluded.metadata, '$.seasonCount'),
|
||||
'$.posterUrl', json_extract(excluded.metadata, '$.posterUrl'),
|
||||
'$.backdropUrl', json_extract(excluded.metadata, '$.backdropUrl'))
|
||||
ELSE excluded.metadata END,
|
||||
file_path = excluded.file_path,
|
||||
fingerprint = excluded.fingerprint,
|
||||
scanned_at = excluded.scanned_at
|
||||
|
||||
@@ -224,6 +224,7 @@ export function tvSeriesFromDb(libraryId: string): TvSeries[] {
|
||||
posterUrl: meta.posterUrl ?? null,
|
||||
backdropUrl: meta.backdropUrl ?? null,
|
||||
seasonCount: meta.seasonCount ?? 0,
|
||||
manuallyEdited: meta.manuallyEdited === true,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user