From a42af1ceefb2ab17011883255de8c66142b472d0 Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Fri, 26 Feb 2021 23:23:55 +0100 Subject: [PATCH] + backported flashplayergit status --- config.sh | 1 + routes.sh | 10 ++- webroot/player.shs | 4 +- webroot/player_flash.shs | 8 +++ webroot/watch.shs | 2 +- webroot/watch_flash.shs | 149 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 170 insertions(+), 4 deletions(-) create mode 100755 webroot/player_flash.shs create mode 100755 webroot/watch_flash.shs diff --git a/config.sh b/config.sh index 5f59400..1880b32 100644 --- a/config.sh +++ b/config.sh @@ -1,2 +1,3 @@ cfg[title]='BashTube' cfg[_cookies]='cookiejar' +cfg[flash_host]='flash.xn--domi-o5a.pl' diff --git a/routes.sh b/routes.sh index 978097b..22becdc 100644 --- a/routes.sh +++ b/routes.sh @@ -1,7 +1,15 @@ #router "/profile/:user" "app/webroot/index.shs" #router "/uwu" "owo" -router "/watch" "${cfg[namespace]}/webroot/watch.shs" + router "/channel/:id" "${cfg[namespace]}/webroot/channel.shs" router "/user/:user" "${cfg[namespace]}/webroot/channel.shs" router "/playlist" "${cfg[namespace]}/webroot/playlist.shs" + +if [[ "${r[host]}" == "${cfg[flash_host]}" ]]; then + router "/watch" "${cfg[namespace]}/webroot/watch_flash.shs" +else + router "/watch" "${cfg[namespace]}/webroot/watch.shs" +fi + +echo "${r[host]}" > tmp diff --git a/webroot/player.shs b/webroot/player.shs index 9723ba2..b43dca3 100755 --- a/webroot/player.shs +++ b/webroot/player.shs @@ -9,5 +9,5 @@ echo ' height: 480px; } -
[x]
Video ID:
Dimensions:
Resolution:
Volume:
Stream Type:
CPN:
Mime Type:
DASH:
Protected:
Bandwidth:
Decoded FramesDropped FramesParsed FramesPresented Frames
Video Bytes DecodedAudio Bytes DecodedPainted FramesPaint Delay
0:00
-' \ No newline at end of file +
[x]
Video ID:
Dimensions:
Resolution:
Volume:
Stream Type:
CPN:
Mime Type:
DASH:
Protected:
Bandwidth:
Decoded FramesDropped FramesParsed FramesPresented Frames
Video Bytes DecodedAudio Bytes DecodedPainted FramesPaint Delay
0:00
+' diff --git a/webroot/player_flash.shs b/webroot/player_flash.shs new file mode 100755 index 0000000..3ce3ded --- /dev/null +++ b/webroot/player_flash.shs @@ -0,0 +1,8 @@ +url_="$(echo "$url" | xxd -ps | sed -E 's/.{2}/%&/g' | tr -d '\n')" +echo '' diff --git a/webroot/watch.shs b/webroot/watch.shs index 36e132c..06b8e0c 100755 --- a/webroot/watch.shs +++ b/webroot/watch.shs @@ -81,7 +81,7 @@ if [[ "${get_data[v]}" ]]; then # echo "

"; #done - vid="$(curl -s "https://www.youtube.com/watch?v=LACbVhgtx9I" -c cookiejar_)" # broken comment support, we need this for now + vid="$(curl -s "https://www.youtube.com/watch?v=${get_data[v]}" -c cookiejar_)" # broken comment support, we need this for now echo "

Comments

" diff --git a/webroot/watch_flash.shs b/webroot/watch_flash.shs new file mode 100755 index 0000000..ad4be8b --- /dev/null +++ b/webroot/watch_flash.shs @@ -0,0 +1,149 @@ +#!/bin/bash + +if [[ "${get_data[v]}" ]]; then + if [[ "${get_data[v]}" == '18l' || "${get_data[v]}" == '5eFdt6Y_34E' ]]; then + uploader='MyMusicGroup' + title='█▬█ █ ▀█▀ Jeden Osiem L - Jak Zapomnieć (Oficjalny Teledysk)' + url='https://f.sakamoto.pl/videoplayback_.flv' + meta[title]="$title" + source templates/head.sh + else + 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]}") + if [[ $video == '' ]]; then # seriously WHO DID THIS + return + fi + fi + cd .. + #echo "http://youtube.com/watch?v=${get_data[v]}" > /dev/stderr + channel_id=$(jq -r '.channel_url' <<< "$video" | sed -s 's/http:\/\/www.youtube.com\/channel\///') + uploader=$(jq -r '.uploader' <<< "$video") + title=$(jq -r '.title' <<< "$video") + meta[title]="$title" + source templates/head.sh + IFS=$'\n' + urls=($(jq -r '.formats[] | select(.format_id == "22" or .format_id == "18").url' <<< "$video")) + unset IFS + if [[ ${urls[1]} != '' ]]; then + url=${urls[1]} + else + url=${urls[0]} + fi + fi + echo "
+ + +
+

