fix: TheTVDB v4 API compatibility + provider-specific renamelist entries

- addrename.sh: replace dead TheTVDB HTML scrape (404 since site overhaul)
  with new v4 API (api.thetvdb.com) using optional TVDB_API_KEY from
  JDAutoConfig; fall back to manual name entry when name cannot be fetched
- rename.sh: per-entry provider stored as renamelist line 6 (IDs are
  provider-specific: TVDB id != TMDB id); old 6-line entries fall back to
  the configured category default
- rename.sh: filebot_rename() validates db value and logs provider/id;
  movie fallback now uses config (FileBotLang, Movies path) instead of
  hardcoded German//mnt/Medien/Filme; drop dead names() TVDB scraper
- fix pre-existing syntax error: three prompt lines in addrename.sh had
  unbalanced quotes (odd count) - bash -n failed on the whole script
- README: filebot 4.8.5 note replaced (new TVDB v4 API needs 5.x+),
  new 'Metadata providers' section incl. TMDB German episode caveat
- JDAutoConfig: document provider options + optional TVDB_API_KEY
- i18n: add tvdb_key_missing/name_fetch_failed/enter_manually (addrename)
  and no_db/using_db (rename) for de_DE, en_GB, en_US
This commit is contained in:
ARIA committed 2026-11-08 21:31:30 +01:00
1 parent 0ca3e19117
commit 7a05877139
10 files changed
+109 -29

No files matched your search

