Adds a per-job scratch directory under the new `paths.work` config (default `./work`) so audio.<n>.wav, audio.<n>.opus and output.mkv no longer live beside the user's sources in paths.input. The work subdir is named after the input basename and unconditionally removed when processFile returns (success or failure), which kills bug #4 (intermediates leaking into the user-owned input folder; output.mkv getting re-picked by the 15-second watcher tick on rename failure; fixed-name collision risk for any future concurrency). Tightens the failure paths in main.processFile too (bug #25): - mover.MoveToFailed return values are now surfaced via a new failToFailed helper. - The helper os.Stats the source first; missing -> log and skip instead of the previous silent no-op when MoveToFailed was called on output.mkv before it existed. - On rename-output failure, the source is now routed to paths.failed (it was previously left in paths.input, causing an infinite re-encode loop on the next watcher tick). The old MoveToFailed on the work-dir output is dropped — the deferred RemoveAll covers it. Mechanical changes: - PathsConfig gains `Work string \`yaml:"work"\`` with default ./work, included in EnsureDirs. - Encoder.Transcode signature now takes workDir; extractAudio, encodeOpus and encodeVideo all write into workDir. The internal cleanupWavs/cleanupOpus defers are gone (RemoveAll in main is the one cleanup path). - MANUAL.md updated: example config, field reference, §6 pipeline step wording, §9 failure handling description, §11 runtime directories block.
71 lines
1.4 KiB
Go
71 lines
1.4 KiB
Go
package types
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type MediaType string
|
|
|
|
const (
|
|
MediaTypeDVD MediaType = "DVD"
|
|
MediaTypeBluRay MediaType = "Blu-ray"
|
|
MediaTypeWebDL MediaType = "WebDL"
|
|
MediaTypeTVRip MediaType = "TVRip"
|
|
)
|
|
|
|
type Job struct {
|
|
InputPath string
|
|
OutputPath string
|
|
MediaType MediaType
|
|
Metadata *Metadata
|
|
CRF int
|
|
Preset int
|
|
DeleteOrigin bool
|
|
}
|
|
|
|
type Metadata struct {
|
|
Title string
|
|
Collection string
|
|
Season string
|
|
Episode string
|
|
DateReleased string
|
|
IMDBID string
|
|
TVMazeID string
|
|
OriginalMedia MediaType
|
|
IsSeries bool
|
|
}
|
|
|
|
type Config struct {
|
|
OMDBAPIKey string `yaml:"omdb_api_key"`
|
|
Encoding EncodingConfig
|
|
Paths PathsConfig
|
|
}
|
|
|
|
type EncodingConfig struct {
|
|
DVD EncodingParams `yaml:"dvd"`
|
|
Bluray EncodingParams `yaml:"bluray"`
|
|
WebDL EncodingParams `yaml:"webdl"`
|
|
TVRip EncodingParams `yaml:"tvrip"`
|
|
}
|
|
|
|
type EncodingParams struct {
|
|
CRF int `yaml:"crf"`
|
|
Preset int `yaml:"preset"`
|
|
}
|
|
|
|
type PathsConfig struct {
|
|
Input string `yaml:"input"`
|
|
Output string `yaml:"output"`
|
|
Originals string `yaml:"originals"`
|
|
Failed string `yaml:"failed"`
|
|
Work string `yaml:"work"`
|
|
}
|
|
|
|
type LogEntry struct {
|
|
Timestamp time.Time `json:"timestamp"`
|
|
Level string `json:"level"`
|
|
Message string `json:"message"`
|
|
File string `json:"file,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|