diff --git a/templates/themes/default/search.t b/templates/themes/default/search.t index ac48342..7b8248e 100644 --- a/templates/themes/default/search.t +++ b/templates/themes/default/search.t @@ -1 +1,8 @@ -{{.results}} +{{start _results}} + + +
{{.title}}
+ | {{.runtime}} seconds | {{.views}} views
+Uploaded by {{.channel}}
+ +{{end _results}} diff --git a/webroot/search.shs b/webroot/search.shs index c84255e..d61557b 100755 --- a/webroot/search.shs +++ b/webroot/search.shs @@ -1,6 +1,6 @@ #!/bin/bash -declare -A strings +declare -A meow if [[ ${cfg[template]} == 'default' ]]; then meta[title]="youtube but not really" @@ -14,28 +14,38 @@ if [[ "${get_data[search_query]}" ]]; then fi 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' + 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" | xargs printf "%d\n")) channel=($(jq -r '.channel' <<< "$data")) channel_id=($(jq -r '.channel_id' <<< "$data")) unset IFS - for (( i=0; i<${#id[@]}; i++ )); do - strings[results]+="
${title[$i]}
| ${runtime[$i]} seconds | ${views[$i]} views
Uploaded by ${channel[$i]}
" + declare -A strings + 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 + meow[_results]=nyaa else strings[results]="search for something will 'ya?" fi -if [[ ! "$(which haruhi-dl)" || $? != "0" ]]; then - strings[results]="Could not fetch search results" -fi +#if [[ ! "$(which haruhi-dl)" || $? != "0" ]]; then +# strings[results]="Could not fetch search results" +#fi 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"