Difference between revisions of "Tdarr"

From Indie IT Wiki
 
(6 intermediate revisions by the same user not shown)
Line 18: Line 18:
  
 
Templating - https://docs.tdarr.io/docs/plugins/flow-plugins/basics#plugin-variable-templating
 
Templating - https://docs.tdarr.io/docs/plugins/flow-plugins/basics#plugin-variable-templating
 +
 +
== Delete Movie From Radarr ==
 +
 +
This involves the use of 2 scripts.
 +
 +
# to output the Radarr movie ID as a number to a text file
 +
# get Tdarr to read that text file and then use curl to access the Radarr API and delete the movie files
 +
 +
=== Script #1 ===
 +
 +
Save it to the location where Radarr keeps its config folder...
 +
 +
$ cat /root/docker/stacks/servarr/data/radarr/config/movie_id_for_tdarr.sh
 +
 +
#!/usr/bin/env bash
 +
# movie_id_for_tdarr.sh
 +
 +
# if this is a Radarr Test event then just exit
 +
if [[ "${radarr_eventtype}" == "Test" ]]; then
 +
  echo "`date` - radarr_eventtype=${radarr_eventtype}" >>/config/movie_id_for_tdarr.log
 +
  exit;
 +
fi
 +
 +
# output the movie id to a text file for tdarr to read
 +
echo "$radarr_movie_id" > "${radarr_movie_path}/radarr_id.txt"
 +
echo "`date` - radarr_eventtype=${radarr_eventtype}" >>/config/movie_id_for_tdarr.log
 +
echo "`date` - radarr_movie_id=${radarr_movie_id}" >>/config/movie_id_for_tdarr.log
 +
echo "`date` - radarr_movie_path=${radarr_movie_path}" >>/config/movie_id_for_tdarr.log
 +
 +
# check txt file and read in to variable to test
 +
sleep 1s
 +
ID=$( cat "${radarr_movie_path}/radarr_id.txt" )
 +
echo "ID=$ID"
 +
 +
exit;
 +
 +
Then, go to '''Radarr > Settings > Connect > Custom Script > Add Connection > Custom Script'''
 +
 +
Name: Movie ID for Tdarr
 +
Notification Triggers: On File Import, On File Upgrade
 +
Browse to /config/movie_id_for_tdarr.sh
 +
Test
 +
Save
 +
 +
=== Script #2 ===
 +
 +
Save it to a location that Tdarr can access ...
 +
 +
$ cat /home/paully/data/bin/RADARR_TDARR_delete_movie.sh
 +
 +
#!/bin/bash
 +
# RADARR_TDARR_delete_movie.sh
 +
 +
INPUT="$1";
 +
echo "INPUT=${INPUT}";
 +
MOVIE="${INPUT}";
 +
echo "MOVIE=${MOVIE}";
 +
MOVIEPATH="/data/media/movies/$MOVIE";
 +
echo "MOVIEPATH=$MOVIEPATH";
 +
ID=$( cat "$MOVIEPATH/radarr_id.txt" );
 +
echo "ID=${ID}";
 +
echo "Sleeping for 5 seconds ...";
 +
sleep 5s;
 +
curl -s -X "DELETE" "<nowiki>http://0.0.0.0:7878/api/v3/movie/${ID}?deleteFiles=true&addImportExclusion=false</nowiki>" -H "accept: application/json" -H "X-Api-Key: xxxxxxxxxxyourapikeyxxxxxxxxxxxxxx";
 +
echo "... deleted.";
 +
 +
exit;
 +
 +
Then, call it by adding the 'Run CLI' plugin to the very end of your Tdarr Flow...
 +
 +
Name: Delete Movie in Radarr
 +
Use Custom CLI Path?  Toggle ON
 +
Custom CLI Path: /data/bin/RADARR_TDARR_delete_movie.sh
 +
CLI Arguments: "{{{args.variables.user.data}}}"
 +
 +
This will then pass the 'Movie Title (Year)' to the script which then finds the correct folder in Radarr to read the radarr_id.txt file and use it with curl.
 +
 +
The above variable "{{{args.variables.user.data}}}" is obtained by adding the 'Custom JS Function' to the beginning of your Tdarr Flow to get the 'Movie Name (Year)' and store it for use in your flow.
 +
 +
Name: Store 'Movie Name (Year)' as variable
 +
JS Code ...
 +
 +
module.exports = async (args) => {
 +
  const parts = args.inputFileObj._id.split('/');
 +
  const data = parts[parts.length - 1].split('.')[0];
 +
 +
  if (!args.variables.user) {
 +
    args.variables.user = {};
 +
  }
 +
 +
  args.variables.user.data = data;
 +
 +
  return {
 +
    outputFileObj: args.inputFileObj,
 +
    outputNumber: 1,
 +
    variables: args.variables,
 +
  };
 +
};
 +
 +
I am pretty pleased with this result so I hope it helps someone else, just as many people have helped me :)
  
 
== Help ==
 
== Help ==
 +
 +
=== Clear Cache ===
 +
 +
All from the main page. Pause all nodes. Under 'staging section'. 'Staged files' tab(I will usually skip the trouble file), then to the 'Cache browser' tab delete [X] everything in that tab. Restart the main docker and nodes. Then go back to the 'transcode successful/not required tab' and under the 'status' section and re-queue the trouble file. Unpause all nodes. Hopefully that will end your loop you are in.
 +
 +
