+ watch.shs error handling
This commit is contained in:
parent
102fdd69f4
commit
14a0adb761
2
templates/themes/default/watch_error.t
Normal file
2
templates/themes/default/watch_error.t
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<div><br>
|
||||||
|
{{.error}}
|
|
@ -7,7 +7,11 @@ fi
|
||||||
declare -A strings
|
declare -A strings
|
||||||
|
|
||||||
if [[ ! $(which haruhi-dl) ]]; then
|
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
|
fi
|
||||||
|
|
||||||
if [[ "${get_data[v]}" ]]; then
|
if [[ "${get_data[v]}" ]]; then
|
||||||
|
@ -26,8 +30,22 @@ if [[ "${get_data[v]}" ]]; then
|
||||||
cd temp
|
cd temp
|
||||||
video=$(haruhi-dl --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}")
|
video=$(haruhi-dl --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}")
|
||||||
if [[ $video == '' ]]; then # okay who did this
|
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
|
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
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue