bashtube/webroot/yt/subscribe.shs

23 lines
783 B
Bash

#!/bin/bash
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 -F "$title" | grep "$(echo ${cookies[username]} | sed -E "s/\r//")") == '' ]]; then
echo "$(session_get_username ${cookies[sh_session]}):${get_data[id]}:$title" >> storage/subscribed
fi
fi
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
IFS=':'
array=($i)
if [[ ${array[1]} == '' ]]; then
break
fi
echo "<div><a href='channel.shs?id=${array[1]}'>${array[@]:2:999}</a><br></div>";
done