aetaric / checkrr

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

[Feature] Whisparr Support #85

Open thorman123 opened 6 months ago

thorman123 commented 6 months ago

Is your feature request related to a problem? Please describe. N/A

Describe the solution you'd like Whisparr support

Describe alternatives you've considered N/A

Additional context N/A

aetaric commented 6 months ago

Blocked by golift/starr#127

aetaric commented 6 months ago

@thorman123 Do you run checkrr as a standalone executable or via docker?

thorman123 commented 6 months ago

Running as a windows 10 service through task scheduler. So I believe it is standalone?

aetaric commented 6 months ago

checkrr_whisparr_test.zip I chatted with the starr devs and it seems their unpackarr tool ties into whisparr via the sonarr API. The attached test build attempts to do the same thing, If you can test that and confirm it works as expected with whisparr, I'll go ahead and get this added for the next major/minor release.

thorman123 commented 6 months ago

Upon testing it does seem to find a corrupted file and does contact whisparr, which searches for another file. However whisparr just searches without deleting the previous file, therefore keeping the corrupted file, and whisparr thinking it is upgrading the file doesn't redownload.

aetaric commented 6 months ago

Interesting... This new build has extra debug logging in the sonarr API logic. If there's an error being thrown, as long as you have debug set to true in the config or run it with --debug it should print info about the series and episode id and any error calling the delete file endpoint. checkrr_whisparr_debug.zip

thorman123 commented 6 months ago

Hmm it seems like this build doesn't recognize whisparr at all. it is saying service unknown for the same file that I tried before and the same config while the previous build shows service whisparr.

aetaric commented 6 months ago

Sorry, I forgot to switch branches on the machine I built that on. I rebuilt it with the whisper changes AND the debug logging. checkrr_whisparr_debug.zip

thorman123 commented 6 months ago

this is all I'm getting time="2023-12-14T22:04:39-06:00" level=info msg="(File path)"" Hash Match=false

time="2023-12-14T22:04:39-06:00" level=warning msg="Error getting data: error running ffprobe [] exit status 1 - (FIle path) FFProbe=failed Type=Video

I can see in whisparr it is searching indexers for the file but it is not deleted from the system first so it is not redownloading. I have debug on in config. The way I'm testing is editing the mp4 file in notepad and adding a few words corrupting the mp4 file as I don't have a corrupted file to test on yet (hence this program as a preventive) Is this perhaps not the correct way to test this? there is something weird in the log though. here is the first few lines

time="2023-12-14T22:04:13-06:00" level=info msg="Next Run: 2023-12-15 00:00:00 -0600 CST" time="2023-12-14T22:04:35-06:00" level=info msg="Radarr Connected." Radarr "radarr" Connected=true Startup=true time="2023-12-14T22:04:35-06:00" level=info msg="Sonarr Connected." Sonarr "sonarr" Connected=true Startup=true time="2023-12-14T22:04:35-06:00" level=info msg="Sonarr Connected." Startup=true Whisparr "whisparr" Connected=true time="2023-12-14T22:04:35-06:00" level=info msg="Connected to Discord" Discord Connected=true Startup=true

Sonarr is added twice but one is whisparr... is that due to the api used? Is this perhaps related to the issue?

aetaric commented 6 months ago

Yeah, Whisparr doesn't have it's own API, they are using sonarr's API. (if you are doing series and episodes there's not really a reason to make a custom API when sonarr's will work)

The proposed Whisparr support would just leverage the sonarr API (though, you could take 3.2.2 and connect whisparr as service: sonarr and it would work fine). With the --debug flag, or setting debug: true in the config under checkrr, any file replacements that match file paths with whisparr's (or sonarr's) configured root directories will log additional information like the series id, the file id, and any error calling delete on the file id.

thorman123 commented 6 months ago

I am not getting that debug info with debug on in the config, but another thing I'm noticing is that the file is not getting added to the badfiles.csv. Do hashes mismatched files not get added to badfiles.csv? Does my strategy of editing the mp4 in notepad not work for creating a corrupt file? How do you test for a corrupt file?

aetaric commented 6 months ago

Files are checked by looking at the magic number and checking if ffprobe can parse the container. A hash mismatch might not be a bad file, just that the file changed from the expected hash.

In windows, you should be able to create a junk data file with fsutil file createnew test.mp4 32234. That's almost certain to fail the magic number check.

thorman123 commented 6 months ago

here is the only thing in the debug log from the file I created from the command that you gave

time="2023-12-14T23:13:29-06:00" level=info msg="File \"K:\Data\Media\Test\test\test.mp4\" is not a recognized file type" FFProbe=false Type=Unknown

aetaric commented 6 months ago

Is K:\Data\Media\Test a root folder for Whisparr? if not, it will not match to that service. When I setup test media, I move a known good file out of the way and replace it with a junk file like that in a root folder that matches the service I am testing.

Checkrr doesn't know what service to contact unless it can find a matching root folder in one of the configured services.

thorman123 commented 6 months ago

Sorry I've been editing the file paths a bit to be sfw...

K:\Data\Media\Adult\test Is where the file is

the log was

time="2023-12-14T23:13:29-06:00" level=info msg="File "K:\Data\Media\Adult\test\test.mp4" is not a recognized file type" FFProbe=false Type=Unknown

The whisparr root folder is K:\Data\Media\Adult

the folder in checkrr is K:/Data/Media/

aetaric commented 6 months ago

Ah, as long as the filename is a filename of a tracked file for whisparr in it's root directory, it should find it in Whisparr's API to remove it. That's why I make a copy of a known good file and then replace it with a junk file of the same name when testing. checkrr has to find the file in the API by filename, without it being found it will still fail to match to a service.

thorman123 commented 6 months ago

So I did what you said and replaced the known tracked file with the test file and here's what I got in the log.

time="2023-12-15T00:41:33-06:00" level=info msg="\"K:\Data\Media\Adult\- Amazing-Films\Amazing Films - 2023-07-21 - Seduced By Lena - Lena Paul.mp4\"" Hash Match=false time="2023-12-15T00:41:33-06:00" level=info msg="File \"K:\Data\Media\Adult\- Amazing-Films\Amazing Films - 2023-07-21 - Seduced By Lena - Lena Paul.mp4\" is not a recognized file type" FFProbe=false Type=Unknown

I didn't filter anything out here so it's exactly as seen in the log. Still no debug info like you said there should be though

Edit: I don't know what's going on but when I am editing this message I get a bunch of double slashes in this post where the paths are but once I post it it removes them... Here's a screenshot showing exactly what the log says

2023-12-15 00_50_23- Feature  Whisparr Support · Issue #85 · aetaric_checkrr - Vivaldi

aetaric commented 6 months ago

To explain what's happening with \\, Windows is the only OS to use \ as a path separator. Every other OS uses /. Checkrr natively supports OS specific path speparators, but it has to log with doubled \ to avoid using it for what every other system uses it for, an escape character.

On the off chance I missed something implementing whisparr as a unique type, does it contact the service if you use service: sonarr?

thorman123 commented 6 months ago

Okay so after a lot of further testing, checkrr doesn't seem to be deleting any files on any service... I used your method to check my radarr and sonarr installs as well and checkrr isn't deleting the files for the arrs to reaquire the files... from what I understand about checkrr it finds a corrupted file, deletes it, then sends the info to the arrs, right? If yes checkrr isn't deleting the files off any service. I even went back to the official 3.2.2 build and it still doesn't delete the files...