+11
View File
@@ -73,6 +73,10 @@ Encoder=nVidia
#### FileBot: #### #### FileBot: ####
############################################################################################ ############################################################################################
# MovieDB/SeriesDB/AnimeDB: TheMovieDB | TheMovieDB::TV | TheTVDB | AniDB
# TheTVDB's new v4 API needs a recent filebot (5.x+). IDs are provider-specific
# (a TVDB id is NOT a TMDB id); renamelist entries store their own provider
# (line 6), so old entries keep working after you switch the defaults here.
MovieDB=TheMovieDB MovieDB=TheMovieDB
SeriesDB=TheTVDB SeriesDB=TheTVDB
AnimeDB=TheTVDB AnimeDB=TheTVDB
@@ -82,3 +86,10 @@ SeriesName="{n} {y}/Season {s}/{n} - {s00e00} - {t}"
AnimeName="{n} {y}/Season {s}/{n} - {s00e00} - {t}" AnimeName="{n} {y}/Season {s}/{n} - {s00e00} - {t}"
FileBotLang=German FileBotLang=German
# Optional: TheTVDB v4 API project key (thetvdb.com) - used by addrename.sh for
# the TVDB name check. Leave empty if not using TheTVDB.
TVDB_API_KEY=
# Note: TheMovieDB::TV often lacks German episode titles (--lang German then falls
# back to English). TheTVDB has better DE episode data but needs filebot 5.x+.
+15 -1
View File
@@ -12,7 +12,7 @@ I try to use as few external programs as possible, so that everyone can use them
- JDownloader obious. Archive Extractor + Event Scripter so the script can be startet if archive is successfully unpacked. - JDownloader obious. Archive Extractor + Event Scripter so the script can be startet if archive is successfully unpacked.
- FFmpeg (If used with Nvidia, [use this guide for NVENC encoding](https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/)) - FFmpeg (If used with Nvidia, [use this guide for NVENC encoding](https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/))
- For encoding. Also used for checking codecs and duration (via ffprobe command). - For encoding. Also used for checking codecs and duration (via ffprobe command).
- [Filebot](https://www.filebot.net/#download) (I use version 4.8.5 myself) - [Filebot](https://www.filebot.net/#download) (use the latest 5.x - TheTVDB's new v4 API does not work with older versions)
- For renaming. Best match rate so unrivaled if you ask me. - For renaming. Best match rate so unrivaled if you ask me.
- Bash version 4 or higher ( bash --version so enter command in terminal) - Bash version 4 or higher ( bash --version so enter command in terminal)
- Some commands need bash v4 like for converting to lower/uppercase. - Some commands need bash v4 like for converting to lower/uppercase.
@@ -34,6 +34,20 @@ You can setup Discord Nextcloud Talk and/or Apprise Notifications if:
- Duration of encoded video doesn't match sourcefile (encoding error) - Duration of encoded video doesn't match sourcefile (encoding error)
- FileBot couldn't rename files 3 times in a row - FileBot couldn't rename files 3 times in a row
# Metadata providers (FileBot --db):
You can pick the metadata provider per category in config.sh (6) FileBot:
- TheMovieDB - movies
- TheMovieDB::TV - TV series (weaker German episode-title coverage; --lang German often falls back to English)
- TheTVDB - TV series / anime (best DE episode data, but needs a recent filebot 5.x+ since the TheTVDB v4 API overhaul)
- AniDB - anime
renamelist entries store the provider they were added with (line 6), so each entry
keeps working even after you switch the default provider. But IDs are provider-specific:
a TVDB series id is NOT a TheMovieDB id - re-add an entry (or edit the line) if you
switch the provider for it. If you keep TheTVDB, you can set TVDB_API_KEY in JDAutoConfig
(optional, used by addrename.sh for the name check).
# Known Bugs: # Known Bugs:
- FileBot can't rename files sometimes, even if it restarts the whole process 2 times in a row. Need to manually start jdautoenc.sh again, works first time.. always. Dunno (detects the right anime/series/movie but couldn't move them, or access them. Working on it) - FileBot can't rename files sometimes, even if it restarts the whole process 2 times in a row. Need to manually start jdautoenc.sh again, works first time.. always. Dunno (detects the right anime/series/movie but couldn't move them, or access them. Working on it)
+41 -13
View File
@@ -12,6 +12,8 @@ cyan='\033[0;36m' # ${cyan}
## Rename Skript Pfad: ## Rename Skript Pfad:
JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null) JDAutoConfig=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)
renamelist=$(grep "renamelist=" "$JDAutoConfig" | sed 's/renamelist=//g') renamelist=$(grep "renamelist=" "$JDAutoConfig" | sed 's/renamelist=//g')
# Optional: TheTVDB v4 API project key for the name check (see JDAutoConfig)
TVDB_API_KEY=$(grep "TVDB_API_KEY=" "$JDAutoConfig" 2>/dev/null | sed 's/.*=//g')
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source "$(dirname "$0")/i18n.sh" source "$(dirname "$0")/i18n.sh"
@@ -22,10 +24,18 @@ get_DB() {
curl_name() { curl_name() {
if [[ $dbid == "TheTVDB" ]]; then if [[ $dbid == "TheTVDB" ]]; then
if [[ -z $(curl -sL https://www.thetvdb.com/dereferrer/series/"$dbentry" | grep -i -A1 "deu" | grep "data-title" | sed 's/.*="\|"//g' | sed "s/&rsquo;/'/g") ]]; then # The old HTML scrape (thetvdb.com/dereferrer/series/<id>) is dead since the TVDB site/API
curl -sL https://www.thetvdb.com/dereferrer/series/"$dbentry" | grep -i -A1 "en" | grep "data-title" | sed 's/.*="\|"//g' | sed "s/&rsquo;/'/g" | head -n 1 # overhaul (returns 404 now). Use the new v4 API with an optional project key from JDAutoConfig.
if [[ -n "$TVDB_API_KEY" ]]; then
local token
token=$(curl -s -X POST https://api.thetvdb.com/login -H "Content-Type: application/json" -d '{"apikey":"'"$TVDB_API_KEY"'"}' | sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
if [[ -n "$token" ]]; then
curl -s "https://api.thetvdb.com/v4/series/$dbentry/basic?language=de" -H "Authorization: Bearer $token" | sed -n 's/.*"name":"\([^"]*\)".*/\1/p' | head -n 1
else
echo "TVDB login failed (check TVDB_API_KEY in JDAutoConfig)." >&2
fi
else else
curl -sL https://www.thetvdb.com/dereferrer/series/"$dbentry" | grep -i -A1 "deu" | grep "data-title" | sed 's/.*="\|"//g' | sed "s/&rsquo;/'/g" | head -n 1 echo "$(tr "tvdb_key_missing")" >&2
fi fi
elif [[ $dbid == "TheMovieDB::TV" ]]; then elif [[ $dbid == "TheMovieDB::TV" ]]; then
curl -sL https://www.themoviedb.org/tv/"$dbentry" | grep -i "TV Series" | sed -e 's/<[^>]*>\|(TV.*//g' curl -sL https://www.themoviedb.org/tv/"$dbentry" | grep -i "TV Series" | sed -e 's/<[^>]*>\|(TV.*//g'
@@ -66,65 +76,83 @@ get_db_id() {
while true; do while true; do
read -rp "$(echo -e "$(tr "add_prompt")" "${cyan}""$(tr "film")""${white}" "$(tr "or_a")" "${blue}""$(tr "anime")""${white}"/"${lblue}""$(tr "series")""${white}" "$(tr "to_rename")") ($(tr "enter_type")): " adding read -rp "$(echo -e "$(tr "add_prompt")" "${cyan}""$(tr "film")""${white}" "$(tr "or_a")" "${blue}""$(tr "anime")""${white}"/"${lblue}""$(tr "series")""${white}" "$(tr "to_rename")") ($(tr "enter_type")): " adding
if [[ ${adding,,} == *"anime"* ]]; then if [[ ${adding,,} == *"anime"* ]]; then
read -rp "$(echo -e "$(tr "by_which")" "${purple}""$(tr "keyword")""${white}" "$(tr "should_the")" "$adding "$(tr "entry_matched")") " key1 read -rp "$(echo -e "$(tr "by_which") ${purple}$(tr "keyword")${white} $(tr "should_the") $adding $(tr "entry_matched")") " key1
read -rp "$(echo -e "${yellow}""$(tr "if_you_want")""${white}", "$(tr "second_keyword")") " key2 read -rp "$(echo -e "${yellow}""$(tr "if_you_want")""${white}", "$(tr "second_keyword")") " key2
dbid=$(get_DB "Anime") dbid=$(get_DB "Anime")
get_db_id get_db_id
read -rp "$(echo -e "$(tr "enter_now")" "${purple}""$dbid""${white}" "$(tr "number")") " dbentry read -rp "$(echo -e "$(tr "enter_now")" "${purple}""$dbid""${white}" "$(tr "number")") " dbentry
echo "$(tr "this_is_anime") $(curl_name)" showname=$(curl_name)
if [[ -z "$showname" ]]; then
read -rp "$(echo -e "$(tr "name_fetch_failed") $(tr "enter_manually")") " showname
fi
echo "$(tr "this_is_anime") $showname"
read -rp "$(tr "is_correct")" wrongformat read -rp "$(tr "is_correct")" wrongformat
if [ "${wrongformat,,}" == "n" ]; then if [ "${wrongformat,,}" == "n" ]; then
tr "manual_add" tr "manual_add"
exit exit
else else
{ {
curl_name echo "$showname"
echo "$key1" echo "$key1"
echo "$key2" echo "$key2"
echo "Anime" echo "Anime"
echo "$dbentry" echo "$dbentry"
# Per-entry provider (IDs are provider-specific! Old entries omit this line.)
echo "$dbid"
echo "" echo ""
} >>"$renamelist" } >>"$renamelist"
fi fi
elif [[ ${adding,,} == *"serie"* ]]; then elif [[ ${adding,,} == *"serie"* ]]; then
read -rp "$(echo -e "$(tr "by_which")" "${purple}""$(tr "keyword")""${white}" "$(tr "should_the")" "$adding "$(tr "entry_matched")") " key1 read -rp "$(echo -e "$(tr "by_which") ${purple}$(tr "keyword")${white} $(tr "should_the") $adding $(tr "entry_matched")") " key1
read -rp "$(echo -e "${yellow}""$(tr "if_you_want")""${white}", "$(tr "second_keyword")") " key2 read -rp "$(echo -e "${yellow}""$(tr "if_you_want")""${white}", "$(tr "second_keyword")") " key2
dbid=$(get_DB "Series") dbid=$(get_DB "Series")
get_db_id get_db_id
read -rp "$(echo -e "$(tr "enter_now")" "${purple}""$dbid""${white}" "$(tr "number")") " dbentry read -rp "$(echo -e "$(tr "enter_now")" "${purple}""$dbid""${white}" "$(tr "number")") " dbentry
echo "$(tr "this_is_series") $(curl_name)" showname=$(curl_name)
if [[ -z "$showname" ]]; then
read -rp "$(echo -e "$(tr "name_fetch_failed") $(tr "enter_manually")") " showname
fi
echo "$(tr "this_is_series") $showname"
read -rp "$(tr "is_correct")" wrongformat read -rp "$(tr "is_correct")" wrongformat
if [ "${wrongformat,,}" == "n" ]; then if [ "${wrongformat,,}" == "n" ]; then
tr "manual_add" tr "manual_add"
exit exit
else else
{ {
curl_name echo "$showname"
echo "$key1" echo "$key1"
echo "$key2" echo "$key2"
echo "Series" echo "Series"
echo "$dbentry" echo "$dbentry"
# Per-entry provider (IDs are provider-specific! Old entries omit this line.)
echo "$dbid"
echo "" echo ""
} >>"$renamelist" } >>"$renamelist"
fi fi
elif [[ ${adding,,} == *"film"* ]]; then elif [[ ${adding,,} == *"film"* ]]; then
read -rp "$(echo -e "$(tr "by_which")" "${purple}""$(tr "keyword")""${white}" "$(tr "should_the")" "$adding "$(tr "entry_matched")") " key1 read -rp "$(echo -e "$(tr "by_which") ${purple}$(tr "keyword")${white} $(tr "should_the") $adding $(tr "entry_matched")") " key1
read -rp "$(echo -e "${yellow}""$(tr "if_you_want")""${white}", "$(tr "second_keyword")") " key2 read -rp "$(echo -e "${yellow}""$(tr "if_you_want")""${white}", "$(tr "second_keyword")") " key2
dbid=$(get_DB "Movie") dbid=$(get_DB "Movie")
get_db_id get_db_id
read -rp "$(echo -e "$(tr "enter_now")" "${purple}"TheMovieDB ID"${white}" "$(tr "number")""\n($(tr "url_number"))") " dbentry read -rp "$(echo -e "$(tr "enter_now")" ${purple}TheMovieDB ID${white} "$(tr "number")""\n($(tr "url_number"))") " dbentry
echo "$(tr "this_is_movie") $(curl_movie_name)" showname=$(curl_movie_name)
if [[ -z "$showname" ]]; then
read -rp "$(echo -e "$(tr "name_fetch_failed") $(tr "enter_manually")") " showname
fi
echo "$(tr "this_is_movie") $showname"
read -rp "$(tr "is_correct")" wrongformat read -rp "$(tr "is_correct")" wrongformat
if [ "${wrongformat,,}" == "n" ]; then if [ "${wrongformat,,}" == "n" ]; then
tr "manual_add" tr "manual_add"
exit exit
else else
{ {
curl_movie_name echo "$showname"
echo "$key1" echo "$key1"
echo "$key2" echo "$key2"
echo "Movie" echo "Movie"
echo "$dbentry" echo "$dbentry"
# Per-entry provider (IDs are provider-specific! Old entries omit this line.)
echo "$dbid"
echo "" echo ""
} >>"$renamelist" } >>"$renamelist"
fi fi
+4 -1
View File
@@ -18,4 +18,7 @@ this_is_series Es handelt sich um die Serie:
this_is_movie Es handelt sich um den Film: this_is_movie Es handelt sich um den Film:
enter_now Gebe nun die enter_now Gebe nun die
number ein. number ein.
url_number Nummer in der URL url_number Nummer in der URL
tvdb_key_missing TVDB_API_KEY ist in JDAutoConfig nicht gesetzt - Namensprüfung deaktiviert.
name_fetch_failed Der Name konnte nicht automatisch ermittelt werden.
enter_manually Bitte Namen manuell eingeben:
+3 -1
View File
@@ -16,4 +16,6 @@ delete Lösche
folder Ordner folder Ordner
error_renaming Fehler bei der Umbenennung! error_renaming Fehler bei der Umbenennung!
failed_attempts Fehlgeschlagene Versuche. failed_attempts Fehlgeschlagene Versuche.
completed_successfully Alles wurde erfolgreich beendet! completed_successfully Alles wurde erfolgreich beendet!
no_db Für diesen Eintrag ist keine Datenbank konfiguriert - übersprungen.
using_db Nutze Datenbank
+4 -1
View File
@@ -18,4 +18,7 @@ this_is_series This is the series:
this_is_movie This is the movie: this_is_movie This is the movie:
enter_now Now enter the enter_now Now enter the
number number. number number.
url_number number in the URL url_number number in the URL
tvdb_key_missing TVDB_API_KEY is not set in JDAutoConfig - name check disabled.
name_fetch_failed Could not fetch the name automatically.
enter_manually Please enter the name manually:
+3 -1
View File
@@ -16,4 +16,6 @@ delete Delete
folder folder folder folder
error_renaming Error during renaming! error_renaming Error during renaming!
failed_attempts Failed attempts. failed_attempts Failed attempts.
completed_successfully Everything was completed successfully! completed_successfully Everything was completed successfully!
no_db No database configured for this entry - skipped.
using_db Using database
+4 -1
View File
@@ -18,4 +18,7 @@ this_is_series This is the series:
this_is_movie This is the movie: this_is_movie This is the movie:
enter_now Now enter the enter_now Now enter the
number number. number number.
url_number number in the URL url_number number in the URL
tvdb_key_missing TVDB_API_KEY is not set in JDAutoConfig - name check disabled.
name_fetch_failed Could not fetch the name automatically.
enter_manually Please enter the name manually:
+3 -1
View File
@@ -16,4 +16,6 @@ delete Delete
folder folder folder folder
error_renaming Error during renaming! error_renaming Error during renaming!
failed_attempts Failed attempts. failed_attempts Failed attempts.
completed_successfully Everything was completed successfully! completed_successfully Everything was completed successfully!
no_db No database configured for this entry - skipped.
using_db Using database
+21 -9
View File
@@ -38,14 +38,17 @@ apprise_msg() {
fi fi
} }
# Provider-agnostic: works with any db value filebot supports (TheMovieDB, TheMovieDB::TV, TheTVDB, AniDB, ...)
# The db is passed through from the config / renamelist entry untouched.
filebot_rename() { filebot_rename() {
if [[ -z "$1" ]]; then
log_msg "${red}$(tr "no_db") $5 -> $v"
return 1
fi
log_msg "$(tr "using_db") $1 id $5 -> $v"
filebot -rename "$v" --db "$1" -non-strict --lang "$2" --format "$3/$4" --q "$5" >>"${log[@]}" 2>>"${log[@]}" filebot -rename "$v" --db "$1" -non-strict --lang "$2" --format "$3/$4" --q "$5" >>"${log[@]}" 2>>"${log[@]}"
} }
names() {
curl -sL https://www.thetvdb.com/dereferrer/series/"$1" | grep -i -A1 "deu" | grep "data-title" | sed 's/.*="\|"//g' | sed "s/&rsquo;/'/g"
}
if [[ -f /tmp/jdautoenc.lock ]]; then # ignore if [[ -f /tmp/jdautoenc.lock ]]; then # ignore
log_msg "$(tr "wait_encoding")" log_msg "$(tr "wait_encoding")"
sleep 2 sleep 2
@@ -86,7 +89,15 @@ while read -r name; do
read -r keyword2 read -r keyword2
read -r format read -r format
read -r dbid read -r dbid
read -r nextentry # Line 6 = provider stored per entry by addrename.sh (IDs are provider-specific!
# e.g. a TVDB series id is NOT a TMDB id). Old entries have an empty separator
# line here and fall back to the category default from the config.
read -r entrydb
if [[ -z "$entrydb" ]]; then
nextentry=""
else
read -r nextentry
fi
find -L "${encodes[@]}" -name '*.mkv' -or -name '*.mp4' 2>/dev/null | while IFS= read -r v; do find -L "${encodes[@]}" -name '*.mkv' -or -name '*.mp4' 2>/dev/null | while IFS= read -r v; do
@@ -94,13 +105,13 @@ while read -r name; do
log_msg "$(tr "name") $(basename "$v" | sed 's/\./ /g;s/AAC\|1080p\|WebDL\|[a-z]26[0-9]\|[hH][eE][Vv][Cc]\|[tT]anuki\| dl \| web \|repack\|wayne\|\|[-]\|[gG]er\|[eE]ng\|[sS]ub//g;s/\[[^][]*\]\|WebDL\|JapDub\|CR\|REPACK\|V2DK\|man\|BluRay\|RSG//g;s/_/ /g;s/\( \)*/\1/g')" log_msg "$(tr "name") $(basename "$v" | sed 's/\./ /g;s/AAC\|1080p\|WebDL\|[a-z]26[0-9]\|[hH][eE][Vv][Cc]\|[tT]anuki\| dl \| web \|repack\|wayne\|\|[-]\|[gG]er\|[eE]ng\|[sS]ub//g;s/\[[^][]*\]\|WebDL\|JapDub\|CR\|REPACK\|V2DK\|man\|BluRay\|RSG//g;s/_/ /g;s/\( \)*/\1/g')"
case ${format,,} in case ${format,,} in
anime) anime)
filebot_rename "$AnimeDB" "$FileBotLang" "$Animes" "$AnimeName" "$dbid" filebot_rename "${entrydb:-$AnimeDB}" "$FileBotLang" "$Animes" "$AnimeName" "$dbid"
;; ;;
series) series)
filebot_rename "$SeriesDB" "$FileBotLang" "$Series" "$SeriesName" "$dbid" filebot_rename "${entrydb:-$SeriesDB}" "$FileBotLang" "$Series" "$SeriesName" "$dbid"
;; ;;
movie) movie)
filebot_rename "$MovieDB" "$FileBotLang" "$Movies" "$MovieName" "$dbid" filebot_rename "${entrydb:-$MovieDB}" "$FileBotLang" "$Movies" "$MovieName" "$dbid"
;; ;;
*) *)
log_msg "${red}$v $(tr "does_not_match") $name $(tr "match")" log_msg "${red}$v $(tr "does_not_match") $name $(tr "match")"
@@ -126,7 +137,8 @@ find -L "${encodes[@]}" -name '*.mkv' -or -name '*.mp4' 2>/dev/null | while IFS=
log_msg "$(tr "move") ${purple}$v${white} $(tr "to") $folder" log_msg "$(tr "move") ${purple}$v${white} $(tr "to") $folder"
mv "$v" "$encodes""$folder" >>"${log[@]}" 2>/dev/null mv "$v" "$encodes""$folder" >>"${log[@]}" 2>/dev/null
log_msg "$(tr "start_renaming")" log_msg "$(tr "start_renaming")"
filebot -rename "$encodes""$folder"/"$movie" --db TheMovieDB -non-strict --lang German --format "/mnt/Medien/Filme/{n} ({y})" >>"${log[@]}" # Heuristic movie fallback: always TheMovieDB, but lang/target dir come from the config
filebot -rename "$encodes""$folder"/"$movie" --db TheMovieDB -non-strict --lang "$FileBotLang" --format "${Movies}/{n} ({y})" >>"${log[@]}"
log_msg "$(tr "if_successful") ${red}$(tr "delete")${white} $(tr "folder")" log_msg "$(tr "if_successful") ${red}$(tr "delete")${white} $(tr "folder")"
sleep 5s sleep 5s
rmdir "$encodes"* 2>/dev/null rmdir "$encodes"* 2>/dev/null