Skip to content

Commit 668603e

Browse files
committed
close #92. adds audio language detection and removal.
1 parent 7b5977a commit 668603e

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

check/checkrr.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Checkrr struct {
3737
ignorePaths []string
3838
removeVideo []string
3939
removeAudio []string
40+
removeLang []string
4041
ignoreHidden bool
4142
config *viper.Viper
4243
FullConfig *viper.Viper
@@ -76,6 +77,7 @@ func (c *Checkrr) Run() {
7677
c.ignorePaths = c.config.GetStringSlice("ignorepaths")
7778
c.removeVideo = c.config.GetStringSlice("removevideo")
7879
c.removeAudio = c.config.GetStringSlice("removeaudio")
80+
c.removeLang = c.config.GetStringSlice("removelang")
7981
c.ignoreHidden = c.config.GetBool("ignorehidden")
8082

8183
// 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) {
284286
return
285287
}
286288
}
289+
for _, language := range c.removeLang {
290+
streamlang, err := stream.TagList.GetString("Language")
291+
if err == nil {
292+
if streamlang == language {
293+
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true, "Codec": stream.CodecName, "Language": streamlang}).Infof("Detected %s. Removing.", string(streamlang))
294+
c.deleteFile(path)
295+
return
296+
}
297+
} else {
298+
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true, "Codec": stream.CodecName, "Language": "unknown"}).Warn("Error getting audio stream language")
299+
c.deleteFile(path)
300+
}
301+
}
287302
}
288303
} else {
289304
if data.FirstAudioStream() != nil {
@@ -413,7 +428,7 @@ type BadFile struct {
413428
FileExt string `json:"fileExt"`
414429
Reacquire bool `json:"reacquire"`
415430
Service string `json:"service"`
416-
Date int64 `json:"date`
431+
Date int64 `json:"date"`
417432
}
418433

419434
// TODO: if h2non/filetype#120 ever gets completed, remove this logic

checkrr.yaml.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ checkrr:
1818
- "avi"
1919
- "avc"
2020
- "h265"
21+
removelang:
22+
- unknown
2123
removeaudio:
2224
- "DTS - 5.1"
2325
ignoreexts:

0 commit comments

Comments
 (0)