-
-
Save goose-ws/fb5ba309081b03f77ff39127f7bc563f to your computer and use it in GitHub Desktop.
This script has been rewritten and improved, and is now located in my `bash scripts` repository: https://github.com/goose-ws/bash-scripts | |
More specifically, here is the script: https://github.com/goose-ws/bash-scripts/blob/main/sonarr-update-tba.bash | |
And here is the corresponding `.env` file you need to put in the same directory as the script: https://github.com/goose-ws/bash-scripts/blob/main/sonarr-update-tba.env.example |
@Sixcurses Thanks for the comment. Both -i
and -t
were actually unnecessary, given the way the script works. I've updated the gist to the most recent version.
This doesn't seem to be working for me any more. It doesn't rename anything, and I get no console output of any errors.
@Hannah-GBS - I actually had on my to-do list to do a total rewrite of this script this weekend to be v3/v4 compatible and generally clean up/standardized to the way I script now. I'll let you know when it's done and published, I'd expect in the next week or so.
@Hannah-GBS and @Sixcurses - I ended up with some free time today, and went ahead with a rewrite.
This script has been rewritten and improved, and is now located in my bash scripts
repository: https://github.com/goose-ws/bash-scripts
More specifically, here is the script: https://github.com/goose-ws/bash-scripts/blob/main/sonarr-update-tba.bash
And here is the corresponding .env
file you need to put in the same directory as the script: https://github.com/goose-ws/bash-scripts/blob/main/sonarr-update-tba.env.example
Let me know if you need further assistance with it.
Thanks for the updated script, how fisable would it be to add an ignore root folder? I have a library with PT-PT with shows that most of the time have TBA as the title and never gets updated, so I would like to ignore the entire root folder. Thanks in advance :)
@DeuX01, sure, open a feature request issue on the repo and I'll get to it in the next week or so.
Just did! Thanks a bunch :)
Compliments on the script, it's amazing and infinitely better than my few admin hacks.
I read it to try to understand all of it then just gave up and ran it! Worked perfectly first time.
I came across this chat in search of a solution to a similar problem, I have Unmanic transcoding new Sonarr / Radarr downloads in Unraid. The issue i'm trying to fix is getting those files renamed after the transcoding has replaced the original file with the smaller (usually) transcoded file.
After the daily refresh, Sonarr correctly identifies the video/sound codecs ("h265" and "AAC") but the file name still reflects the old codecs (for example "h264" and "EAC3")
I do a bulk rename in Sonarr / Radarr every morning to fix this and it works just fine, producing the following for Sonarr.
- Old name: "The Test - S02E01 - Own Your Own Space (2023-01-13) WEBDL-720p x264 EAC3.mp4"
- New name: "The Test - S02E01 - Own Your Own Space (2023-01-13) WEBDL-720p h265 AAC.mkv"
It's a bit of a hack, but gets the job done - I do the following;
- Custom filter new shows/movies added in the last 3 days and run the rename on those shows/movies.
- Custom filter shows with new episodes added in the last 3 days and run the rename on those shows.
There's a fair bit of redundancy as I do it daily on 3 day's worth of additions, and it renames all the episodes of a series when only one really probably needs renaming for existing shows (spinning up the array as only 7 days worth of new content lives in the cache), and it's renaming 3 days' worth of new shows in case I forget one day. The alternative is a bulk re-name of all shows, which also spins up the array disks unnecessarily.
Solution:
I'd like to modify your script to do this in Sonarr (and Radarr but Sonarr good for a start)
- Find all episodes added in the last day (since it last ran, assuming I run it daily) - this will find new episodes in old shows and new episodes in new shows.
- Rename them to reflect the correct codecs
I'd probably then run the original script to solve the TBA issue (which i'd never even thought of - thanks again)
Does this sound possible? it would require a search for the episodes by date added (or file date as this will be a few minutes later after Unmanic has done transcoding it)
I'll have a look myself and try to change it but don't want to break anything and my scripting is a bit basic.
Best Regards and thanks again for the script!
Aidan
@SlingerAJ no need for that, install the Sonarr plugin in unmanic and enable the option to trigger a rename in sonarr
Tried that and played with the settings for a week or two with no luck, importing / refresh & rename. Nothing seemed to work. After it ran the files were unchanged - had it at the end of the sequence of plugins.
Was wondering if it was an API access issue. How is yours set up?
#!/bin/bash
/usr/bin/apt-get update
python3 -m pip install pyarr
python3 -m pip install humanfriendly
should do it - put that in a file named startup.sh, make it executable (chmod +x startup.sh) and put it in /config
in the container. restart unmanic. everytime unmanic is started &/or recreated it'll install these. You won't need to worry about it any more. You can add other things to this if there are other utilities you need to install in your unmanic container. This should fix the api issue
Hmm - didn't seem to work
Doesn't seem to be automatically triggering refresh / rename
Let me look at the logs - Unmanic or Sonarr (or both)? Trouble is I changed the minimum file size from 500M to 300m and Unmanic has now grabbed a load of existing files to transcode so might need to dig to find this specific example.
#!/bin/bash
/usr/bin/apt-get update
python3 -m pip install pyarr python3 -m pip install humanfriendly
should do it - put that in a file named startup.sh, make it executable (chmod +x startup.sh) and put it in
/config
in the container. restart unmanic. everytime unmanic is started &/or recreated it'll install these. You won't need to worry about it any more. You can add other things to this if there are other utilities you need to install in your unmanic container. This should fix the api issue
I created this, the config folder is in /appdata/unmanic/.unmanic/config
So I added the script in here - that correct?
You need to put the script inside /mnt/user/appdata/unmanic and then restart the container. When you restart the container the proper modules will be installed inside the container
Thats for your OS, modules inside the container are independent from the modules installed in the host. Point being is that the missing modules need to be installed inside the container not in the host
You need to put the script inside /mnt/user/appdata/unmanic and then restart the container. When you restart the container the proper modules will be installed inside the container
OK, moved the script to /mnt/user/appdata/unmanic/startup.sh - it's the only thing in there except the two hidden folders.
Just ran it, one error and two warnings. Can I now restart unmanic or do we need to resolve the problem in line 3?
Restart the container and check the logs. You should see both modules being pulled, then make sure that Sonarr plugin in unmanic has the rename option enabled and it should work.
Restart the container and check the logs. You should see both modules being pulled, then make sure that Sonarr plugin in unmanic has the rename option enabled and it should work.
Container startup logs - looks ok?
**** (permissions_config) Setting permissions ****
**** (permissions_config) Adding run user to video group ****
**** (custom-setup-script) Calling custom user setup script ****
Get:1 https://deb.nodesource.com/node_20.x nodistro InRelease [12.1 kB]
Get:2 https://deb.nodesource.com/node_20.x nodistro/main amd64 Packages [7,133 B]
Get:3 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Get:4 https://repo.jellyfin.org/ubuntu jammy InRelease [6,660 B]
Get:5 https://sgp1.mirror.jellyfin.org/files/ubuntu jammy/main amd64 Packages [1,895 B]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:7 https://repositories.intel.com/gpu/ubuntu jammy InRelease [15.4 kB]
Err:7 https://repositories.intel.com/gpu/ubuntu jammy InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 28DA432DAAC8BAEA
Get:8 http://archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:9 http://archive.ubuntu.com/ubuntu jammy/multiverse Sources [361 kB]
Get:10 http://archive.ubuntu.com/ubuntu jammy/main Sources [1,668 kB]
Get:11 http://archive.ubuntu.com/ubuntu jammy/restricted Sources [28.2 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy/universe Sources [22.0 MB]
Get:13 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages [164 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages [1,792 kB]
Get:15 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [17.5 MB]
Get:16 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [266 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy-updates/universe Sources [415 kB]
Get:18 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse Sources [21.9 kB]
Get:19 http://archive.ubuntu.com/ubuntu jammy-updates/main Sources [611 kB]
Get:20 http://archive.ubuntu.com/ubuntu jammy-updates/restricted Sources [78.2 kB]
Get:21 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [2,125 kB]
Get:22 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [2,468 kB]
Get:23 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1,375 kB]
Get:24 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [51.1 kB]
Get:25 http://archive.ubuntu.com/ubuntu jammy-security/universe Sources [238 kB]
Get:26 http://archive.ubuntu.com/ubuntu jammy-security/restricted Sources [73.9 kB]
Get:27 http://archive.ubuntu.com/ubuntu jammy-security/main Sources [337 kB]
Get:28 http://archive.ubuntu.com/ubuntu jammy-security/multiverse Sources [12.2 kB]
Get:29 http://archive.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [2,395 kB]
Get:30 http://archive.ubuntu.com/ubuntu jammy-security/main amd64 Packages [1,853 kB]
Get:31 http://archive.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [1,083 kB]
Get:32 http://archive.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [44.7 kB]
Reading package lists...
Collecting pyarr
Downloading pyarr-5.2.0-py3-none-any.whl (39 kB)
Requirement already satisfied: requests<3.0.0,>=2.28.2 in /usr/local/lib/python3.10/dist-packages (from pyarr) (2.31.0)
Collecting types-requests<3.0.0.0,>=2.28.11.17
Downloading types_requests-2.32.0.20240523-py3-none-any.whl (15 kB)
Collecting overrides<8.0.0,>=7.3.1
Downloading overrides-7.7.0-py3-none-any.whl (17 kB)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.28.2->pyarr) (2024.2.2)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.28.2->pyarr) (3.3.2)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.28.2->pyarr) (2.2.1)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.28.2->pyarr) (3.7)
Installing collected packages: types-requests, overrides, pyarr
Successfully installed overrides-7.7.0 pyarr-5.2.0 types-requests-2.32.0.20240523
Collecting humanfriendly
Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 86.8/86.8 KB 2.4 MB/s eta 0:00:00
Installing collected packages: humanfriendly
Successfully installed humanfriendly-10.0
[custom-init] No custom files found, skipping...
[ls.io-init] done.
Yep it should work now
It works - YOU BEAUTY!
Thanks for all the support, so what did we just do, install python3 in the container so python based plugins can work? I wonder why this isn't installed as standard if it's a dependency for some of the plugins.
For some reason Unmanic (since the first re-start) has now found 1500 files to transcode, most of which are failing (output file larger than the input file). The only prior change was to set the minimum file size to 300M (it was 500M). Might change it back as small x264 files don't seem to benefit from transcoding in terms of size reduction.
Thanks so much, wouldn't have figured this out myself in a month of Sundays and didn't find anything when i googled the problem for the plugin/unmanic.
We just installed the missing modules needed by the Sonarr and Radarr plugins. Python3 already comes installed by default, but the modules were missing. By keeping the startup script there it will always reinstall them even if you rebuild the container. Enjoy
Brilliant, thanks again!
Been watching it for a day now, it's very cool to see it all working properly.
Thanks for making this
I've changed
docker exec -it
todocker exec -t
to make it work for unraid user scripts.