Documentation
¶
Index ¶
- Constants
- Variables
- func Base2Absolute(s, dir string) string
- func IsFlagBoolSet(cmd *cobra.Command, flagName string) (bool, bool)
- func IsFlagIntSet(cmd *cobra.Command, flagName string) (bool, int)
- func IsFlagStrSet(cmd *cobra.Command, flagName string) (bool, string)
- func IsZeroLengthTimespan(last, t time.Duration) (b bool)
- func SetPrefered(langs []Lang, l, atm Lang, filename string, out *string, Native *Lang) bool
- func Str(l *iso.Language) string
- func Subs2StringBlock(subs *astisub.Subtitles) (mergedSubsStr string, subSlice []string)
- func TagsStr2TagsArr(tagsString string) []string
- type AudioTrack
- type CLIHandler
- func (h *CLIHandler) GetLogBuffer() bytes.Buffer
- func (h *CLIHandler) GetSnapshotsString() string
- func (h *CLIHandler) HandleProgress(current, total int, description string)
- func (h *CLIHandler) HandleStatus(status string)
- func (h *CLIHandler) IsCLI() bool
- func (h *CLIHandler) Log(level int8, behavior string, msg string) *ProcessingError
- func (h *CLIHandler) LogErr(err error, behavior string, msg string) *ProcessingError
- func (h *CLIHandler) LogErrFields(err error, behavior string, msg string, fields map[string]interface{}) *ProcessingError
- func (h *CLIHandler) LogFields(level int8, behavior string, msg string, fields map[string]interface{}) *ProcessingError
- func (h *CLIHandler) SaveSnapshot(state string, task *Task)
- func (h *CLIHandler) ZeroLog() *zerolog.Logger
- type CreatingLibrary
- type GUIHandler
- func (h *GUIHandler) GetLogBuffer() bytes.Buffer
- func (h *GUIHandler) GetSnapshotsString() string
- func (h *GUIHandler) HandleProgress(current, total int, description string)
- func (h *GUIHandler) HandleStatus(status string)
- func (h *GUIHandler) IsCLI() bool
- func (h *GUIHandler) Log(level int8, behavior string, msg string) *ProcessingError
- func (h *GUIHandler) LogErr(err error, behavior string, msg string) *ProcessingError
- func (h *GUIHandler) LogErrFields(err error, behavior string, msg string, fields map[string]interface{}) *ProcessingError
- func (h *GUIHandler) LogFields(level int8, behavior string, msg string, fields map[string]interface{}) *ProcessingError
- func (h *GUIHandler) SaveSnapshot(state string, task *Task)
- func (h *GUIHandler) ZeroLog() *zerolog.Logger
- type GeneralTrack
- type IndexedSubItem
- type Lang
- type LogWriter
- type MediaInfo
- type MessageHandler
- type Meta
- type Mode
- type ProcessedItem
- type ProcessedItemWriter
- type ProcessingError
- type ProcessingSnapshot
- type RawMedia
- type RawMediaInfo
- type SelectionHelper
- type Task
- func (tsk *Task) ApplyFlags(cmd *cobra.Command) *ProcessingError
- func (tsk *Task) Autosub() *ProcessingError
- func (tsk *Task) ChooseAudio(helper func(tsk *Task, i int, track AudioTrack) error) (err error)
- func (tsk *Task) ConcatWAVstoOGG(suffix string)
- func (tsk *Task) Execute(ctx context.Context) *ProcessingError
- func (tsk *Task) PrepareLangs() *ProcessingError
- func (tsk *Task) ProcessItem(ctx context.Context, foreignItem *astisub.Item) (item ProcessedItem, procErr *ProcessingError)
- func (tsk *Task) Routing(ctx context.Context) (procErr *ProcessingError)
- func (tsk *Task) Supervisor(ctx context.Context, outStream *os.File, write ProcessedItemWriter) *ProcessingError
- func (tsk *Task) Translit(subsFilepath string) *ProcessingError
- type VideoTrack
- type WorkerConfig
Constants ¶
const ( StrippedSDH = iota Sub Dub CC )
const ( //ContinueProcessing = "continue" //ContinueWithWarning = "warning" ProbeUser = "probe" AbortTask = "abort_task" AbortAllTasks = "abort_all" )
const ( Trace = int8(zerolog.TraceLevel) Debug = int8(zerolog.DebugLevel) Info = int8(zerolog.InfoLevel) Warn = int8(zerolog.WarnLevel) Error = int8(zerolog.ErrorLevel) Fatal = int8(zerolog.FatalLevel) Panic = int8(zerolog.PanicLevel) )
const ( Subs2Cards = iota Subs2Dubs Enhance Translit )
Variables ¶
var AstisubSupportedExt = []string{".srt", ".ass", ".ssa", "vtt", ".stl", ".ttml"}
var CodecToExtension = map[string]string{
"MP3": ".mp3",
"AAC": ".aac",
"WMA": ".wma",
"FLAC": ".flac",
"ALAC": ".m4a",
"Opus": ".opus",
"Vorbis": ".ogg",
"PCM": ".wav",
"WAV": ".wav",
"AIFF": ".aiff",
"RealAudio": ".ra",
"AMR": ".amr",
"MPEG-4 ALS": ".mp4",
"MPEG Audio": ".mp3",
"AC-3": ".ac3",
"DTS": ".dts",
"TrueHD": ".thd",
"E-AC-3": ".eac3",
"MKA": ".mka",
"WebM": ".webm",
"Speex": ".spx",
"Musepack": ".mpc",
}
var MediainfoPath = "mediainfo"
var (
Splitter = "𓃰" // All providers must accept and return UTF-8.
)
Functions ¶
func Base2Absolute ¶
func IsZeroLengthTimespan ¶
func SetPrefered ¶
func Subs2StringBlock ¶
func TagsStr2TagsArr ¶
Types ¶
type AudioTrack ¶
type AudioTrack struct { Type string `json:"@type"` StreamOrder string `json:"StreamOrder"` ID string `json:"ID"` Format string `json:"Format"` FormatCommercialIfAny string `json:"Format_Commercial_IfAny"` FormatSettingsSBR string `json:"Format_Settings_SBR"` FormatAdditionalFeatures string `json:"Format_AdditionalFeatures"` CodecID string `json:"CodecID"` Duration string `json:"Duration"` BitRateMode string `json:"BitRate_Mode"` BitRate string `json:"BitRate"` Channels string `json:"Channels"` ChannelPositions string `json:"ChannelPositions"` ChannelLayout string `json:"ChannelLayout"` SamplesPerFrame string `json:"SamplesPerFrame"` SamplingRate string `json:"SamplingRate"` SamplingCount string `json:"SamplingCount"` FrameRate string `json:"FrameRate"` FrameCount string `json:"FrameCount"` CompressionMode string `json:"Compression_Mode"` StreamSize string `json:"StreamSize"` StreamSizeProportion string `json:"StreamSize_Proportion"` Title string `json:"Title"` LangRaw string `json:"Language"` Language *iso.Language Default string `json:"Default"` AlternateGroup string `json:"AlternateGroup"` }
AudioTrack represents the information about the audio stream in the media file
type CLIHandler ¶
type CLIHandler struct {
// contains filtered or unexported fields
}
CLI implementation
func NewCLIHandler ¶
func NewCLIHandler() *CLIHandler
func (*CLIHandler) GetLogBuffer ¶
func (h *CLIHandler) GetLogBuffer() bytes.Buffer
func (*CLIHandler) GetSnapshotsString ¶
func (h *CLIHandler) GetSnapshotsString() string
func (*CLIHandler) HandleProgress ¶
func (h *CLIHandler) HandleProgress(current, total int, description string)
func (*CLIHandler) HandleStatus ¶
func (h *CLIHandler) HandleStatus(status string)
func (*CLIHandler) IsCLI ¶
func (h *CLIHandler) IsCLI() bool
func (*CLIHandler) Log ¶
func (h *CLIHandler) Log(level int8, behavior string, msg string) *ProcessingError
func (*CLIHandler) LogErr ¶
func (h *CLIHandler) LogErr(err error, behavior string, msg string) *ProcessingError
func (*CLIHandler) LogErrFields ¶
func (h *CLIHandler) LogErrFields(err error, behavior string, msg string, fields map[string]interface{}) *ProcessingError
func (*CLIHandler) LogFields ¶
func (h *CLIHandler) LogFields(level int8, behavior string, msg string, fields map[string]interface{}) *ProcessingError
func (*CLIHandler) SaveSnapshot ¶
func (h *CLIHandler) SaveSnapshot(state string, task *Task)
func (*CLIHandler) ZeroLog ¶
func (h *CLIHandler) ZeroLog() *zerolog.Logger
type CreatingLibrary ¶
CreatingLibrary represents the information about the library used to create the media information
type GUIHandler ¶
type GUIHandler struct {
// contains filtered or unexported fields
}
GUI implementation
func NewGUIHandler ¶
func NewGUIHandler(ctx context.Context) *GUIHandler
func (*GUIHandler) GetLogBuffer ¶
func (h *GUIHandler) GetLogBuffer() bytes.Buffer
func (*GUIHandler) GetSnapshotsString ¶
func (h *GUIHandler) GetSnapshotsString() string
func (*GUIHandler) HandleProgress ¶
func (h *GUIHandler) HandleProgress(current, total int, description string)
func (*GUIHandler) HandleStatus ¶
func (h *GUIHandler) HandleStatus(status string)
func (*GUIHandler) IsCLI ¶
func (h *GUIHandler) IsCLI() bool
func (*GUIHandler) Log ¶
func (h *GUIHandler) Log(level int8, behavior string, msg string) *ProcessingError
func (*GUIHandler) LogErr ¶
func (h *GUIHandler) LogErr(err error, behavior string, msg string) *ProcessingError
func (*GUIHandler) LogErrFields ¶
func (h *GUIHandler) LogErrFields(err error, behavior string, msg string, fields map[string]interface{}) *ProcessingError
func (*GUIHandler) LogFields ¶
func (h *GUIHandler) LogFields(level int8, behavior string, msg string, fields map[string]interface{}) *ProcessingError
func (*GUIHandler) SaveSnapshot ¶
func (h *GUIHandler) SaveSnapshot(state string, task *Task)
func (*GUIHandler) ZeroLog ¶
func (h *GUIHandler) ZeroLog() *zerolog.Logger
type GeneralTrack ¶
type GeneralTrack struct { Type string `json:"@type"` VideoCount string `json:"VideoCount"` AudioCount string `json:"AudioCount"` FileExtension string `json:"FileExtension"` Format string `json:"Format"` FormatProfile string `json:"Format_Profile"` CodecID string `json:"CodecID"` CodecIDCompatible string `json:"CodecID_Compatible"` FileSize string `json:"FileSize"` Duration string `json:"Duration"` OverallBitRate string `json:"OverallBitRate"` FrameRate string `json:"FrameRate"` FrameCount string `json:"FrameCount"` StreamSize string `json:"StreamSize"` HeaderSize string `json:"HeaderSize"` DataSize string `json:"DataSize"` IsStreamable string `json:"IsStreamable"` Title string `json:"Title"` Collection string `json:"Collection"` Season string `json:"Season"` Track string `json:"Track"` Description string `json:"Description"` RecordedDate string `json:"Recorded_Date"` FileModifiedDate string `json:"File_Modified_Date"` FileModifiedDateLocal string `json:"File_Modified_Date_Local"` EncodedApplication string `json:"Encoded_Application"` Cover string `json:"Cover"` Extra struct { PartID string `json:"Part_ID"` } `json:"extra"` }
GeneralTrack represents the general information about the media file
type IndexedSubItem ¶
IndexedSubItem wraps a subtitle item along with its original index.
type Lang ¶
type Lang struct { *iso.Language Subtag string // Typically a ISO 3166-1 region but can also be a ISO 15924 script }
func GuessLangFromFilename ¶
Only 1st subtag found is considered, the others are ignored
func ParseLanguageTags ¶
Exemple of input slice: []string{"pt-BR", "yue", "zh-Hant"}
type LogWriter ¶
type LogWriter struct {
// contains filtered or unexported fields
}
LogWriter must implement io.Writer for zerolog.MultiLevelWriter
type MediaInfo ¶
type MediaInfo struct { CreatingLibrary CreatingLibrary GeneralTrack GeneralTrack VideoTrack VideoTrack AudioTracks []AudioTrack }
MediaInfo represents the media information including general, video, and audio tracks
type MessageHandler ¶
type MessageHandler interface { IsCLI() bool Log(level int8, behavior string, msg string) *ProcessingError LogErr(err error, behavior string, msg string) *ProcessingError LogFields(level int8, behavior string, msg string, fields map[string]interface{}) *ProcessingError LogErrFields(err error, behavior string, msg string, fields map[string]interface{}) *ProcessingError ZeroLog() *zerolog.Logger GetLogBuffer() bytes.Buffer HandleProgress(current, total int, description string) //TODO HandleStatus(status string) //TODO SaveSnapshot(state string, task *Task) }
type ProcessedItem ¶
type ProcessedItem struct { Index int AlreadyDone bool Sound string Time string Source string Image string ForeignCurr string NativeCurr string ForeignPrev string NativePrev string ForeignNext string NativeNext string }
ProcessedItem represents the exported information of a single subtitle item.
type ProcessedItemWriter ¶
type ProcessedItemWriter func(*os.File, *ProcessedItem)
type ProcessingError ¶
type ProcessingSnapshot ¶
type RawMedia ¶
type RawMedia struct { Ref string `json:"@ref"` Track []json.RawMessage `json:"track"` }
type RawMediaInfo ¶
type RawMediaInfo struct { CreatingLibrary CreatingLibrary `json:"creatingLibrary"` Media RawMedia `json:"media"` }
type SelectionHelper ¶
type SelectionHelper func(*Task, int, AudioTrack) error
type Task ¶
type Task struct { Handler MessageHandler Meta Meta Mode Mode // Language settings OriginalLang string // FIXME what for? Langs []string RefLangs []Lang Targ Lang Native Lang // File paths // mediaSourceFile is the path of the actual media provided or any media found while routing() MediaSourceFile string TargSubFile string NativeSubFile string // mediaprefix is the base string for building AVIF / OPUS to which timecodes of a subtitle line will be added. MediaPrefix string // base string for building AVIF/OPUS // Subtitles NativeSubs *subs.Subtitles TargSubs *subs.Subtitles // Processing options IsBulkProcess bool DubsOnly bool IsCCorDubs bool // Common options FieldSep string // defaults to "\t" OutputFileExtension string // defaults to ".tsv" for "\t" and ".csv" otherwise Offset time.Duration // Subs2cards options WantCondensedAudio bool // Audio track options TargetChan int // TODO rename TargetChanNum UseAudiotrack int // Voice enhancement options SeparationLib string TimeoutSep int VoiceBoost float64 OriginalBoost float64 Limiter float64 MergingFormat string // STT options STT string TimeoutSTT int WantDubs bool // Romanization options WantTranslit bool RomanizationStyle string KanjiThreshold int BrowserAccessURL string DockerRecreate bool }
func NewTask ¶
func NewTask(handler MessageHandler) (tsk *Task)
func (*Task) ApplyFlags ¶
func (tsk *Task) ApplyFlags(cmd *cobra.Command) *ProcessingError
func (*Task) Autosub ¶
func (tsk *Task) Autosub() *ProcessingError
idea: rework to create register: whichSub, whichLang map[string]string and scan subtitles passively without declaring tsk.Native or tsk.NativeSubFile
func (*Task) ChooseAudio ¶
func (*Task) ConcatWAVstoOGG ¶
func (*Task) PrepareLangs ¶
func (tsk *Task) PrepareLangs() *ProcessingError
func (*Task) ProcessItem ¶
func (tsk *Task) ProcessItem(ctx context.Context, foreignItem *astisub.Item) (item ProcessedItem, procErr *ProcessingError)
func (*Task) Supervisor ¶
func (tsk *Task) Supervisor(ctx context.Context, outStream *os.File, write ProcessedItemWriter) *ProcessingError
Supervisor manages multiple workers processing subtitle items concurrently. It handles cancellation, error reporting, duplicate checking for resuming a previous aborted run, and on‑the‑fly writing.
func (*Task) Translit ¶
func (tsk *Task) Translit(subsFilepath string) *ProcessingError
type VideoTrack ¶
type VideoTrack struct { Type string `json:"@type"` StreamOrder string `json:"StreamOrder"` ID string `json:"ID"` Format string `json:"Format"` FormatProfile string `json:"Format_Profile"` FormatLevel string `json:"Format_Level"` CodecID string `json:"CodecID"` Duration string `json:"Duration"` BitRate string `json:"BitRate"` Width string `json:"Width"` Height string `json:"Height"` SampledWidth string `json:"Sampled_Width"` SampledHeight string `json:"Sampled_Height"` PixelAspectRatio string `json:"PixelAspectRatio"` DisplayAspectRatio string `json:"DisplayAspectRatio"` Rotation string `json:"Rotation"` FrameRateMode string `json:"FrameRate_Mode"` FrameRate string `json:"FrameRate"` FrameRateMinimum string `json:"FrameRate_Minimum"` FrameRateMaximum string `json:"FrameRate_Maximum"` FrameCount string `json:"FrameCount"` ColorSpace string `json:"ColorSpace"` ChromaSubsampling string `json:"ChromaSubsampling"` BitDepth string `json:"BitDepth"` StreamSize string `json:"StreamSize"` Title string `json:"Title"` ColourRange string `json:"colour_range"` ColourRangeSource string `json:"colour_range_Source"` Extra struct { CodecConfigurationBox string `json:"CodecConfigurationBox"` } `json:"extra"` }
VideoTrack represents the information about the video stream in the media file
type WorkerConfig ¶
type WorkerConfig struct {
// contains filtered or unexported fields
}