* modernizing code + more new templating engine support
parent
d4c901f323
commit
b4e15bec4d
|
@ -29,20 +29,21 @@
|
|||
<div class='comments'></div>
|
||||
<script src='/js/watch.js'></script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
if ('{{.next}}' != '') {
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
var video = document.querySelector('video');
|
||||
video.addEventListener('ended', function() {
|
||||
window.location = 'watch?v={{.next}}&playlist={{.playlist_id}}';
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
{{start ?playlist}}
|
||||
<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
|
||||
|
||||
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
|
||||
echo "$(session_get_username ${cookies[sh_session]}):${get_data[v]}:$title" >> storage/faves
|
||||
fi
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
source "${cfg[namespace]}/code/common.sh"
|
||||
|
||||
declare -A meow
|
||||
|
||||
|
@ -21,7 +22,7 @@ if [[ "${get_data[search_query]}" ]]; then
|
|||
id=($(jq -r '.id' <<< "$data"))
|
||||
title=($(jq -r '.title' <<< "$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_id=($(jq -r '.channel_id' <<< "$data"))
|
||||
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
#!/bin/bash
|
||||
#TODO: move this somewhere more apropriate
|
||||
#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/^,//'
|
||||
}
|
||||
source "${cfg[namespace]}/code/common.sh"
|
||||
|
||||
if [[ ! -d "temp" ]]; then
|
||||
mkdir "temp"
|
||||
|
@ -194,8 +185,7 @@ if [[ "${get_data[v]}" ]]; then
|
|||
done
|
||||
|
||||
strings[_recommended]="rec"
|
||||
|
||||
strings[playlist]=""
|
||||
strings[next]=""
|
||||
|
||||
if [[ "${get_data[playlist]}" ]]; then
|
||||
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'
|
||||
|
||||
strings[?playlist]=true
|
||||
strings[playlist_id]="$(html_encode "${get_data[playlist]}")"
|
||||
strings[next]="$next"
|
||||
|
||||
|
|
Loading…
Reference in New Issue