* change URL schema and other stuff

18l-fix
Dominika Liberda 2021-01-28 22:56:24 +01:00
parent 4be0069989
commit 3ebb0054ef
24 changed files with 88 additions and 82 deletions

7
templates/header.shs Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
if ! session_verify "${cookies[sh_session]}"; then
echo "<a href='/login.shs'</a>Log in</a> | <a href='/register.shs'>Register</a>"
else
echo "Logged in as ${cookies[username]} | <a href='/logout.shs'>Log out</a>"
fi

View File

@ -2,7 +2,7 @@
if session_verify ${cookies[sh_session]} && [[ ${get_data[v]} != '' ]]; then
title=$(haruhi-dl $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -e "https://youtube.com/watch?v=${get_data[v]}")
if [[ $(cat storage/faves | grep -F "$title" | grep "$(echo ${cookies[username]} | sed -E "s/\r//")") == '' ]]; then
if [[ $(grep -F "$title" storage/faves | grep "$(echo ${cookies[username]} | sed -E "s/\r//")") == '' ]]; then
echo "$(session_get_username ${cookies[sh_session]}):${get_data[v]}:$title" >> storage/faves
fi
fi
@ -12,7 +12,7 @@ source templates/head.sh
echo "<a href='./'>&lt;--- back to main</a><br><h1>Your favourites</h1>"
IFS=$'\n'
for i in $(tac storage/faves); do
for i in $(tac storage/faves | grep -P "^$(session_get_username ${cookies[sh_session]}):"); do
IFS=':'
array=($i)
if [[ ${array[1]} == '' ]]; then

25
webroot/feed.shs Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
source templates/head.sh
if session_verify "${cookies[sh_session]}"; then
while read i; do
IFS=':'
y=($i)
IFS=$'\n'
data=$(curl -s "https://www.youtube.com/feeds/videos.xml?channel_id=${y[1]}");
video_id+=($((grep "<link" | grep -Eoh "watch\?v\=[A-Za-z0-9_\-]+" | sed -s 's/watch?v=//') <<< "$data"))
video_title+=($((grep "<media:title>" | sed -E 's/[</ ]+media:title>//g') <<< "$data"))
video_date+=($((grep "<published>" | tail -n 15 | sed -E 's/[ </]+published>//g' | xargs -L1 date "+%s" -d) <<< "$data"))
video_uploader+=($((grep -Poh "name>.*?</" | sed -E 's/name>//;s/<\///' | head -n 1) <<< "$data"))
done <<< "$(cat storage/subscribed | grep -P "^$(session_get_username ${cookies[sh_session]}):")"
queue=$(for (( i=0; i<${#video_id[@]}; i++ )); do echo "$i ${video_date[i]}"; done | sort -k2r | awk '{print $1}')
while read i; do
echo "<a href='watch.shs?v=${video_id[$i]}'><img src='http://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a>$(date -d "@${video_date[$i]}" "+%H:%M, %d %h %Y")<br>"
done <<< "$queue"
else
echo "gtfo"
fi

View File

@ -1,5 +1,6 @@
#!/bin/bash
source templates/head.sh
source ${cfg[namespace]}/templates/header.shs
echo "<form action='${r[url]}/search.shs'>
<input name='q' type='text'>

35
webroot/search.shs Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
meta[title]="youtube but not really"
source templates/head.sh
echo "<form action='${r[url]}/search.shs'>
<input name='q' type='text'>
<input type='submit' value='Search'>
</form>
"
if [[ ${get_data[q]} ]]; then
query=${get_data[q]}
query_nice=$(echo ${get_data[q]} | sed -s 's/+/ /g')
echo "<p>Searching for '$query_nice'</p>"
data=$(haruhi-dl "ytsearch30:${get_data[q]}" --flat-playlist -J | jq '.entries[]')
IFS=$'\n'
id=($(jq -r '.id' <<< "$data"))
title=($(jq -r '.title' <<< "$data"))
runtime=($(jq -r '.duration' <<< "$data"))
views=($(jq -r '.view_count' <<< "$data"))
channel=($(jq -r '.channel' <<< "$data"))
channel_id=($(jq -r '.channel_id' <<< "$data"))
unset IFS
for (( i=0; i<${#id[@]}; i++ )); do
echo "<a href='/watch.shs?v=${id[$i]}'><img src='https://i.ytimg.com/vi/${id[$i]}/mqdefault.jpg'><br>${title[$i]}</a> | ${runtime[$i]} seconds | ${views[$i]} views<br>Uploaded by <a href='/channel.shs?id=${channel_id[$i]}'>${channel[$i]}</a><br>"
done
else
echo "search for something will 'ya?"
fi

View File

@ -2,7 +2,7 @@
if session_verify ${cookies[sh_session]} && [[ ${get_data[id]} != '' ]]; then
title=$(curl https://www.youtube.com/feeds/videos.xml?channel_id=${get_data[id]} | grep title | head -n 1 | sed -s 's/ <title>//;s/<\/title>//')
if [[ $(cat storage/subscribed | grep -PF ":$title$" | grep "$(echo ${cookies[username]} | sed -E "s/\r//")") == '' ]]; then
if [[ $((grep -PF ":$title$" | grep "$(echo ${cookies[username]} | sed -E "s/\r//")") <<< storage/subscribed) == '' ]]; then
echo "$(session_get_username ${cookies[sh_session]}):${get_data[id]}:$title" >> storage/subscribed
fi
fi
@ -12,11 +12,15 @@ source templates/head.sh
echo "<a href='./'>&lt;--- back to main</a><br><h1>Channels you subscribe to</h1>"
IFS=$'\n'
for i in $(tac storage/subscribed); do
for i in $(tac storage/subscribed | grep -P "^$(session_get_username ${cookies[sh_session]}):"); do
IFS=':'
array=($i)
if [[ ${array[1]} == '' ]]; then
break
fi
echo "<div><a href='channel.shs?id=${array[1]}'>${array[@]:2:999}</a><br></div>";
echo "<div><a href='channel.shs?id=${array[1]}'>${array[@]:2:9999}</a><br></div>";
done
unset IFS

View File

@ -1,11 +1,5 @@
#!/bin/bash
# fetching recommended disabled for speed
#for i in $(curl https://www.youtube.com/watch?v=${get_data[v]} | grep -ohE "watch\?v\=[A-zaz0-9]{11}" | uniq | cut -c 9-19); do
# echo "<div><img src='http://i.ytimg.com/vi/$i/hqdefault.jpg'><br><audio src='$(haruhi-dl -g -f 251 $i)' controls></audio></div>";
#done
if [[ ${get_data[v]} ]]; then
if [[ ${get_data[v]} == '18l' || ${get_data[v]} == '5eFdt6Y_34E' ]]; then
uploader='MyMusicGroup'
@ -42,7 +36,7 @@ if [[ ${get_data[v]} ]]; then
</form>
<div><br>"
source "${cfg[namespace]}/webroot/yt/player.shs"
source "${cfg[namespace]}/webroot/player.shs"
#<video id='player' src='$url' controls></video>
echo "<h2>$title</h2>
@ -54,12 +48,12 @@ if [[ ${get_data[v]} ]]; then
<b>$(echo $video | jq -r '.view_count')</b> views<br>
<b>$(echo $video | jq -r '.like_count')</b> likes, <b>$(echo $video | jq -r '.dislike_count')</b> dislikes.<br>"
if [[ ${cookies[sh_session]} ]]; then
if [[ $(cat storage/faves | grep $(echo -n ${cookies[username]} | sed -E 's/\r//g') | grep ${get_data[v]}) == '' ]]; then
if [[ $(grep $(session_get_username ${cookies[sh_session]}) storage/faves | grep ${get_data[v]}) == '' ]]; then
echo "<a href='fav.shs?v=$(echo ${get_data[v]} | sed -s 's/<//g;')' target='_blank'>Add to favourites</a><br>"
else
echo "<a href='unfav.shs?v=$(echo ${get_data[v]} | sed -s 's/<//g;')' target='_blank'>Remove from favourites</a><br>"
fi
if [[ $(cat storage/subscribed | grep $(echo -n ${cookies[username]} | sed -E 's/\r//g') | grep $channel_id) == '' ]]; then
if [[ $(grep $(session_get_username ${cookies[sh_session]}) storage/subscribed | grep $channel_id) == '' ]]; then
echo "<a href='subscribe.shs?id=$channel_id' target='_blank'>Subscribe to $uploader!</a><br>"
else
echo "<a href='unsubscribe.shs?id=$channel_id' target='_blank'>Unsubscribe from $uploader</a><br>"
@ -73,13 +67,19 @@ if [[ ${get_data[v]} ]]; then
<span><i>Description</i>:<br>$(echo "$video" | jq -r '.description' | sed -E 's/$/<br>/g')</span>
</div>";
vid="$(curl -s "https://www.youtube.com/watch?v=${get_data[v]}" -c cookiejar)"
echo "<h1>Recommended</h1>"
for i in $(echo "$vid" | grep -ohE "watch\?v\=[A-zaz0-9]{11}" | uniq | cut -c 9-19); do
echo "<div><img src='http://i.ytimg.com/vi/$i/hqdefault.jpg'><br></div>";
done
echo "<h1>Comments</h1>"
vid="$(curl -s "https://www.youtube.com/watch?v=${get_data[v]}" -c cookiejar)"
cont="$(echo "$vid" | grep -Poh 'continuation":".*?"' | sed -E 's/.*":"//g;s/"//g')"
CSRF="$(echo "$vid" | grep -Poh 'XSRF_TOKEN":".*?"' | sed -E 's/XSRF_TOKEN":"//g;s/"//g;s/\\u00/%/g')"
comments="$(curl 'https://www.youtube.com/comment_service_ajax?action_get_comments=1&pbj=1&ctoken='"$cont"'&continuation='"$cont" -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'X-YouTube-Client-Name: 1' -H 'X-YouTube-Client-Version: 2.20201105.01.01' --data-raw 'session_token='"$CSRF" -b cookiejar)"
comments="$(curl -s 'https://www.youtube.com/comment_service_ajax?action_get_comments=1&pbj=1&ctoken='"$cont"'&continuation='"$cont" -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'X-YouTube-Client-Name: 1' -H 'X-YouTube-Client-Version: 2.20201105.01.01' --data-raw 'session_token='"$CSRF" -b cookiejar)"
IFS=$'\n'
comment_nick=($(jq -r '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.authorText.simpleText' <<< "$comments"))

View File

@ -1,24 +0,0 @@
#!/bin/bash
source templates/head.sh
if session_verify ${cookies[sh_session]}; then
for i in $(cat storage/subscribed); do
IFS=':'
y=($i)
IFS=$'\n'
data=$(curl -s "https://www.youtube.com/feeds/videos.xml?channel_id=${y[1]}");
video_id+=($(echo "$data" | grep "<link" | grep -Eoh "watch\?v\=[A-Za-z0-9_\-]+" | sed -s 's/watch?v=//'))
video_title+=($(echo "$data" | grep "<media:title>" | sed -E 's/[</ ]+media:title>//g'))
video_date+=($(echo "$data" | grep "<published>" | tail -n 15 | sed -E 's/[ </]+published>//g' | xargs -L1 date "+%s" -d))
done
queue=$(for (( i=0; i<${#video_id[@]}; i++ )); do echo "$i ${video_date[i]}"; done | sort -k2r | awk '{print $1}')
for i in $queue; do
echo "<a href='watch.shs?v=${video_id[$i]}'><img src='http://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a>${video_date[$i]}<br>"
done
else
echo "gtfo"
fi

View File

@ -1,42 +0,0 @@
#!/bin/bash
PREFIX='/yt'
meta[title]="youtube but not really"
source templates/head.sh
# GOOD LUCK FIXING IT WHEN GOOGLE BREAKS IT LOL
#cat webroot/yt/webarchive/search_top.htm
echo "<form action='${r[url]}/search.shs'>
<input name='q' type='text'>
<input type='submit' value='Search'>
</form>
"
if [[ ${get_data[q]} ]]; then
query=${get_data[q]}
query_nice=$(echo ${get_data[q]} | sed -s 's/+/ /g')
echo "<p>Searching for '$query_nice'</p>"
data=$(haruhi-dl "ytsearch30:${get_data[q]}" --flat-playlist -J | jq '.entries[]')
IFS=$'\n'
id=($(jq -r '.id' <<< "$data"))
title=($(jq -r '.title' <<< "$data"))
runtime=($(jq -r '.duration' <<< "$data"))
views=($(jq -r '.view_count' <<< "$data"))
channel=($(jq -r '.channel' <<< "$data"))
channel_id=($(jq -r '.channel_id' <<< "$data"))
unset IFS
for (( i=0; i<${#id[@]}; i++ )); do
echo "<a href='/yt/watch.shs?v=${id[$i]}'><img src='https://i.ytimg.com/vi/${id[$i]}/mqdefault.jpg'><br>${title[$i]}</a> | ${runtime[$i]} seconds | ${views[$i]} views<br>Uploaded by <a href='$PREFIX/channel.shs?id=${channel_id[$i]}'>${channel[$i]}</a><br>"
# echo "<li><div class='yt-lockup yt-lockup-tile yt-lockup-video clearfix yt-uix-tile'><div class='yt-lockup-thumbnail'><a href='$PREFIX/watch.shs?v=${id[$i]}' class='contains-addto yt-uix-sessionlink spf-link'><div class='video-thumb'><img src='https://i.ytimg.com/vi/${id[$i]}/mqdefault.jpg' width='185' height='104'/></div><span class='video-time'>${runtime[$i]}</span><button class='yt-uix-button yt-uix-button-size-small yt-uix-button-default yt-uix-button-empty yt-uix-button-has-icon addto-button video-actions spf-nolink hide-until-delayloaded addto-watch-later-button-sign-in yt-uix-tooltip' type='button' onclick=';return false;' title='Watch Later' role='button'><span class='yt-uix-button-icon-wrapper'><img src='https://s.ytimg.com/yts/img/pixel-vfl3z5WfW.gif' title='Watch Later' class='yt-uix-button-icon yt-uix-button-icon-addto yt-sprite'></span><img src='https://s.ytimg.com/yts/img/pixel-vfl3z5WfW.gif' class='yt-uix-button-arrow yt-sprite'></button></a></div><div class='yt-lockup-content'><h3 class='yt-lockup-title'><a href='$PREFIX/watch.shs?v=${id[$i]}' class='yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-sessionlink spf-link' dir='ltr'>${title[$i]}</a></h3><div class='yt-lockup-meta'><ul class='yt-lockup-meta-info'><li>by <b><a href='/user/PewDiePie' class='yt-uix-sessionlink spf-link g-hovercard'>PewDiePie</a></b></li><li>1 day ago</li><li>2,824,318 views</li></ul></div><div class='yt-lockup-description yt-ui-ellipsis yt-ui-ellipsis-2' dir='ltr'>THE DESCRIPTION GOES HERE!</div><div class='yt-lockup-badges'><ul class='yt-badge-list'><li class='yt-badge-item'><span class='yt-badge'>New</span></li><li class='yt-badge-item'><span class='yt-badge'>HD</span></li></ul></div></div></div></li>"
done
# cat webroot/yt/webarchive/search_bottom.htm
else
echo "search for something will 'ya?"
fi