feat: initial project

This commit is contained in:
MasutaYunikon committed 2026-03-10 22:36:34 +01:00
commit eaf01cfc59
38 files changed
+5807

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import fs from 'fs'
import path from 'path'
const DATA_PATH = path.join(process.cwd(), 'data', 'settings.json')
export interface Settings {
mediaPath : string // dossier Jellyfin destination ex: /media/Kai
completePath : string // dossier qB complétion ex: /downloads/complete
organizeMode : 'hardlink' | 'move'
category : string // catégorie qBittorrent
}
const defaults: Settings = {
mediaPath : '/media/Kai',
completePath : '/downloads/complete',
organizeMode : 'hardlink',
category : 'fankai',
}
export function readSettings(): Settings {
try {
if (!fs.existsSync(DATA_PATH)) return { ...defaults }
return { ...defaults, ...JSON.parse(fs.readFileSync(DATA_PATH, 'utf-8')) }
} catch { return { ...defaults } }
}
export function writeSettings(settings: Partial<Settings>): Settings {
const current = readSettings()
const updated = { ...current, ...settings }
fs.mkdirSync(path.dirname(DATA_PATH), { recursive: true })
fs.writeFileSync(DATA_PATH, JSON.stringify(updated, null, 2))
return updated
}