+ proxying stub

This commit is contained in:
Dominika Liberda 2021-06-20 21:14:13 +00:00
parent b4d7f4e268
commit 48d5ef22a7
2 changed files with 22 additions and 16 deletions

View file

@ -9,3 +9,6 @@ if [[ "${r[url]}" == "/proxy"* ]]; then
cfg[proxy_url]='http(s|)://[a-z0-9-]*\.googlevideo\.com/.*' cfg[proxy_url]='http(s|)://[a-z0-9-]*\.googlevideo\.com/.*'
cfg[proxy_param]='url' cfg[proxy_param]='url'
fi fi
cfg[regionlock_proxy]=false
cfg[regionlock_proxy_url]='http://.../'

View file

@ -48,29 +48,32 @@ if [[ "${get_data[v]}" ]]; then
source templates/head.sh source templates/head.sh
fi fi
else else
cd temp
video=$(haruhi-dl --ie-key Youtube --write-pages --cookies "${cfg[_cookies]}" -J "http://youtube.com/watch?v=${get_data[v]}") video=$(haruhi-dl --ie-key Youtube --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
random_hash=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1) random_hash=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1)
video=$(haruhi-dl --ie-key Youtube --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}" &> output$random_hash.log) video=$(haruhi-dl --ie-key Youtube --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}" 2> temp/output$random_hash.log)
if [[ $video == '' ]]; then # seriously WHO DID THIS if [[ $video == '' ]]; then # seriously WHO DID THIS
output=$(cat output$random_hash.log) if [[ "${cfg[regionlock_proxy]}" == true ]]; then
rm output$random_hash.log # retrying w/ proxy!
cd .. video=$(haruhi-dl --ie-key Youtube --write-pages --cookies ${cfg[_cookies]} --proxy "${cfg[regionlock_proxy_url]}" -J "http://youtube.com/watch?v=${get_data[v]}" 2> output$random_hash.log)
if [[ $output == 'ERROR: Video unavailable' ]]; then fi
strings[error]='Video unavailable' output=$(cat temp/output$random_hash.log)
elif [[ $output == *'ERROR: Incomplete YouTube ID'* ]]; then rm temp/output$random_hash.log
strings[error]='Incomplete YouTube ID' if [[ $video == '' ]]; then
else if [[ $output == 'ERROR: Video unavailable' ]]; then
strings[error]='Unexpected error has occured' 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
source templates/head.sh
source "${cfg[namespace]}/templates/header.shs"
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/watch_error.t"
return
fi fi
fi fi
cd ..
#echo "http://youtube.com/watch?v=${get_data[v]}" > /dev/stderr #echo "http://youtube.com/watch?v=${get_data[v]}" > /dev/stderr
strings[channel_id]=$(jq -r '.channel_url' <<< "$video" | sed -s 's/http:\/\/www.youtube.com\/channel\///') strings[channel_id]=$(jq -r '.channel_url' <<< "$video" | sed -s 's/http:\/\/www.youtube.com\/channel\///')
strings[uploader]=$(jq -r '.uploader' <<< "$video") strings[uploader]=$(jq -r '.uploader' <<< "$video")