temporarily remove the easter egg to unclutter the code
This commit is contained in:
parent
fe0fb5e42a
commit
c491f1ec60
|
@ -7,103 +7,67 @@ fi
|
||||||
|
|
||||||
declare -A strings
|
declare -A strings
|
||||||
|
|
||||||
#if [[ ! "$(which haruhi-dl)" ]]; then
|
|
||||||
# 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
|
if [[ "${get_data[v]}" ]]; then
|
||||||
if [[ "${get_data[v]}" == '18l' || "${get_data[v]}" == '5eFdt6Y_34E' ]]; then
|
cd temp
|
||||||
strings[uploader]='MyMusicGroup'
|
video=$(yt-dlp --all-subs --write-pages --cookies "${cfg[_cookies]}" -J "http://youtube.com/watch?v=${get_data[v]}")
|
||||||
strings[title]='█▬█ █ ▀█▀ Jeden Osiem L - Jak Zapomnieć (Oficjalny Teledysk)'
|
if [[ $video == '' ]]; then # okay who did this
|
||||||
formats='[{
|
random_hash=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1)
|
||||||
"format_id": "44",
|
video=$(yt-dlp --all-subs --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}" 2> output$random_hash.log)
|
||||||
"url": "https://sakamoto.pl/tmp/videoplayback_.webm",
|
if [[ $video == '' ]]; then # seriously WHO DID THIS
|
||||||
"asr": 44100,
|
if [[ "${cfg[regionlock_proxy]}" == true ]]; then
|
||||||
"format_note": "480p",
|
# retrying w/ proxy!
|
||||||
"fps": 25,
|
video=$(yt-dlp --all-subs --write-pages --cookies ${cfg[_cookies]} --proxy "${cfg[regionlock_proxy_url]}" -J "http://youtube.com/watch?v=${get_data[v]}" 2> output$random_hash.log)
|
||||||
"height": 480,
|
fi
|
||||||
"tbr": 867,
|
output=$(cat output$random_hash.log)
|
||||||
"width": 640,
|
rm output$random_hash.log
|
||||||
"ext": "webm",
|
if [[ $video == '' ]]; then
|
||||||
"vcodec": "vp8",
|
if [[ $output == 'ERROR: Video unavailable' ]]; then
|
||||||
"acodec": "vorbis"
|
strings[error]='Video unavailable'
|
||||||
}]'
|
elif [[ $output == *'ERROR: Incomplete YouTube ID'* ]]; then
|
||||||
subs='[]'
|
strings[error]='Incomplete YouTube ID'
|
||||||
if [[ "${r[host]}" == "${cfg[flash_host]}" ]]; then
|
else
|
||||||
url='http://f.sakamoto.pl/videoplayback_.flv'
|
strings[error]='Unexpected error has occured'
|
||||||
fi
|
|
||||||
if [[ ${cfg[template]} != 'retro' ]]; then
|
|
||||||
meta[title]="${strings[title]}"
|
|
||||||
#source templates/head.sh
|
|
||||||
source "${cfg[namespace]}/templates/header.shs"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
cd temp
|
|
||||||
video=$(yt-dlp --all-subs --write-pages --cookies "${cfg[_cookies]}" -J "http://youtube.com/watch?v=${get_data[v]}")
|
|
||||||
if [[ $video == '' ]]; then # okay who did this
|
|
||||||
random_hash=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1)
|
|
||||||
video=$(yt-dlp --all-subs --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}" 2> output$random_hash.log)
|
|
||||||
if [[ $video == '' ]]; then # seriously WHO DID THIS
|
|
||||||
if [[ "${cfg[regionlock_proxy]}" == true ]]; then
|
|
||||||
# retrying w/ proxy!
|
|
||||||
video=$(yt-dlp --all-subs --write-pages --cookies ${cfg[_cookies]} --proxy "${cfg[regionlock_proxy_url]}" -J "http://youtube.com/watch?v=${get_data[v]}" 2> output$random_hash.log)
|
|
||||||
fi
|
fi
|
||||||
output=$(cat output$random_hash.log)
|
cd ..
|
||||||
rm output$random_hash.log
|
source "${cfg[namespace]}/templates/header.shs"
|
||||||
if [[ $video == '' ]]; then
|
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/watch_error.html"
|
||||||
if [[ $output == 'ERROR: Video unavailable' ]]; then
|
return
|
||||||
strings[error]='Video unavailable'
|
fi
|
||||||
elif [[ $output == *'ERROR: Incomplete YouTube ID'* ]]; then
|
fi
|
||||||
strings[error]='Incomplete YouTube ID'
|
|
||||||
else
|
|
||||||
strings[error]='Unexpected error has occured'
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
source "${cfg[namespace]}/templates/header.shs"
|
|
||||||
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/watch_error.html"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
strings[channel_id]=$(jq -r '.channel_url' <<< "$video" | sed -s 's/.*\/channel\///')
|
|
||||||
strings[uploader]=$(jq -r '.uploader' <<< "$video")
|
|
||||||
strings[title]=$(jq -r '.title' <<< "$video")
|
|
||||||
if [[ ${cfg[template]} != 'retro' ]]; then
|
|
||||||
meta[title]="${strings[title]}"
|
|
||||||
meta[description]="$(jq -r '.description' <<< "$video")"
|
|
||||||
meta[unsafe]="
|
|
||||||
<meta property='og:image' content='https://i.ytimg.com/vi/$(html_encode "${get_data[v]}")/hqdefault.jpg'>
|
|
||||||
<meta property='og:type' content='video.other'>
|
|
||||||
<meta property='video:duration' content='$(jq -r '.duration' <<< "$video")'>
|
|
||||||
"'<script type="application/ld+json">'"$(jq -c '{
|
|
||||||
"@context": "https://schema.org",
|
|
||||||
"@type": "VideoObject",
|
|
||||||
"name": .title,
|
|
||||||
"alternateName": .alt_title,
|
|
||||||
"description": .description,
|
|
||||||
"thumbnail": .thumbnails[-1].url,
|
|
||||||
"duration": ("PT" + (.duration | tostring) + "S"),
|
|
||||||
}' <<< "$video" | sed 's/</\</g;s/>/\>/g;')"'</script>'
|
|
||||||
#source templates/head.sh
|
|
||||||
source "${cfg[namespace]}/templates/header.shs"
|
|
||||||
fi
|
|
||||||
formats=$(jq -c '[.formats[] | {"format_id":.format_id,"url":.url,"ext":.ext,"width":.width,"height":.height,"format_note":.format_note,"acodec":.acodec,"vcodec":.vcodec,"abr":.abr,"fps":.fps}]' <<< "$video")
|
|
||||||
|
|
||||||
sub_array=()
|
|
||||||
|
|
||||||
for i in $(jq -r '.subtitles | keys[]' <<< "$video"); do
|
|
||||||
sub_array+=("$(jq '.subtitles.'"$i"'[] | select(.ext == "vtt").url | {"url": ., "lang":"'"$i"'"}' <<< "$video")")
|
|
||||||
done
|
|
||||||
|
|
||||||
subs=$(jq -s '.' <<< "${sub_array[@]}")
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
cd ..
|
||||||
|
strings[channel_id]=$(jq -r '.channel_url' <<< "$video" | sed -s 's/.*\/channel\///')
|
||||||
|
strings[uploader]=$(jq -r '.uploader' <<< "$video")
|
||||||
|
strings[title]=$(jq -r '.title' <<< "$video")
|
||||||
|
if [[ ${cfg[template]} != 'retro' ]]; then
|
||||||
|
meta[title]="${strings[title]}"
|
||||||
|
meta[description]="$(jq -r '.description' <<< "$video")"
|
||||||
|
meta[unsafe]="
|
||||||
|
<meta property='og:image' content='https://i.ytimg.com/vi/$(html_encode "${get_data[v]}")/hqdefault.jpg'>
|
||||||
|
<meta property='og:type' content='video.other'>
|
||||||
|
<meta property='video:duration' content='$(jq -r '.duration' <<< "$video")'>
|
||||||
|
"'<script type="application/ld+json">'"$(jq -c '{
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "VideoObject",
|
||||||
|
"name": .title,
|
||||||
|
"alternateName": .alt_title,
|
||||||
|
"description": .description,
|
||||||
|
"thumbnail": .thumbnails[-1].url,
|
||||||
|
"duration": ("PT" + (.duration | tostring) + "S"),
|
||||||
|
}' <<< "$video" | sed 's/</\</g;s/>/\>/g;')"'</script>'
|
||||||
|
#source templates/head.sh
|
||||||
|
source "${cfg[namespace]}/templates/header.shs"
|
||||||
|
fi
|
||||||
|
formats=$(jq -c '[.formats[] | {"format_id":.format_id,"url":.url,"ext":.ext,"width":.width,"height":.height,"format_note":.format_note,"acodec":.acodec,"vcodec":.vcodec,"abr":.abr,"fps":.fps}]' <<< "$video")
|
||||||
|
|
||||||
|
sub_array=()
|
||||||
|
|
||||||
|
for i in $(jq -r '.subtitles | keys[]' <<< "$video"); do
|
||||||
|
sub_array+=("$(jq '.subtitles.'"$i"'[] | select(.ext == "vtt").url | {"url": ., "lang":"'"$i"'"}' <<< "$video")")
|
||||||
|
done
|
||||||
|
|
||||||
|
subs=$(jq -s '.' <<< "${sub_array[@]}")
|
||||||
|
|
||||||
if [[ "${r[host]}" == "${cfg[flash_host]}" ]]; then
|
if [[ "${r[host]}" == "${cfg[flash_host]}" ]]; then
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
urls=($(jq -r '.formats[] | select(.format_id == "22" or .format_id == "18").url' <<< "$video"))
|
urls=($(jq -r '.formats[] | select(.format_id == "22" or .format_id == "18").url' <<< "$video"))
|
||||||
|
@ -169,8 +133,6 @@ if [[ "${get_data[v]}" ]]; then
|
||||||
vid="$(cat "temp/${written_id}_https_-_"*"watch"*".dump")"
|
vid="$(cat "temp/${written_id}_https_-_"*"watch"*".dump")"
|
||||||
vid_json="$(tr -d '\n' <<< "$vid" | grep -Poh "ytInitialData.*?</script>" | sed 's/ytInitialData = //;s/<\/script>//')"
|
vid_json="$(tr -d '\n' <<< "$vid" | grep -Poh "ytInitialData.*?</script>" | sed 's/ytInitialData = //;s/<\/script>//')"
|
||||||
|
|
||||||
#strings[recommended]=$()
|
|
||||||
|
|
||||||
_jq_to_array '.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results[] | .compactAutoplayRenderer.contents[0].compactVideoRenderer, .compactVideoRenderer |
|
_jq_to_array '.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results[] | .compactAutoplayRenderer.contents[0].compactVideoRenderer, .compactVideoRenderer |
|
||||||
if .videoId != null then
|
if .videoId != null then
|
||||||
[.videoId,
|
[.videoId,
|
||||||
|
|
Loading…
Reference in a new issue