* search: move to the new templating engine
This commit is contained in:
parent
da609de918
commit
7e4e26f0f2
|
@ -1 +1,8 @@
|
||||||
{{.results}}
|
{{start _results}}
|
||||||
|
|
||||||
|
<a href='/watch?v={{.id}}'>
|
||||||
|
<img src='https://i.ytimg.com/vi/{{.id}}/mqdefault.jpg'><br>{{.title}}</a>
|
||||||
|
| {{.runtime}} seconds | {{.views}} views<br>
|
||||||
|
Uploaded by <a href='/channel/{{.channel_id}}'>{{.channel}}</a><br>
|
||||||
|
|
||||||
|
{{end _results}}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
declare -A strings
|
declare -A meow
|
||||||
|
|
||||||
if [[ ${cfg[template]} == 'default' ]]; then
|
if [[ ${cfg[template]} == 'default' ]]; then
|
||||||
meta[title]="youtube but not really"
|
meta[title]="youtube but not really"
|
||||||
|
@ -14,28 +14,38 @@ if [[ "${get_data[search_query]}" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${get_data[search_query]}" ]]; then
|
if [[ "${get_data[search_query]}" ]]; then
|
||||||
data=$(haruhi-dl --ie-key YoutubeSearch "ytsearch30:${get_data[search_query]}" --flat-playlist -J | jq '.entries[]')
|
data=$(yt-dlp "ytsearch30:${get_data[search_query]}" --flat-playlist -J | jq '.entries[]')
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
|
||||||
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" | xargs printf "%d\n"))
|
||||||
channel=($(jq -r '.channel' <<< "$data"))
|
channel=($(jq -r '.channel' <<< "$data"))
|
||||||
channel_id=($(jq -r '.channel_id' <<< "$data"))
|
channel_id=($(jq -r '.channel_id' <<< "$data"))
|
||||||
|
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
for (( i=0; i<${#id[@]}; i++ )); do
|
declare -A strings
|
||||||
strings[results]+="<a href='/watch?v=${id[$i]}'><img src='https://i.ytimg.com/vi/${id[$i]}/mqdefault.jpg'><br>${title[$i]}</a> | ${runtime[$i]} seconds | ${views[$i]} views<br>Uploaded by <a href='/channel/${channel_id[$i]}'>${channel[$i]}</a><br>"
|
nested_declare nyaa
|
||||||
|
for (( i=0; i<${#id[@]}; i++ )); do
|
||||||
|
strings[id]="${id[$i]}"
|
||||||
|
strings[title]="${title[$i]}"
|
||||||
|
strings[runtime]="${runtime[$i]}"
|
||||||
|
strings[views]="${views[$i]}"
|
||||||
|
strings[channel_id]="${channel_id[$i]}"
|
||||||
|
strings[channel]="${channel[$i]}"
|
||||||
|
nested_add nyaa strings
|
||||||
done
|
done
|
||||||
|
meow[_results]=nyaa
|
||||||
else
|
else
|
||||||
strings[results]="search for something will 'ya?"
|
strings[results]="search for something will 'ya?"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! "$(which haruhi-dl)" || $? != "0" ]]; then
|
#if [[ ! "$(which haruhi-dl)" || $? != "0" ]]; then
|
||||||
strings[results]="Could not fetch search results"
|
# strings[results]="Could not fetch search results"
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
source "${cfg[namespace]}/templates/header.shs"
|
source "${cfg[namespace]}/templates/header.shs"
|
||||||
render_unsafe strings "${cfg[namespace]}/templates/themes/${cfg[template]}/search.t"
|
render meow "${cfg[namespace]}/templates/themes/${cfg[template]}/search.t"
|
||||||
|
|
Loading…
Reference in a new issue