-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple libraries #2
Comments
I have separate *arr instances and tdarr libraries. So that was never a thought of mine. you would need to modify the script, one of the input args contains the file path. You could check the paths and setup additional env vars for input. |
This is what I've come up with so far. Untested, will give it a try tomorrow. This should also retain the original behaviour of the script if you only have a single library/multiple instances. #!/bin/bash
##########################################
# For a single library, set the following:
##########################################
TDARR_DB_ID="value1"
############################################
# For multiple libraries, set the following:
############################################
# How many libraries do you have?
LIBRARY_COUNT=6
# Library ID's. Add or remove ID's depending on your requirements.
TDARR_DB_ID_1="value1"
TDARR_DB_ID_2="value2"
TDARR_DB_ID_3="value3"
TDARR_DB_ID_4="value4"
TDARR_DB_ID_5="value5"
TDARR_DB_ID_6="value6"
if [[ -n "${sonarr_eventtype}" ]]; then
FILE_PATH=${sonarr_episodefile_path}
EVENT_TYPE="${sonarr_eventtype}"
elif [[ -n "${radarr_eventtype}" ]]; then
FILE_PATH=${radarr_moviefile_path}
EVENT_TYPE="${radarr_eventtype}"
fi
if [[ -n "${TDARR_PATH_TRANSLATE}" ]]; then
FILE_PATH=$(echo "$FILE_PATH" | sed "s|${TDARR_PATH_TRANSLATE}|")
fi
if [ -v TDARR_DB_ID ]
then
PAYLOAD="{\"data\": {\"scanConfig\": {\"dbID\": \"${TDARR_DB_ID}\", \"arrayOrPath\": [\"$FILE_PATH\"], \"mode\": \"scanFolderWatcher\" }}}"
else
for i in $(seq 1 $LIBRARY_COUNT)
do
TDARR_DB_ID=TDARR_DB_ID_${i}
PAYLOAD="{\"data\": {\"scanConfig\": {\"dbID\": \"${!TDARR_DB_ID}\", \"arrayOrPath\": [\"$FILE_PATH\"], \"mode\": \"scanFolderWatcher\" }}}"
done
fi
# debug logs - payload is most important
echo "EVENT_TYPE: $EVENT_TYPE"
echo "TDARR_URL: $TDARR_URL"
echo "PAYLOAD: $PAYLOAD"
# don't call tdarr when testing
if [[ -n "$EVENT_TYPE" && "$EVENT_TYPE" != "Test" ]]; then
curl --silent --request POST \
--url ${TDARR_URL}/api/v2/scan-files \
--header 'content-type: application/json' \
--data "$PAYLOAD" \
--location \
--insecure
fi If this is useful (and if it works in production), I'd be happy to raise a PR if appropriate. |
I’ve been so busy, I just now had time to sit down and look at the code you posted. In the past I had issues with calling the tdarr scan endpoint, with a file that wasn’t actually in the library on the HTTP request. The file would get picked up and converted and put in the wrong output folder. so I’m not certain looping and calling the endpoint for every library defined is an good idea. Let me sit and think on this, and see if I can come up with something more flexible. |
I have not tested end to end but the script on test in *arr app shows Success! I went with the python version and used dockermods to install python3 and request in the container. This is assuming that you use lsio images ...
|
I think you might have my repo confused with tdarr_inform my goal was to use bash/curl to eliminate any additional container dependencies. But yes, what you have will work fine with tdarr_inform. I’d probably roll your own image though. Every container restart will reinstall python before it bootstraps sonarr. |
Heya,
For multiple libraries, how best to get this done?
Cheers!
The text was updated successfully, but these errors were encountered: