@ -5,11 +5,12 @@ arrItemId=$radarr_movie_id
tmdbApiKey = "3b7751e3179f796565d88fdb2fcdf426"
tmdbApiKey = "3b7751e3179f796565d88fdb2fcdf426"
# Debugging
# Debugging
#arrItemId=11677
arrItemId = 11677
#trailerLanguages=en
trailerLanguages = en
#trailerExtrasType=all
trailerExtrasType = all
#trailerOfficialOnly=true
trailerOfficialOnly = true
#trailerSingle=true
trailerKodiCompatibility = true
trailerSingle = false
if [ -z " $arrUrl " ] || [ -z " $arrApiKey " ] ; then
if [ -z " $arrUrl " ] || [ -z " $arrApiKey " ] ; then
arrUrlBase = " $( cat /config/config.xml | xq | jq -r .Config.UrlBase) "
arrUrlBase = " $( cat /config/config.xml | xq | jq -r .Config.UrlBase) "
@ -53,27 +54,41 @@ arrItemData=$(curl -s "$arrUrl/api/v3/movie/$arrItemId?apikey=$arrApiKey")
itemTitle = $( echo " $arrItemData " | jq -r .title)
itemTitle = $( echo " $arrItemData " | jq -r .title)
itemHasFile = $( echo " $arrItemData " | jq -r .hasFile)
itemHasFile = $( echo " $arrItemData " | jq -r .hasFile)
itemPath = " $( echo " $arrItemData " | jq -r ".path" ) "
itemPath = " $( echo " $arrItemData " | jq -r ".path" ) "
itemRelativePath = " $( echo " $arrItemData " | jq -r ".movieFile.relativePath" ) "
itemTrailerId = " $( echo " $arrItemData " | jq -r ".youTubeTrailerId" ) "
itemTrailerId = " $( echo " $arrItemData " | jq -r ".youTubeTrailerId" ) "
tmdbId = " $( echo " $arrItemData " | jq -r ".tmdbId" ) "
tmdbId = " $( echo " $arrItemData " | jq -r ".tmdbId" ) "
if [ ! -d " $itemPath " ] ; then
if [ ! -d " $itemPath " ] ; then
log " $itemTitle :: ERROR: Item Path does not exist ( $itemPath ), Skipping... "
log " $itemTitle :: ERROR: Item Path does not exist ( $itemPath ), Skipping... "
exit
exit
fi
fi
if [ ! -z " $itemTrailerId " ] ; then
if [ " $trailerSingle " = = "true" ] ; then
if [ ! -f " $itemPath /Trailer-trailer.mkv " ] ; then
if [ " $trailerKodiCompatibility " = = "true" ] ; then
trailerFileName = "movie-trailer"
else
trailerFileName = "Trailer-trailer"
fi
if [ ! -z " $itemTrailerId " ] ; then
if [ ! -f " $itemPath / $trailerFileName .mkv " ] ; then
if [ ! -z " $cookiesFile " ] ; then
if [ ! -z " $cookiesFile " ] ; then
yt-dlp --cookies " $cookiesFile " -o " $itemPath /Trailer-trailer " --write-sub --sub-lang $trailerLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass " https://www.youtube.com/watch?v= $itemTrailerId "
yt-dlp --cookies " $cookiesFile " -o " $itemPath / $trailerFileName " --write-sub --sub-lang $trailerLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass " https://www.youtube.com/watch?v= $itemTrailerId "
else
else
yt-dlp -o " $itemPath /Trailer-trailer " --write-sub --sub-lang $trailerLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass " https://www.youtube.com/watch?v= $itemTrailerId "
yt-dlp -o " $itemPath /Trailer-trailer " --write-sub --sub-lang $trailerLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass " https://www.youtube.com/watch?v= $itemTrailerId "
fi
fi
fi
fi
fi
if [ -f " $itemPath / $trailerFileName .mkv " ] ; then
chmod 666 " $itemPath / $trailerFileName .mkv "
chown abc:abc " $itemPath / $trailerFileName .mkv "
fi
fi
if [ " $trailerSingle " = = "true" ] ; then
if [ ! -f " $itemPath / $trailerFileName .mkv " ] ; then
if [ ! -f " $itemPath /Trailer-trailer.mkv " ] ; then
log " $itemTitle :: ERROR :: No Trailer ID Found, Skipping... "
log " $itemTitle :: ERROR :: No Trailer ID Found, Skipping... "
else
log " $itemTitle :: Trailer already downloaded... "
fi
fi
exit
exit
fi
fi
@ -108,7 +123,6 @@ log "$itemTitle :: $tmdbVideosListDataIdsCount Extras Found!"
i = 0
i = 0
for id in $( echo " $tmdbVideosListDataIds " ) ; do
for id in $( echo " $tmdbVideosListDataIds " ) ; do
i = $(( i + 1 ))
i = $(( i + 1 ))
log " $itemTitle :: $i of $tmdbVideosListDataIdsCount :: Processing... "
tmdbExtraData = " $( echo " $tmdbVideosListData " | jq -r " select(.id==\" $id \") " ) "
tmdbExtraData = " $( echo " $tmdbVideosListData " | jq -r " select(.id==\" $id \") " ) "
tmdbExtraTitle = " $( echo " $tmdbExtraData " | jq -r .name) "
tmdbExtraTitle = " $( echo " $tmdbExtraData " | jq -r .name) "
tmdbExtraTitleClean = " $( echo " $tmdbExtraTitle " | sed -e " s/[^[:alpha:][:digit:] $^&_+=()'%;{},.@#]/ /g " -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g' ) "
tmdbExtraTitleClean = " $( echo " $tmdbExtraTitle " | sed -e " s/[^[:alpha:][:digit:] $^&_+=()'%;{},.@#]/ /g " -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g' ) "
@ -122,22 +136,48 @@ for id in $(echo "$tmdbVideosListDataIds"); do
fi
fi
if [ " $tmdbExtraType " = = "Featurette" ] ; then
if [ " $tmdbExtraType " = = "Featurette" ] ; then
fil eSuffi x= featurette
extraFolderName = " featurettes"
elif [ " $tmdbExtraType " = = "Trailer" ] ; then
elif [ " $tmdbExtraType " = = "Trailer" ] ; then
fileSuffix = trailer
extraFolderName = "trailers"
elif [ " $themoviedbvidetype " = = "Behind the Scenes" ] ; then
elif [ " $tmdbExtraType " = = "Behind the Scenes" ] ; then
fileSuffix = behindthescenes
extraFolderName = "behind the scenes"
elif [ " $themoviedbvidetype " = = "Clip" ] ; then
else
fileSuffix = clip
log " $itemTitle :: $i of $tmdbVideosListDataIdsCount :: ERROR :: $tmdbExtraType :: Extra Type Not found "
elif [ " $themoviedbvidetype " = = "Bloopers" ] ; then
if [ -f "/config/logs/MovieExtras-InvalidType.txt" ] ; then
fileSuffix = scene
if cat "/config/logs/MovieExtras-InvalidType.txt" | grep " $tmdbExtraType " | read; then
fi
continue
log " $itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle ( $tmdbExtraKey ) "
else
echo " $tmdbExtraType " >> "/config/logs/MovieExtras-InvalidType.txt"
fi
fi
echo " $tmdbExtraType " >> "/config/logs/MovieExtras-InvalidType.txt"
continue
fi
if [ ! -d " $itemPath / $extraFolderName " ] ; then
mkdir -p " $itemPath / $extraFolderName "
chmod 777 " $itemPath / $extraFolderName "
chown abc:abc " $itemPath / $extraFolderName "
fi
finalPath = " $itemPath / $extraFolderName "
if [ -f " $finalPath / $tmdbExtraTitleClean .mkv " ] ; then
log " $itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle ( $tmdbExtraKey ) :: Already Downloaded, skipping... "
continue
fi
log " $itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: $tmdbExtraTitle ( $tmdbExtraKey ) :: Downloading... "
if [ ! -z " $cookiesFile " ] ; then
if [ ! -z " $cookiesFile " ] ; then
yt-dlp --cookies " $cookiesFile " -o " $itemPath / $tmdbExtraTitleClean - $fileSuffix " --write-sub --sub-lang $trailerLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass " https://www.youtube.com/watch?v= $tmdbExtraKey "
yt-dlp --cookies " $cookiesFile " -o " $ finalPath/ $tmdbExtraTitleClean " --write-sub --sub-lang $trailerLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass " https://www.youtube.com/watch?v= $tmdbExtraKey " & >/dev/null
else
else
yt-dlp -o " $itemPath / $tmdbExtraTitleClean - $fileSuffix " --write-sub --sub-lang $trailerLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass " https://www.youtube.com/watch?v= $tmdbExtraKey "
yt-dlp -o " $itemPath / $tmdbExtraTitleClean " --write-sub --sub-lang $trailerLanguages --embed-subs --merge-output-format mkv --no-mtime --geo-bypass " https://www.youtube.com/watch?v= $tmdbExtraKey " & >/dev/null
fi
fi
break
if [ -f " $finalPath / $tmdbExtraTitleClean .mkv " ] ; then
chmod 666 " $finalPath / $tmdbExtraTitleClean .mkv "
chown abc:abc " $finalPath / $tmdbExtraTitleClean .mkv "
fi
done
done
exit
exit