#!/bin/bash declare -A strings if [[ ${cfg[template]} == 'default' ]]; then meta[title]="youtube but not really" source templates/head.sh fi if [[ "${get_data[q]}" ]]; then query="${get_data[q]}" query_nice=$(sed -s 's/+/ /g' <<< "${get_data[q]}") fi if [[ "${get_data[q]}" ]]; then data=$(haruhi-dl --ie-key YoutubeSearch "ytsearch30:${get_data[q]}" --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")) 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]}
" done else strings[results]="search for something will 'ya?" 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"