Scan folders and prompt user to select folder.
This commit is contained in:
parent
0782bf23c4
commit
e1cff7a8c7
@ -12,18 +12,33 @@ urlencode() {
|
|||||||
char="${string:i:1}"
|
char="${string:i:1}"
|
||||||
case "$char" in
|
case "$char" in
|
||||||
[a-zA-Z0-9.~_-]) encoded+="$char" ;;
|
[a-zA-Z0-9.~_-]) encoded+="$char" ;;
|
||||||
|
" ") encoded+="%20" ;;
|
||||||
*) encoded+=$(printf '%%%02X' "'$char") ;;
|
*) encoded+=$(printf '%%%02X' "'$char") ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
echo "$encoded"
|
echo "$encoded"
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Enter Movie Title:"
|
counter=1
|
||||||
|
folders=()
|
||||||
|
for dir in ../*/; do
|
||||||
|
folder_name="${dir#../}"
|
||||||
|
folder_name="${folder_name%/}"
|
||||||
|
echo "$counter. $folder_name"
|
||||||
|
folders+=("$folder_name")
|
||||||
|
counter=$((counter + 1))
|
||||||
|
done
|
||||||
|
|
||||||
read -r title
|
read -p "Please select a folder by entering the corresponding number: " selection
|
||||||
|
|
||||||
|
#Assuming folder name is name of movie
|
||||||
|
title="${folders[$((selection - 1))]}"
|
||||||
|
folder_path="../$title/"
|
||||||
|
echo "You selected: $title"
|
||||||
|
|
||||||
# URL encode the movie title
|
# URL encode the movie title
|
||||||
encoded_title=$(urlencode "$title")
|
encoded_title=$(echo "$title" | sed -E 's/ \([0-9]{4}\)$//')
|
||||||
|
encoded_title=$(urlencode "$encoded_title")
|
||||||
|
|
||||||
# mkdir "../$title/temp"
|
# mkdir "../$title/temp"
|
||||||
|
|
||||||
@ -33,6 +48,7 @@ json_results=$(curl -s --request GET \
|
|||||||
--header "Authorization: Bearer $themoviedb_token" \
|
--header "Authorization: Bearer $themoviedb_token" \
|
||||||
--header 'accept: application/json' | ./jq)
|
--header 'accept: application/json' | ./jq)
|
||||||
|
|
||||||
|
# Show first results and have user select right result
|
||||||
echo "Select the correct movie title:"
|
echo "Select the correct movie title:"
|
||||||
echo "$json_results" | ./jq -r '.results[:3] | to_entries[] | "\(.key + 1). \(.value.title) (\(.value.release_date))"'
|
echo "$json_results" | ./jq -r '.results[:3] | to_entries[] | "\(.key + 1). \(.value.title) (\(.value.release_date))"'
|
||||||
read -r -p "Selection: " selection
|
read -r -p "Selection: " selection
|
||||||
@ -43,11 +59,12 @@ selected_movie=$(echo "$json_results" | ./jq -r ".results[$((selection - 1))]")
|
|||||||
full_title=$(echo "$selected_movie" | ./jq -r '. | "\(.original_title) (\(.release_date | split("-")[0]))"')
|
full_title=$(echo "$selected_movie" | ./jq -r '. | "\(.original_title) (\(.release_date | split("-")[0]))"')
|
||||||
poster_path="https://image.tmdb.org/t/p/original$(echo "$selected_movie" | ./jq -r '.poster_path')"
|
poster_path="https://image.tmdb.org/t/p/original$(echo "$selected_movie" | ./jq -r '.poster_path')"
|
||||||
|
|
||||||
echo "$full_title"
|
|
||||||
|
|
||||||
|
|
||||||
echo "Downloading Poster..."
|
echo "Downloading Poster..."
|
||||||
curl -s -o "./poster.${poster_path##*.}" "$poster_path"
|
curl -s -o "$folder_path/poster.${poster_path##*.}" "$poster_path"
|
||||||
|
|
||||||
|
echo "Updating folder name to \"$full_title\""
|
||||||
|
mv "$folder_path" "../$full_title"
|
||||||
|
|
||||||
|
|
||||||
# HandBrakeCLI -i "../$title/$title - 4k DV.mkv" -o "../$title/temp/handbrake.mkv" -f av_mkv -m -e x265_10bit --encoder-preset slower -q 20 --encoder-profile auto --all-audio -E copy --audio-copy-mask aac,eac3,dts,ac3,truehd,dtshd,mp3 --crop-mode auto --auto-anamorphic --all-subtitles
|
# HandBrakeCLI -i "../$title/$title - 4k DV.mkv" -o "../$title/temp/handbrake.mkv" -f av_mkv -m -e x265_10bit --encoder-preset slower -q 20 --encoder-profile auto --all-audio -E copy --audio-copy-mask aac,eac3,dts,ac3,truehd,dtshd,mp3 --crop-mode auto --auto-anamorphic --all-subtitles
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user