goose-ws / bash-scripts

A collection of bash scripts I've hacked together over time
MIT License
10 stars 3 forks source link

Sonarr Update TBA issues #2

Closed Hannah-GBS closed 1 year ago

Hannah-GBS commented 1 year ago

I love how verbose the new script can be, but it still seems to have some issues on my machine.

It correctly finds 4 files that have TBA titles, but then seems to set every series on sonarr to update (which I can see happening on sonarr's web UI) and still fails to rename everything. I think this is because it's failing to find the Series ID? Does a RefreshSeries call to sonarr with no ID set refresh every series, while a RenameSeries with no ID does nothing?

Sonarr version 3.0.10.1567 Attached is the console output. update sonarr log.txt

goose-ws commented 1 year ago

Thanks for the console output, that's helpful.

While this is entirely unrelated to your issue, as long as your user has permission to run commands on the docker socket, you shouldn't need to run it with sudo. The script is essentially a wrapper for some docker and curl commands, but the rename occurs from inside the sonarr container. I mention that for the sake of preventing unnecessary sudo. I'm not a malicious actor, but sudo'ing scripts can result in bad outcomes if the author is a malicious actor.

Off the cusp, I noticed that your file naming scheme doesn't quite match what I use. Lines 35-43 mention the required naming scheme. This is because the entire premise of finding TBA episodes relies on a find command searching for the pattern * - TBA - *. A more correct approach may be to use the API to search for episodes with the title "TBA", if the API is capable of that, I'm not sure. I'll have to look into that.

In any case, I'll dig into the output more closely and see if I can give you an update in a day or so.

Hannah-GBS commented 1 year ago

The sudo thing is very true, bad habit of mine, though I do tend to read through the scripts I run.

It does find the files though, no? It's looking for * TBA * not * - TBA - *. (Though the Chainsaw Man episodes are wrong because I realised I never set up the Anime file naming correctly as I don't have a lot of anime on my system. My Standard naming scheme includes the dashes)

Hannah-GBS commented 1 year ago

Oh is it because my media is too many layers deep? /data/media/Videos/TV Shows/<Series title>?

The script correctly detects the library as /data/media/Videos/TV Shows but then later assumes a 2 directory depth for Series folders, so it's only sending /data/media to the api to lookup Series ID`

goose-ws commented 1 year ago

It does find the files though, no? It's looking for * TBA * not * - TBA - *.

You are correct, looking at Line 347, the pattern is * TBA *, not with the dashes as I thought.

Oh is it because my media is too many layers deep? /data/media/Videos/TV Shows/<Series title>?

That does seem to play a role in it, I didn't define logic for more than one layer of depth. Pushing a commit now, try the updated version and see if that does it for you. If not I'll recreate your environment and test further.

Hannah-GBS commented 1 year ago

That works perfectly now! Appreciate the lightning speed updates!

goose-ws commented 1 year ago

You're welcome. Given that you are actively using the script, there's a push coming probably later today or tomorrow to enable support for multiple containers. If you update the script but not the .env file it'll fail with an error that your .env needs to be updated. Essentially the change is:

# Docker container name
containerName="sonarr"

Becomes an array:

# Docker container names, this is an array of the Sonarr container names you want this script to interact with
# Format is: ("sonarr" "sonarr-4k" "sonarr-anime")
containers=("sonarr")

No need to update your .env file if you do not update the script. Just if/when you update the script, that's the change. In any case, glad I could help/it was a quick fix. Happy sonarr'ing.