Skip to content

Commit 8aa5f15

Browse files
committed
Implement #84. Adds the ability to remove certain video and audio codecs. See full example config.
1 parent c8a28fb commit 8aa5f15

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

check/checkrr.go

+38
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ type Checkrr struct {
3434
lidarr []connections.Lidarr
3535
ignoreExts []string
3636
ignorePaths []string
37+
removeVideo []string
38+
removeAudio []string
3739
ignoreHidden bool
3840
config *viper.Viper
3941
FullConfig *viper.Viper
@@ -71,6 +73,8 @@ func (c *Checkrr) Run() {
7173

7274
c.ignoreExts = c.config.GetStringSlice("ignoreexts")
7375
c.ignorePaths = c.config.GetStringSlice("ignorepaths")
76+
c.removeVideo = c.config.GetStringSlice("removevideo")
77+
c.removeAudio = c.config.GetStringSlice("removeaudio")
7478
c.ignoreHidden = c.config.GetBool("ignorehidden")
7579

7680
// I'm tired of waiting for filetype to support this. We'll force it by adding to the matchers on the fly.
@@ -260,6 +264,40 @@ func (c *Checkrr) checkFile(path string) {
260264
} else {
261265
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true}).Infof(string(data.Format.Filename))
262266

267+
log.Info(data.Format.FormatName)
268+
269+
if detectedFileType == "Video" {
270+
for _, stream := range data.Streams {
271+
log.Info(stream.CodecName)
272+
for _, codec := range c.removeVideo {
273+
if stream.CodecName == codec {
274+
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true}).Infof("Detected %s. Removing.", string(data.FirstVideoStream().CodecName))
275+
c.deleteFile(path)
276+
return
277+
}
278+
}
279+
for _, codec := range c.removeAudio {
280+
if stream.CodecName == codec {
281+
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true}).Infof("Detected %s. Removing.", string(data.FirstVideoStream().CodecName))
282+
c.deleteFile(path)
283+
return
284+
}
285+
}
286+
}
287+
} else {
288+
log.Debug(data.FirstAudioStream().CodecName)
289+
for _, stream := range data.Streams {
290+
log.Info(stream.CodecName)
291+
for _, codec := range c.removeAudio {
292+
if stream.CodecName == codec {
293+
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true}).Infof("Detected %s. Removing.", string(data.FirstVideoStream().CodecName))
294+
c.deleteFile(path)
295+
return
296+
}
297+
}
298+
}
299+
}
300+
263301
filehash := imohash.New()
264302
sum, _ := filehash.SumFile(path)
265303

checkrr.yaml.example

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ checkrr:
1414
ignorehidden: true
1515
ignorepaths:
1616
- '/tv/ignored'
17+
removevideo:
18+
- "avi"
19+
- "avc"
20+
- "h265"
21+
removeaudio:
22+
- "DTS - 5.1"
1723
ignoreexts:
1824
- .txt
1925
- .nfo

0 commit comments

Comments
 (0)