Add updateExisting option to importers & UI

Introduce an updateExisting flag across importers and the Importer UI to control whether existing items should be updated or only new items imported. Changes: added updateExisting to XBVR, StashAPP, Playnite, and Jellyfin config types; added checkboxes in ImporterView (enabled by default) to toggle the behavior; import logic now skips existing items when updateExisting is false and logs/skips appropriately (XBVR, StashAPP, Playnite, Jellyfin). Also: minor Playnite env parsing tweak for port (undefined when not provided) and small logging/cleanup in the Jellyfin album handling.
This commit is contained in:
Lars Behrends
2026-04-12 02:57:34 +02:00
parent 9c7e5a2b19
commit 6250164656
5 changed files with 101 additions and 25 deletions

View File

@@ -13,15 +13,17 @@ const BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:3000';
export default function ImporterView() {
const navigate = useNavigate();
const [xbvrConfig, setXbvrConfig] = useState<XBVRConfig>({ url: import.meta.env.VITE_XBVR_URL || BASE_URL });
const [xbvrConfig, setXbvrConfig] = useState<XBVRConfig>({ url: import.meta.env.VITE_XBVR_URL || BASE_URL, updateExisting: true });
const [stashappConfig, setStashappConfig] = useState<StashAPPConfig>({
url: import.meta.env.VITE_STASHAPP_URL || '',
apiKey: import.meta.env.VITE_STASHAPP_API_KEY || ''
apiKey: import.meta.env.VITE_STASHAPP_API_KEY || '',
updateExisting: true
});
const [playniteConfig, setPlayniteConfig] = useState<PlayniteConfig>({
ip: import.meta.env.VITE_PLAYNITE_IP || '',
apiToken: import.meta.env.VITE_PLAYNITE_API_TOKEN || '',
port: parseInt(import.meta.env.VITE_PLAYNITE_PORT || '19821')
apiToken: import.meta.env.VITE_PLAYNITE_API_TOKEN || '',
port: import.meta.env.VITE_PLAYNITE_PORT ? parseInt(import.meta.env.VITE_PLAYNITE_PORT) : undefined,
updateExisting: true
});
const [jellyfinConfig, setJellyfinConfig] = useState<JellyfinConfig>({
url: import.meta.env.VITE_JELLYFIN_URL || '',
@@ -33,7 +35,8 @@ export default function ImporterView() {
importMusic: true,
importCast: true,
limit: undefined,
libraryMappings: []
libraryMappings: [],
updateExisting: true
});
const [jellyfinLibraries, setJellyfinLibraries] = useState<Array<{ Id: string; Name: string; CollectionType: string }>>([]);
const [libraryMappings, setLibraryMappings] = useState<LibraryMapping[]>([]);
@@ -396,6 +399,17 @@ export default function ImporterView() {
placeholder="http://192.168.1.102:10001"
/>
</div>
<div className="flex items-center gap-2">
<input
type="checkbox"
id="xbvr-update-existing"
checked={xbvrConfig.updateExisting}
onChange={(e) => setXbvrConfig({ ...xbvrConfig, updateExisting: e.target.checked })}
disabled={progress.stage !== 'idle'}
className="rounded border-border"
/>
<label htmlFor="xbvr-update-existing" className="text-xs text-muted-foreground cursor-pointer">Bestehende aktualisieren</label>
</div>
<Button
onClick={handleXBVRImport}
disabled={progress.stage !== 'idle' || !xbvrConfig.url}
@@ -465,6 +479,17 @@ export default function ImporterView() {
placeholder="Enter API key if required"
/>
</div>
<div className="flex items-center gap-2">
<input
type="checkbox"
id="stashapp-update-existing"
checked={stashappConfig.updateExisting}
onChange={(e) => setStashappConfig({ ...stashappConfig, updateExisting: e.target.checked })}
disabled={progress.stage !== 'idle'}
className="rounded border-border"
/>
<label htmlFor="stashapp-update-existing" className="text-xs text-muted-foreground cursor-pointer">Bestehende aktualisieren</label>
</div>
<Button
onClick={handleStashAPPImport}
disabled={progress.stage !== 'idle' || !stashappConfig.url}
@@ -603,6 +628,17 @@ export default function ImporterView() {
placeholder="pb_your_token_here"
/>
</div>
<div className="flex items-center gap-2">
<input
type="checkbox"
id="playnite-update-existing"
checked={playniteConfig.updateExisting}
onChange={(e) => setPlayniteConfig({ ...playniteConfig, updateExisting: e.target.checked })}
disabled={progress.stage !== 'idle'}
className="rounded border-border"
/>
<label htmlFor="playnite-update-existing" className="text-xs text-muted-foreground cursor-pointer">Bestehende aktualisieren</label>
</div>
<Button
onClick={handlePlayniteImport}
disabled={progress.stage !== 'idle' || !playniteConfig.ip || !playniteConfig.apiToken}
@@ -728,6 +764,17 @@ export default function ImporterView() {
placeholder="e.g. 10"
/>
</div>
<div className="flex items-center gap-2">
<input
type="checkbox"
id="jellyfin-update-existing"
checked={jellyfinOptions.updateExisting}
onChange={(e) => setJellyfinOptions({ ...jellyfinOptions, updateExisting: e.target.checked })}
disabled={progress.stage !== 'idle'}
className="rounded border-border"
/>
<label htmlFor="jellyfin-update-existing" className="text-xs text-muted-foreground cursor-pointer">Bestehende aktualisieren</label>
</div>
<div>
<label className="text-xs font-bold text-muted-foreground mb-2 block">Library Category Mapping</label>
<Button