" + + source "${cfg[namespace]}/webroot/player_flash.shs" + + # + echo "

$title

+
+
+ Uploaded by $uploader on $(date -d "$(echo $video | jq -r '.upload_date' | sed -E 's/..../&-/;s/....-../&-/')" "+%d %B %Y") +
+
+ $(echo $video | jq -r '.view_count') views
+ $(echo $video | jq -r '.like_count') likes, $(echo $video | jq -r '.dislike_count') dislikes.
" + if [[ ${cookies[sh_session]} ]]; then + if [[ $(grep $(session_get_username "${cookies[sh_session]}") storage/faves | grep "${get_data[v]}") == '' ]]; then + echo "Add to favourites
" + else + echo "Remove from favourites
" + fi + if [[ $(grep $(session_get_username "${cookies[sh_session]}") storage/subscribed | grep "$channel_id") == '' ]]; then + echo "Subscribe to $uploader!
" + else + echo "Unsubscribe from $uploader
" + fi + else + echo "Log in to add this video to your favourites and/or subscribe to this channel!
" + fi + echo "

+
+
+ Description:
$(echo "$video" | jq -r '.description' | sed -E 's/$/
/g')
+
"; + + vid="$(cat "temp/${get_data[v]}_https_-_"*"watch"*".dump")" + vid_json="$(tr -d '\n' <<< "$vid" | grep -Poh "ytInitialData.*?" | sed 's/ytInitialData = //;s/<\/script>//')" + + echo "

Recommended

+
" + + jq -r '.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results[] | .compactAutoplayRenderer.contents[0].compactVideoRenderer, .compactVideoRenderer | if .videoId != null then "
"+.title.simpleText+"
" else empty end' <<< "$vid_json" + + #for i in $(grep -ohE "watch\?v\=[A-zaz0-9]{11}" <<< "$vid" | cut -c 9-19 | uniq); do + # echo "

"; + #done + + vid="$(curl -s "https://www.youtube.com/watch?v=${get_data[v]}" -c cookiejar_)" # broken comment support, we need this for now + + echo "

Comments

" + + 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 -vvv '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")) + comment_published=($(jq -r '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.publishedTimeText.runs[0].text' <<< "$comments")) + comment_likes=($(jq -r '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.likeCount' <<< "$comments")) + comment_avatar=($(jq -r '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.authorThumbnail.thumbnails[1].url' <<< "$comments")) + unset IFS + x=$(jq '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.contentText.runs | map(.text)' <<< "$comments") + IFS=']' + for i in $x; do + comment_text+=($(echo "$i]" | jq -r 'join("")')) # sincerely, fsck [] shell expansion + done + + for (( i=0; i<${#comment_nick[@]}; i++ )); do + echo "
+ ${comment_nick[$i]} | ${comment_published[$i]} | ${comment_likes[$i]} liked
+
${comment_text[$i]}
+

" + done + + if [[ "${get_data[playlist]}" ]]; then + playlist=$(haruhi-dl --cookies ${cfg[_cookies]} -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[playlist]}") + + IFS=$'\n' + video_title=($(jq -r '.title' <<< $playlist)) + video_id=($(jq -r '.id' <<< $playlist)) + + for (( i=0; i<${#video_id[@]}; i++ )); do + if [[ "${video_id[$i]}" == "${get_data[v]}" ]]; then + next="${video_id[$((i+1))]}" + break + fi + done + + [[ "$next" == '' ]] && next='dQw4w9WgXcQ' + + echo "" + echo "

Playlist

" + + for (( i=0; i<${#video_id[@]}; i++ )); do + echo "
${video_title[$i]}

" + done + fi + + echo "" +else + source templates/head.sh + echo "pls add ?v param i'm still WiP" +fi