2.4 - bug fix

This commit is contained in:
RandomNinjaAtk 2023-07-15 11:04:42 -04:00 committed by GitHub
parent 066f3452be
commit 11731efc91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,5 @@
#!/usr/bin/with-contenv bash #!/usr/bin/with-contenv bash
scriptVersion="2.3" scriptVersion="2.4"
scriptName="Video" scriptName="Video"
log () { log () {
@ -82,31 +82,32 @@ verifyApiAccess () {
done done
} }
if [ "$dlClientSource" = "tidal" ] || [ "$dlClientSource" = "both" ]; then
sourcePreference=tidal
fi
log "-----------------------------------------------------------------------------"
log "|~) _ ._ _| _ ._ _ |\ |o._ o _ |~|_|_|"
log "|~\(_|| |(_|(_)| | || \||| |_|(_||~| | |<"
log " Presents: $scriptName ($scriptVersion)"
log " May the beats be with you!"
log "-----------------------------------------------------------------------------"
log "Donate: https://github.com/sponsors/RandomNinjaAtk"
log "Project: https://github.com/RandomNinjaAtk/arr-scripts"
log "Support: https://github.com/RandomNinjaAtk/arr-scripts/discussions"
log "-----------------------------------------------------------------------------"
sleep 5
log ""
log "Lift off in..."; sleep 0.5
log "5"; sleep 1
log "4"; sleep 1
log "3"; sleep 1
log "2"; sleep 1
log "1"; sleep 1
Configuration () { Configuration () {
if [ "$dlClientSource" = "tidal" ] || [ "$dlClientSource" = "both" ]; then
sourcePreference=tidal
fi
log "-----------------------------------------------------------------------------"
log "|~) _ ._ _| _ ._ _ |\ |o._ o _ |~|_|_|"
log "|~\(_|| |(_|(_)| | || \||| |_|(_||~| | |<"
log " Presents: $scriptName ($scriptVersion)"
log " May the beats be with you!"
log "-----------------------------------------------------------------------------"
log "Donate: https://github.com/sponsors/RandomNinjaAtk"
log "Project: https://github.com/RandomNinjaAtk/arr-scripts"
log "Support: https://github.com/RandomNinjaAtk/arr-scripts/discussions"
log "-----------------------------------------------------------------------------"
sleep 5
log ""
log "Lift off in..."; sleep 0.5
log "5"; sleep 1
log "4"; sleep 1
log "3"; sleep 1
log "2"; sleep 1
log "1"; sleep 1
processdownloadid="$(ps -A -o pid,cmd|grep "Video.sh" | grep -v grep | head -n 1 | awk '{print $1}')" processdownloadid="$(ps -A -o pid,cmd|grep "Video.sh" | grep -v grep | head -n 1 | awk '{print $1}')"
log "To kill script, use the following command:" log "To kill script, use the following command:"
log "kill -9 $processdownloadid" log "kill -9 $processdownloadid"
@ -114,8 +115,8 @@ Configuration () {
verifyApiAccess verifyApiAccess
downloadPath="$downloadPath/videos" videoDownloadPath="$downloadPath/videos"
log "CONFIG :: Download Location :: $downloadPath" log "CONFIG :: Download Location :: $videoDownloadPath"
log "CONFIG :: Music Video Location :: $videoPath" log "CONFIG :: Music Video Location :: $videoPath"
log "CONFIG :: Subtitle Language set to: $youtubeSubtitleLanguage" log "CONFIG :: Subtitle Language set to: $youtubeSubtitleLanguage"
log "CONFIG :: Video container set to format: $videoContainer" log "CONFIG :: Video container set to format: $videoContainer"
@ -226,36 +227,36 @@ ImvdbCache () {
DownloadVideo () { DownloadVideo () {
if [ -d "$downloadPath/incomplete" ]; then if [ -d "$videoDownloadPath/incomplete" ]; then
rm -rf "$downloadPath/incomplete" rm -rf "$videoDownloadPath/incomplete"
fi fi
if [ ! -d "$downloadPath/incomplete" ]; then if [ ! -d "$videoDownloadPath/incomplete" ]; then
mkdir -p "$downloadPath/incomplete" mkdir -p "$videoDownloadPath/incomplete"
chmod 777 "$downloadPath/incomplete" chmod 777 "$videoDownloadPath/incomplete"
fi fi
if echo "$1" | grep -i "youtube" | read; then if echo "$1" | grep -i "youtube" | read; then
if [ $videoContainer = mkv ]; then if [ $videoContainer = mkv ]; then
if [ ! -z "$cookiesFile" ]; then if [ ! -z "$cookiesFile" ]; then
yt-dlp -f "$videoFormat" --no-video-multistreams --cookies "$cookiesFile" -o "$downloadPath/incomplete/${2}${3}" --embed-subs --sub-lang $youtubeSubtitleLanguage --merge-output-format mkv --remux-video mkv --no-mtime --geo-bypass "$1" yt-dlp -f "$videoFormat" --no-video-multistreams --cookies "$cookiesFile" -o "$videoDownloadPath/incomplete/${2}${3}" --embed-subs --sub-lang $youtubeSubtitleLanguage --merge-output-format mkv --remux-video mkv --no-mtime --geo-bypass "$1"
else else
yt-dlp -f "$videoFormat" --no-video-multistreams -o "$downloadPath/incomplete/${2}${3}" --embed-subs --sub-lang $youtubeSubtitleLanguage --merge-output-format mkv --remux-video mkv --no-mtime --geo-bypass "$1" yt-dlp -f "$videoFormat" --no-video-multistreams -o "$videoDownloadPath/incomplete/${2}${3}" --embed-subs --sub-lang $youtubeSubtitleLanguage --merge-output-format mkv --remux-video mkv --no-mtime --geo-bypass "$1"
fi fi
if [ -f "$downloadPath/incomplete/${2}${3}.mkv" ]; then if [ -f "$videoDownloadPath/incomplete/${2}${3}.mkv" ]; then
chmod 666 "$downloadPath/incomplete/${2}${3}.mkv" chmod 666 "$videoDownloadPath/incomplete/${2}${3}.mkv"
downloadFailed=false downloadFailed=false
else else
downloadFailed=true downloadFailed=true
fi fi
else else
if [ ! -z "$cookiesFile" ]; then if [ ! -z "$cookiesFile" ]; then
yt-dlp --format-sort ext:mp4:m4a --merge-output-format mp4 --no-video-multistreams --cookies "$cookiesFile" -o "$downloadPath/incomplete/${2}${3}" --embed-subs --sub-lang $youtubeSubtitleLanguage --no-mtime --geo-bypass "$1" yt-dlp --format-sort ext:mp4:m4a --merge-output-format mp4 --no-video-multistreams --cookies "$cookiesFile" -o "$videoDownloadPath/incomplete/${2}${3}" --embed-subs --sub-lang $youtubeSubtitleLanguage --no-mtime --geo-bypass "$1"
else else
yt-dlp --format-sort ext:mp4:m4a --merge-output-format mp4 --no-video-multistreams -o "$downloadPath/incomplete/${2}${3}" --embed-subs --sub-lang $youtubeSubtitleLanguage --no-mtime --geo-bypass "$1" yt-dlp --format-sort ext:mp4:m4a --merge-output-format mp4 --no-video-multistreams -o "$videoDownloadPath/incomplete/${2}${3}" --embed-subs --sub-lang $youtubeSubtitleLanguage --no-mtime --geo-bypass "$1"
fi fi
if [ -f "$downloadPath/incomplete/${2}${3}.mp4" ]; then if [ -f "$videoDownloadPath/incomplete/${2}${3}.mp4" ]; then
chmod 666 "$downloadPath/incomplete/${2}${3}.mp4" chmod 666 "$videoDownloadPath/incomplete/${2}${3}.mp4"
downloadFailed=false downloadFailed=false
else else
downloadFailed=true downloadFailed=true
@ -267,19 +268,19 @@ DownloadVideo () {
TidalClientTest TidalClientTest
sleep 1 sleep 1
TidaldlStatusCheck TidaldlStatusCheck
tidal-dl -o "$downloadPath/incomplete" -l "$1" tidal-dl -o "$videoDownloadPath/incomplete" -l "$1"
find "$downloadPath/incomplete" -type f -exec mv "{}" "$downloadPath/incomplete"/ \; find "$videoDownloadPath/incomplete" -type f -exec mv "{}" "$videoDownloadPath/incomplete"/ \;
find "$downloadPath/incomplete" -mindepth 1 -type d -exec rm -rf "{}" \; &>/dev/null find "$videoDownloadPath/incomplete" -mindepth 1 -type d -exec rm -rf "{}" \; &>/dev/null
find "$downloadPath/incomplete" -type f -regex ".*/.*\.\(mkv\|mp4\)" -print0 | while IFS= read -r -d '' video; do find "$videoDownloadPath/incomplete" -type f -regex ".*/.*\.\(mkv\|mp4\)" -print0 | while IFS= read -r -d '' video; do
file="${video}" file="${video}"
filenoext="${file%.*}" filenoext="${file%.*}"
filename="$(basename "$video")" filename="$(basename "$video")"
extension="${filename##*.}" extension="${filename##*.}"
filenamenoext="${filename%.*}" filenamenoext="${filename%.*}"
mv "$file" "$downloadPath/incomplete/${2}${3}.mp4" mv "$file" "$videoDownloadPath/incomplete/${2}${3}.mp4"
done done
if [ -f "$downloadPath/incomplete/${2}${3}.mp4" ]; then if [ -f "$videoDownloadPath/incomplete/${2}${3}.mp4" ]; then
chmod 666 "$downloadPath/incomplete/${2}${3}.mp4" chmod 666 "$videoDownloadPath/incomplete/${2}${3}.mp4"
downloadFailed=false downloadFailed=false
else else
downloadFailed=true downloadFailed=true
@ -290,13 +291,13 @@ DownloadVideo () {
DownloadThumb () { DownloadThumb () {
curl -s "$1" -o "$downloadPath/incomplete/${2}${3}.jpg" curl -s "$1" -o "$videoDownloadPath/incomplete/${2}${3}.jpg"
chmod 666 "$downloadPath/incomplete/${2}${3}.jpg" chmod 666 "$videoDownloadPath/incomplete/${2}${3}.jpg"
} }
VideoProcessWithSMA () { VideoProcessWithSMA () {
find "$downloadPath/incomplete" -type f -regex ".*/.*\.\(mkv\|mp4\)" -print0 | while IFS= read -r -d '' video; do find "$videoDownloadPath/incomplete" -type f -regex ".*/.*\.\(mkv\|mp4\)" -print0 | while IFS= read -r -d '' video; do
count=$(($count+1)) count=$(($count+1))
file="${video}" file="${video}"
filenoext="${file%.*}" filenoext="${file%.*}"
@ -332,7 +333,7 @@ VideoProcessWithSMA () {
} }
VideoTagProcess () { VideoTagProcess () {
find "$downloadPath/incomplete" -type f -regex ".*/.*\.\(mkv\|mp4\)" -print0 | while IFS= read -r -d '' video; do find "$videoDownloadPath/incomplete" -type f -regex ".*/.*\.\(mkv\|mp4\)" -print0 | while IFS= read -r -d '' video; do
count=$(($count+1)) count=$(($count+1))
file="${video}" file="${video}"
filenoext="${file%.*}" filenoext="${file%.*}"
@ -369,7 +370,7 @@ VideoTagProcess () {
-metadata ARTIST="$lidarrArtistName" \ -metadata ARTIST="$lidarrArtistName" \
-metadata ALBUMARTIST="$lidarrArtistName" \ -metadata ALBUMARTIST="$lidarrArtistName" \
-metadata ENCODED_BY="lidarr-extended" \ -metadata ENCODED_BY="lidarr-extended" \
-attach "$downloadPath/incomplete/${1}${2}.jpg" -metadata:s:t mimetype=image/jpeg \ -attach "$videoDownloadPath/incomplete/${1}${2}.jpg" -metadata:s:t mimetype=image/jpeg \
"$filenoext.$videoContainer" &>/dev/null "$filenoext.$videoContainer" &>/dev/null
rm "$filenoext-temp.$videoContainer" rm "$filenoext-temp.$videoContainer"
chmod 666 "$filenoext.$videoContainer" chmod 666 "$filenoext.$videoContainer"
@ -378,7 +379,7 @@ VideoTagProcess () {
log "$processCount of $lidarrArtistIdsCount :: $4 :: $lidarrArtistName :: ${1}${2} $3 :: Tagging file" log "$processCount of $lidarrArtistIdsCount :: $4 :: $lidarrArtistName :: ${1}${2} $3 :: Tagging file"
ffmpeg -y \ ffmpeg -y \
-i "$filenoext-temp.$videoContainer" \ -i "$filenoext-temp.$videoContainer" \
-i "$downloadPath/incomplete/${1}${2}.jpg" \ -i "$videoDownloadPath/incomplete/${1}${2}.jpg" \
-map 1 \ -map 1 \
-map 0 \ -map 0 \
-c copy \ -c copy \
@ -398,7 +399,7 @@ VideoTagProcess () {
VideoNfoWriter () { VideoNfoWriter () {
log "$processCount of $lidarrArtistIdsCount :: $7 :: $lidarrArtistName :: ${3} :: Writing NFO" log "$processCount of $lidarrArtistIdsCount :: $7 :: $lidarrArtistName :: ${3} :: Writing NFO"
nfo="$downloadPath/incomplete/${1}${2}.nfo" nfo="$videoDownloadPath/incomplete/${1}${2}.nfo"
if [ -f "$nfo" ]; then if [ -f "$nfo" ]; then
rm "$nfo" rm "$nfo"
fi fi
@ -703,7 +704,7 @@ VideoProcess () {
chmod 777 "$videoPath/$lidarrArtistFolderNoDisambig" chmod 777 "$videoPath/$lidarrArtistFolderNoDisambig"
fi fi
mv $downloadPath/incomplete/* "$videoPath/$lidarrArtistFolderNoDisambig"/ mv $videoDownloadPath/incomplete/* "$videoPath/$lidarrArtistFolderNoDisambig"/
done done
fi fi