feat(pinchflat): Media Profiles — named download presets per Library source
A MediaProfile bundles { kind, quality, options, outputTemplate, extraArgs }
that a Source points at via Source.profileId, overriding the global defaults
field-by-field for that source's downloads.
Backend mirrors CommandTemplate: profiles.ts (createJsonStore, PROFILES_MAX,
isProfileLike + sanitize), CRUD IPC (profiles:list/save/remove) + preload +
useProfiles store; Source.profileId + sources:set-profile. Pure resolution
in @shared/profileResolve.ts (profile → global, per field; unit-tested).
Applied in the sources-store enqueueItems; a per-download collectionOutput-
Template override threads to buildArgs so a profile's outputTemplate wins.
UI: ProfileManager (mirrors TemplateManager) in a new Settings → Advanced →
Media profiles card, plus a per-source Profile picker in the Library source
detail. Both live-verified in the preview; 354 tests pass.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,21 @@ export function setSourceWatched(id: string, watched: boolean): Source[] {
|
||||
return sourcesStore.write(listSources().map((s) => (s.id === id ? { ...s, watched } : s)))
|
||||
}
|
||||
|
||||
/**
|
||||
* Point a source at a MediaProfile, or clear it (profileId === null). Returns
|
||||
* all sources. A cleared profile drops the field entirely so the record stays
|
||||
* clean rather than carrying an explicit undefined.
|
||||
*/
|
||||
export function setSourceProfile(id: string, profileId: string | null): Source[] {
|
||||
return sourcesStore.write(
|
||||
listSources().map((s) => {
|
||||
if (s.id !== id) return s
|
||||
const { profileId: _drop, ...rest } = s
|
||||
return profileId ? { ...rest, profileId } : rest
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/** Remove a source and all of its media items. Returns the remaining sources. */
|
||||
export function removeSource(id: string): Source[] {
|
||||
const sources = sourcesStore.write(listSources().filter((s) => s.id !== id))
|
||||
|
||||
Reference in New Issue
Block a user