bashtube/webroot/fav.shs

32 lines
1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2021-02-28 17:43:40 +01:00
declare -A strings
2021-02-18 01:18:06 +01:00
if session_verify "${cookies[sh_session]}" && [[ "${get_data[v]}" != '' ]]; then
title=$(yt-dlp --cookies ${cfg[_cookies]} -e "https://youtube.com/watch?v=${get_data[v]}")
2021-01-28 22:56:24 +01:00
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
2021-02-28 17:43:40 +01:00
if [[ ${cfg[template]} == 'default' ]]; then
source templates/head.sh
fi
IFS=$'\n'
2021-01-28 22:56:24 +01:00
for i in $(tac storage/faves | grep -P "^$(session_get_username ${cookies[sh_session]}):"); do
IFS=':'
array=($i)
if [[ ${array[1]} == '' ]]; then
break
fi
2021-02-28 17:43:40 +01:00
strings[fav]+="<div><a href='watch?v=${array[1]}'><img src='https://i.ytimg.com/vi/${array[1]}/mqdefault.jpg'><br><b>${array[@]:2:999}</b></a><br></div>";
done
2021-02-28 17:43:40 +01:00
if [[ ! ${strings[fav]} ]]; then
strings[fav]="You are not logged in or you do not have any favorites"
fi
2021-03-01 23:53:15 +01:00
source "${cfg[namespace]}/templates/header.shs"
2021-02-28 17:43:40 +01:00
render_unsafe strings "${cfg[namespace]}/templates/themes/${cfg[template]}/fav.t"