* modernizing code + more new templating engine support
This commit is contained in:
parent
d4c901f323
commit
b4e15bec4d
|
@ -29,20 +29,21 @@
|
||||||
<div class='comments'></div>
|
<div class='comments'></div>
|
||||||
<script src='/js/watch.js'></script>
|
<script src='/js/watch.js'></script>
|
||||||
|
|
||||||
<script type='text/javascript'>
|
|
||||||
if ('{{.next}}' != '') {
|
{{start ?playlist}}
|
||||||
window.addEventListener('DOMContentLoaded', (event) => {
|
|
||||||
var video = document.querySelector('video');
|
|
||||||
video.addEventListener('ended', function() {
|
|
||||||
window.location = 'watch?v={{.next}}&playlist={{.playlist_id}}';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<h1>Playlist</h1>
|
<h1>Playlist</h1>
|
||||||
{{start _playlist}}
|
|
||||||
|
|
||||||
<a href='watch?v={{.id}}&playlist={{.playlist_id}}'><img src='//i.ytimg.com/vi/{{.id}}/mqdefault.jpg'><br>{{.title}}</a><br>
|
<script type='text/javascript'>
|
||||||
|
window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
|
var video = document.querySelector('video');
|
||||||
|
video.addEventListener('ended', function() {
|
||||||
|
window.location = 'watch?v={{.next}}&playlist={{.playlist_id}}';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{{start _playlist}}
|
||||||
|
|
||||||
{{end _playlist}}
|
<a href='watch?v={{.id}}&playlist={{.playlist_id}}'><img src='//i.ytimg.com/vi/{{.id}}/mqdefault.jpg'><br>{{.title}}</a><br>
|
||||||
|
|
||||||
|
{{end _playlist}}
|
||||||
|
{{end ?playlist}}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
declare -A strings
|
declare -A strings
|
||||||
|
|
||||||
if session_verify "${cookies[sh_session]}" && [[ "${get_data[v]}" != '' ]]; then
|
if session_verify "${cookies[sh_session]}" && [[ "${get_data[v]}" != '' ]]; then
|
||||||
title=$(haruhi-dl --cookies ${cfg[_cookies]} -e "https://youtube.com/watch?v=${get_data[v]}")
|
title=$(yt-dlp --cookies ${cfg[_cookies]} -e "https://youtube.com/watch?v=${get_data[v]}")
|
||||||
if [[ $(grep -F "$title" storage/faves | 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
|
echo "$(session_get_username ${cookies[sh_session]}):${get_data[v]}:$title" >> storage/faves
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
source "${cfg[namespace]}/code/common.sh"
|
||||||
|
|
||||||
declare -A meow
|
declare -A meow
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ if [[ "${get_data[search_query]}" ]]; then
|
||||||
id=($(jq -r '.id' <<< "$data"))
|
id=($(jq -r '.id' <<< "$data"))
|
||||||
title=($(jq -r '.title' <<< "$data"))
|
title=($(jq -r '.title' <<< "$data"))
|
||||||
runtime=($(jq -r '.duration' <<< "$data"))
|
runtime=($(jq -r '.duration' <<< "$data"))
|
||||||
views=($(jq -r '.view_count' <<< "$data" | xargs printf "%d\n"))
|
views=($(jq -r '.view_count' <<< "$data" | format_numbers))
|
||||||
channel=($(jq -r '.channel' <<< "$data"))
|
channel=($(jq -r '.channel' <<< "$data"))
|
||||||
channel_id=($(jq -r '.channel_id' <<< "$data"))
|
channel_id=($(jq -r '.channel_id' <<< "$data"))
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#TODO: move this somewhere more apropriate
|
source "${cfg[namespace]}/code/common.sh"
|
||||||
#jq_to_array(jq_expression)
|
|
||||||
function _jq_to_array() {
|
|
||||||
declare -ga "_tmp=($(jq -r "$1" | sed 's/[][`~!@#$%^&*():;<>.,?\|{}=+-]/\\&/g;'"s@\\\'@\\'@g" ))"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function format_numbers() {
|
|
||||||
rev | sed "s#[[:digit:]]\{3\}#&,#g" | rev | sed -E 's/^,//'
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ ! -d "temp" ]]; then
|
if [[ ! -d "temp" ]]; then
|
||||||
mkdir "temp"
|
mkdir "temp"
|
||||||
|
@ -194,8 +185,7 @@ if [[ "${get_data[v]}" ]]; then
|
||||||
done
|
done
|
||||||
|
|
||||||
strings[_recommended]="rec"
|
strings[_recommended]="rec"
|
||||||
|
strings[next]=""
|
||||||
strings[playlist]=""
|
|
||||||
|
|
||||||
if [[ "${get_data[playlist]}" ]]; then
|
if [[ "${get_data[playlist]}" ]]; then
|
||||||
playlist=$(yt-dlp --cookies ${cfg[_cookies]} -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[playlist]}")
|
playlist=$(yt-dlp --cookies ${cfg[_cookies]} -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[playlist]}")
|
||||||
|
@ -213,6 +203,7 @@ if [[ "${get_data[v]}" ]]; then
|
||||||
|
|
||||||
[[ "$next" == '' ]] && next='dQw4w9WgXcQ'
|
[[ "$next" == '' ]] && next='dQw4w9WgXcQ'
|
||||||
|
|
||||||
|
strings[?playlist]=true
|
||||||
strings[playlist_id]="$(html_encode "${get_data[playlist]}")"
|
strings[playlist_id]="$(html_encode "${get_data[playlist]}")"
|
||||||
strings[next]="$next"
|
strings[next]="$next"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue