+ watch.shs error handling
parent
102fdd69f4
commit
14a0adb761
|
@ -0,0 +1,2 @@
|
|||
<div><br>
|
||||
{{.error}}
|
|
@ -7,7 +7,11 @@ fi
|
|||
declare -A strings
|
||||
|
||||
if [[ ! $(which haruhi-dl) ]]; then
|
||||
echo "Could not load video"
|
||||
strings[error]='Could not load video'
|
||||
source templates/head.sh
|
||||
source "${cfg[namespace]}/templates/header.shs"
|
||||
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/watch_error.t"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "${get_data[v]}" ]]; then
|
||||
|
@ -26,8 +30,22 @@ if [[ "${get_data[v]}" ]]; then
|
|||
cd temp
|
||||
video=$(haruhi-dl --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}")
|
||||
if [[ $video == '' ]]; then # okay who did this
|
||||
video=$(haruhi-dl --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}")
|
||||
random_hash=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1)
|
||||
video=$(haruhi-dl --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}" &> output$random_hash.log)
|
||||
if [[ $video == '' ]]; then # seriously WHO DID THIS
|
||||
output=$(cat output$random_hash.log)
|
||||
rm output$random_hash.log
|
||||
cd ..
|
||||
if [[ $output == 'ERROR: Video unavailable' ]]; then
|
||||
strings[error]='Video unavailable'
|
||||
elif [[ $output == *'ERROR: Incomplete YouTube ID'* ]]; then
|
||||
strings[error]='Incomplete YouTube ID'
|
||||
else
|
||||
strings[error]='Unexpected error has occured'
|
||||
fi
|
||||
source templates/head.sh
|
||||
source "${cfg[namespace]}/templates/header.shs"
|
||||
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/watch_error.t"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue