Skip to content

Commit

Permalink
Implement #84. Adds the ability to remove certain video and audio cod…
Browse files Browse the repository at this point in the history
…ecs. See full example config.
  • Loading branch information
aetaric committed Jan 11, 2024
1 parent c8a28fb commit 8aa5f15
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
38 changes: 38 additions & 0 deletions check/checkrr.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type Checkrr struct {
lidarr []connections.Lidarr
ignoreExts []string
ignorePaths []string
removeVideo []string
removeAudio []string
ignoreHidden bool
config *viper.Viper
FullConfig *viper.Viper
Expand Down Expand Up @@ -71,6 +73,8 @@ func (c *Checkrr) Run() {

c.ignoreExts = c.config.GetStringSlice("ignoreexts")
c.ignorePaths = c.config.GetStringSlice("ignorepaths")
c.removeVideo = c.config.GetStringSlice("removevideo")
c.removeAudio = c.config.GetStringSlice("removeaudio")
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.
Expand Down Expand Up @@ -260,6 +264,40 @@ func (c *Checkrr) checkFile(path string) {
} else {
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true}).Infof(string(data.Format.Filename))

log.Info(data.Format.FormatName)

if detectedFileType == "Video" {
for _, stream := range data.Streams {
log.Info(stream.CodecName)
for _, codec := range c.removeVideo {
if stream.CodecName == codec {
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true}).Infof("Detected %s. Removing.", string(data.FirstVideoStream().CodecName))
c.deleteFile(path)
return
}
}
for _, codec := range c.removeAudio {
if stream.CodecName == codec {
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true}).Infof("Detected %s. Removing.", string(data.FirstVideoStream().CodecName))
c.deleteFile(path)
return
}
}
}
} else {
log.Debug(data.FirstAudioStream().CodecName)
for _, stream := range data.Streams {
log.Info(stream.CodecName)
for _, codec := range c.removeAudio {
if stream.CodecName == codec {
log.WithFields(log.Fields{"Format": data.Format.FormatLongName, "Type": detectedFileType, "FFProbe": true}).Infof("Detected %s. Removing.", string(data.FirstVideoStream().CodecName))
c.deleteFile(path)
return
}
}
}
}

filehash := imohash.New()
sum, _ := filehash.SumFile(path)

Expand Down
6 changes: 6 additions & 0 deletions checkrr.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ checkrr:
ignorehidden: true
ignorepaths:
- '/tv/ignored'
removevideo:
- "avi"
- "avc"
- "h265"
removeaudio:
- "DTS - 5.1"
ignoreexts:
- .txt
- .nfo
Expand Down

0 comments on commit 8aa5f15

Please sign in to comment.