=== Reddit ===
  
 
https://www.reddit.com/r/Tdarr
 
https://www.reddit.com/r/Tdarr

Latest revision as of 11:22, 22 November 2024

Introduction

Tdarr is one of the Starr apps and is a automated transcoding system - taking your original video files and remixing them to a smaller size.

It is also capable of distributing the jobs to other computer nodes on your network thereby reducing the time needed to work.

You build flows of work that can be finely tuned to handle all sorts of scenarios. For example ...

Original File  -->  Check  -->  Clean  -->  Transcode to 720p with only 1 English audio track  -->  Move to Emby Library  -->  Notify

Variables

Filename without extension = "{{{args.inputFileObj._id}}}"

Storing the movie name and year - https://www.reddit.com/r/Tdarr/comments/1g3m7i7/flow_variable_to_store_movie_name_year/

Loops and variables - https://www.reddit.com/r/Tdarr/comments/17ukeoe/is_there_a_better_way_to_do_fallback_conversion/

Templating - https://docs.tdarr.io/docs/plugins/flow-plugins/basics#plugin-variable-templating

Delete Movie From Radarr

This involves the use of 2 scripts.

  1. to output the Radarr movie ID as a number to a text file
  2. get Tdarr to read that text file and then use curl to access the Radarr API and delete the movie files

Script #1

Save it to the location where Radarr keeps its config folder...

$ cat /root/docker/stacks/servarr/data/radarr/config/movie_id_for_tdarr.sh

#!/usr/bin/env bash
# movie_id_for_tdarr.sh

# if this is a Radarr Test event then just exit
if [[ "${radarr_eventtype}" == "Test" ]]; then
  echo "`date` - radarr_eventtype=${radarr_eventtype}" >>/config/movie_id_for_tdarr.log
  exit;
fi

# output the movie id to a text file for tdarr to read
echo "$radarr_movie_id" > "${radarr_movie_path}/radarr_id.txt"
echo "`date` - radarr_eventtype=${radarr_eventtype}" >>/config/movie_id_for_tdarr.log
echo "`date` - radarr_movie_id=${radarr_movie_id}" >>/config/movie_id_for_tdarr.log
echo "`date` - radarr_movie_path=${radarr_movie_path}" >>/config/movie_id_for_tdarr.log

# check txt file and read in to variable to test
sleep 1s
ID=$( cat "${radarr_movie_path}/radarr_id.txt" )
echo "ID=$ID"

exit;

Then, go to Radarr > Settings > Connect > Custom Script > Add Connection > Custom Script

Name: Movie ID for Tdarr
Notification Triggers: On File Import, On File Upgrade
Browse to /config/movie_id_for_tdarr.sh
Test
Save

Script #2

Save it to a location that Tdarr can access ...

$ cat /home/paully/data/bin/RADARR_TDARR_delete_movie.sh

#!/bin/bash
# RADARR_TDARR_delete_movie.sh

INPUT="$1";
echo "INPUT=${INPUT}";
MOVIE="${INPUT}";
echo "MOVIE=${MOVIE}";
MOVIEPATH="/data/media/movies/$MOVIE";
echo "MOVIEPATH=$MOVIEPATH";
ID=$( cat "$MOVIEPATH/radarr_id.txt" );
echo "ID=${ID}";
echo "Sleeping for 5 seconds ...";
sleep 5s;
curl -s -X "DELETE" "http://0.0.0.0:7878/api/v3/movie/${ID}?deleteFiles=true&addImportExclusion=false" -H "accept: application/json" -H "X-Api-Key: xxxxxxxxxxyourapikeyxxxxxxxxxxxxxx";
echo "... deleted.";

exit;

Then, call it by adding the 'Run CLI' plugin to the very end of your Tdarr Flow...

Name: Delete Movie in Radarr
Use Custom CLI Path?  Toggle ON
Custom CLI Path: /data/bin/RADARR_TDARR_delete_movie.sh
CLI Arguments: "{{{args.variables.user.data}}}"

This will then pass the 'Movie Title (Year)' to the script which then finds the correct folder in Radarr to read the radarr_id.txt file and use it with curl.

The above variable "{{{args.variables.user.data}}}" is obtained by adding the 'Custom JS Function' to the beginning of your Tdarr Flow to get the 'Movie Name (Year)' and store it for use in your flow.

Name: Store 'Movie Name (Year)' as variable JS Code ...

module.exports = async (args) => {
  const parts = args.inputFileObj._id.split('/');
  const data = parts[parts.length - 1].split('.')[0];

  if (!args.variables.user) {
    args.variables.user = {};
  }

  args.variables.user.data = data;

  return {
    outputFileObj: args.inputFileObj,
    outputNumber: 1,
    variables: args.variables,
  };
};

I am pretty pleased with this result so I hope it helps someone else, just as many people have helped me :)

Help

Clear Cache

All from the main page. Pause all nodes. Under 'staging section'. 'Staged files' tab(I will usually skip the trouble file), then to the 'Cache browser' tab delete [X] everything in that tab. Restart the main docker and nodes. Then go back to the 'transcode successful/not required tab' and under the 'status' section and re-queue the trouble file. Unpause all nodes. Hopefully that will end your loop you are in.

Reddit

https://www.reddit.com/r/Tdarr