1.0.018 - For Kodi Compatibility Use "filename-trailer"

#41 #39 

Untested, should work.... 

This will remove exiting movie-trailer.mkv and replace it with the same file but has a matching file name. If you rename your files frequently, you'll most likely end up with dupes....
pull/49/head
RandomNinjaAtk 2 years ago committed by GitHub
parent f7b98bd585
commit 3901da2a82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
scriptVersion="1.0.017" scriptVersion="1.0.018"
arrEventType="$radarr_eventtype" arrEventType="$radarr_eventtype"
arrItemId=$radarr_movie_id arrItemId=$radarr_movie_id
tmdbApiKey="3b7751e3179f796565d88fdb2fcdf426" tmdbApiKey="3b7751e3179f796565d88fdb2fcdf426"
@ -78,12 +78,15 @@ 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")"
itemFileName=$(curl -s "$arrUrl/api/v3/moviefile?movieId=$arrItemId&apikey=$arrApiKey" | jq -r .[].relativePath)
itemFileNameNoExt="${itemFileName%.*}"
itemFolder="$(basename "$itemPath")" itemFolder="$(basename "$itemPath")"
itemRelativePath="$(echo "$arrItemData" | jq -r ".movieFile.relativePath")" 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
@ -157,10 +160,10 @@ do
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: Single Trailer Enabled..." log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: Single Trailer Enabled..."
if [ "$extrasKodiCompatibility" == "true" ] ; then if [ "$extrasKodiCompatibility" == "true" ] ; then
finalPath="$itemPath" finalPath="$itemPath"
finalFileName="movie-trailer" finalFileName="$itemFileNameNoExt-trailer"
else else
finalPath="$itemPath/$extraFolderName" finalPath="$itemPath/$extraFolderName"
finalFileName="$itemFolder" finalFileName="$tmdbExtraTitleClean"
fi fi
else else
finalPath="$itemPath/$extraFolderName" finalPath="$itemPath/$extraFolderName"
@ -180,6 +183,11 @@ do
break break
fi fi
continue continue
elif [ -f "$finalPath/movie-trailer.mkv" ]; then
if [ "$extrasKodiCompatibility" == "true" ] ; then
log "$itemTitle :: $i of $tmdbVideosListDataIdsCount :: $tmdbExtraType :: Removing old \"movie-trailer.mkv\" to replace with Kodi naming..."
rm "$finalPath/movie-trailer.mkv"
fi
fi fi
videoLanguages="$(echo "$extrasLanguages" | sed "s/-[[:alpha:]][[:alpha:]]//g")" videoLanguages="$(echo "$extrasLanguages" | sed "s/-[[:alpha:]][[:alpha:]]//g")"

Loading…
Cancel
Save