#!/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 "
";
#done
if [[ ${get_data[v]} ]]; then
video=$(youtube-dl -J "http://youtube.com/watch?v=${get_data[v]}")
if [[ $video == '' ]]; then
video=$(youtube-dl -J "http://youtube.com/watch?v=${get_data[v]}")
if [[ $video == '' ]]; then
return
fi
fi
#echo "http://youtube.com/watch?v=${get_data[v]}" > /dev/stderr
title=$(echo $video | jq -r '.title')
meta[title]=$title
source templates/head.sh
IFS=$'\n'
urls=($(echo $video | jq -r '.formats[] | select(.format_id == "22" or .format_id == "18").url'))
unset IFS
if [[ ${urls[1]} != '' ]]; then
url=${urls[1]}
else
url=${urls[0]}
fi
echo "
$title
$(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 [[ $(cat storage/faves | grep $(echo -n ${cookies[username]} | sed -E 's/\r//g') | grep ${get_data[v]}) == '' ]]; then
echo "
Add to favourites"
else
echo "
Remove from favourites"
fi
else
echo "
Log in to add this video to your favourites!"
fi
echo "
Description:
$(echo $video | jq -r '.description' | sed -E 's/$/
/g')
";
else
source templates/head.sh
echo "pls add ?v param i'm still WiP"
fi