From 668603ef50b0d0062f19a4831fdd442426a040ca Mon Sep 17 00:00:00 2001 From: aetaric <565454+aetaric@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:26:11 -0600 Subject: [PATCH] close #92. adds audio language detection and removal. --- check/checkrr.go | 17 ++++++++++++++++- checkrr.yaml.example | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/check/checkrr.go b/check/checkrr.go index e551ce5..43e34cd 100644 --- a/check/checkrr.go +++ b/check/checkrr.go @@ -37,6 +37,7 @@ type Checkrr struct { ignorePaths []string removeVideo []string removeAudio []string + removeLang []string ignoreHidden bool config *viper.Viper FullConfig *viper.Viper @@ -76,6 +77,7 @@ func (c *Checkrr) Run() { c.ignorePaths = c.config.GetStringSlice("ignorepaths") c.removeVideo = c.config.GetStringSlice("removevideo") c.removeAudio = c.config.GetStringSlice("removeaudio") + c.removeLang = c.config.GetStringSlice("removelang") c.ignoreHidden = c.config.GetBool("ignorehidden") // I'm tired of waiting for filetype to support this. We'll force it by adding to the matchers on the fly. @@ -284,6 +286,19 @@ func (c *Checkrr) checkFile(path string) { return } } + for _, language := range c.removeLang { + streamlang, err := stream.TagList.GetString("Language") + if err == nil { + if streamlang == language { + log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true, "Codec": stream.CodecName, "Language": streamlang}).Infof("Detected %s. Removing.", string(streamlang)) + c.deleteFile(path) + return + } + } else { + log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true, "Codec": stream.CodecName, "Language": "unknown"}).Warn("Error getting audio stream language") + c.deleteFile(path) + } + } } } else { if data.FirstAudioStream() != nil { @@ -413,7 +428,7 @@ type BadFile struct { FileExt string `json:"fileExt"` Reacquire bool `json:"reacquire"` Service string `json:"service"` - Date int64 `json:"date` + Date int64 `json:"date"` } // TODO: if h2non/filetype#120 ever gets completed, remove this logic diff --git a/checkrr.yaml.example b/checkrr.yaml.example index 0590e18..9426ec3 100644 --- a/checkrr.yaml.example +++ b/checkrr.yaml.example @@ -18,6 +18,8 @@ checkrr: - "avi" - "avc" - "h265" + removelang: + - unknown removeaudio: - "DTS - 5.1" ignoreexts: