aetaric / checkrr

Checkrr Scans your library files for corrupt media and replace the files via sonarr and radarr
MIT License
184 stars 8 forks source link

bug/feature: mappings for *arr paths in docker context #30

Closed aetaric closed 1 year ago

aetaric commented 1 year ago

A user running the checkrr docker container will never match paths with the arr services because checkrr likely has a different path mapping for the files than the arr services do.

This 100% effects windows users running checkrr in docker and is a mixed impact for *nix users running in docker as they can workaround this by matching the paths inside the container with the host system.

checkrr should have a mapping option to allow users to provide it with path replacements when contacting arr services.

douginoz commented 1 year ago

(Trying out the unreleased 3.1.0 so feel free to ignore this) Running checkrr not in docker. Running radarr not in docker. Running sonarr in docker (so sonarr's root folder paths are docker-specific).

checkrr finds a corrupt movie file and passes it to radarr correctly. checkrr finds a corrupt tv file but fails to pass it to sonarr correctly. Numerous variations in the mappings: config section fail to fix this.

Actual file and path: /media/videos/TV/Blah/Season 01/Blah - s01e01.avi sonarr sees this file as: /data/tv/Blah/Season 01/Blah - s01e01.avi checkrr.yaml config:

  checkpath:
    "/media/videos/TV/"
  sonarr:
    mappings:
      "/data/tv/": "/media/videos/TV/"

I've tried a few variations:

      "/data/tv": "/media/videos/TV" (removed trailing slash from both)
      "/media/videos/TV/": "/data/tv/" (switched order)
      "/data/tv/": "/media/videos/TV"  (removed trailing slash from 2nd value)
      "/data/tv": "/media/videos/TV/"  (removed trailing slash only from first)

Relevant log file entries (aside: note the Discord mention yet I've completely removed the Discord section in my config file)

INFO[0000] Radarr Connected.                             Radarr "radarr" Connected=true Startup=true
INFO[0000] Lidarr Connected.                             Lidarr "lidarr" Connected=true Startup=true
INFO[0000] Sonarr Connected.                             Sonarr "sonarr" Connected=true Startup=true
INFO[0000] No Discord Webhook URL provided.              Discord Connected=false Startup=true
INFO[0000] File "/media/videos/TV/Blah/Season 01/Blah - s01e01.avi" is not a recongized file type  FFProbe=false Type=Unknown
INFO[0000] Couldn't find a target for file "/media/videos/TV/Blah/Season 01/Blah - s01e01.avi". File is unknown.  Unknown File=true
INFO[0521] File "/media/videos/TV/Blah/Season 01/Blah - s01e02.avi" is not a recongized file type  FFProbe=false Type=Unknown
INFO[0521] Couldn't find a target for file "/media/videos/TV/Blah/Season 01/Blah - s01e02.avi". File is unknown.  Unknown File=true
INFO[0521] /media/videos/TV/Blah/Season 03/Blah - s03e01.mp4  FFProbe=true Format="QuickTime / MOV" Type=Video
INFO[0521] /media/videos/TV/Blah/Season 03/Blah - s03e12.mp4  FFProbe=true Format="QuickTime / MOV" Type=Video
INFO[0521] /media/videos/TV/Blah/Season 03/Blah - s03e13.mp4  FFProbe=true Format="QuickTime / MOV" Type=Video
aetaric commented 1 year ago

Hey thanks @douginoz. I've added some debug logging so we can see what it's up to in commit e9fe7f341d8e4408544730813c268e19afa261eb.

douginoz commented 1 year ago

Hey thanks @douginoz. I've added some debug logging so we can see what it's up to in commit e9fe7f3.

I tried this. No additional debug lines that include "Replaced path:" show up in the logs. I've tried running it with --debug but still it doesn't appear. I created a fresh 3.1.0 git clone and confirmed that the changes in this commit are there. Ran the 'yarn build' 'go build' etc. and ran the new checkrr that was produced.

So it would appear that the code isn't being called at all (or I'm not triggering these debug lines properly?)

aetaric commented 1 year ago

Lemme toss a bit more debug logging around the setup, maybe it's not reading that in right...

aetaric commented 1 year ago

I see the maps in my debug logging, but I don't have any bad files that get submitted to sonarr currently (and I don't really want to break a file for my prod library). But there's more logging now that shows what it's reading in right before the files start getting checked. If you aren't seeing debug lines for each file, you might need to check the config and make sure debug isn't set to false as well.

aetaric commented 1 year ago

After much investigation, this should work now. I was able to build a test environment using files from my server:

INFO[0000] Using config file: ./checkrr.yaml            
INFO[0000] Next Run: 2023-01-21 20:30:00 -0700 MST      
DEBU[0035] Setting Lock to prevent multi-runs           
DEBU[0035] Sonarr Path Maps: %vmap[/tv:test/tv]         
INFO[0035] Sonarr Connected.                             Sonarr "sonarr" Connected=true Startup=true
WARN[0035] No config options for notifications found.    Notifications Connected=false Startup=true
DEBU[0035] [test/tv test/movies test/music]             
DEBU[0035] Path: %vtest/tv                               startup=true
INFO[0035] "test/tv/That Time I Got Reincarnated as a Slime/Season 1/That Time I Got Reincarnated as a Slime - S01E01 - The Storm Dragon, Veldora Bluray-1080p.mkv"  Hash Match=false
DEBU[0035] File "test/tv/That Time I Got Reincarnated as a Slime/Season 1/That Time I Got Reincarnated as a Slime - S01E01 - The Storm Dragon, Veldora Bluray-1080p.mkv" is of type "application/octet-stream"  FFProbe=false Type=Unknown
INFO[0035] File "test/tv/That Time I Got Reincarnated as a Slime/Season 1/That Time I Got Reincarnated as a Slime - S01E01 - The Storm Dragon, Veldora Bluray-1080p.mkv" is not a recognized file type  FFProbe=false Type=Unknown
DEBU[0036] Key: /tv                                     
DEBU[0036] Value: test/tv                               
DEBU[0036] Original path: test/tv/That Time I Got Reincarnated as a Slime/Season 1/That Time I Got Reincarnated as a Slime - S01E01 - The Storm Dragon, Veldora Bluray-1080p.mkv 
DEBU[0036] New path: /tv/That Time I Got Reincarnated as a Slime/Season 1/That Time I Got Reincarnated as a Slime - S01E01 - The Storm Dragon, Veldora Bluray-1080p.mkv 
DEBU[0036] Key: /tv                                     
DEBU[0036] Value: test/tv                               
DEBU[0036] Original path: test/tv/That Time I Got Reincarnated as a Slime/Season 1/That Time I Got Reincarnated as a Slime - S01E01 - The Storm Dragon, Veldora Bluray-1080p.mkv 
DEBU[0036] New path: /tv/That Time I Got Reincarnated as a Slime/Season 1/That Time I Got Reincarnated as a Slime - S01E01 - The Storm Dragon, Veldora Bluray-1080p.mkv 
DEBU[0036] Key: /tv                                     
DEBU[0036] Value: test/tv                               
DEBU[0036] Original path: test/tv/That Time I Got Reincarnated as a Slime/Season 1/That Time I Got Reincarnated as a Slime - S01E01 - The Storm Dragon, Veldora Bluray-1080p.mkv 
DEBU[0036] New path: /tv/That Time I Got Reincarnated as a Slime/Season 1/That Time I Got Reincarnated as a Slime - S01E01 - The Storm Dragon, Veldora Bluray-1080p.mkv 
DEBU[0036] DB Hash: f9b3f4b906660576986bd0aefd3595b5     DB Hash=Found
DEBU[0036] File Hash: %xf9b3f4b906660576986bd0aefd3595b5  DB Hash=Found File Hash=Computed

Sonarr successfully removed the file and tried to replace it which means the path swap worked. Had a few things wrong, so thanks for bringing this to my attention @douginoz.