#!/bin/bash source "${cfg[namespace]}/code/common.sh" declare -A meow if [[ ${cfg[template]} != 'retro' ]]; then meta[title]="youtube but not really" #source templates/head.sh source "${cfg[namespace]}/templates/header.shs" fi #https://www.youtube.com/results?search_query=oooo if [[ "${get_data[search_query]}" ]]; then query="${get_data[search_query]}" meow[query]=$(sed -s 's/+/ /g' <<< "${get_data[search_query]}") meow[?query]=true query_nice=$(sed -s 's/+/ /g' <<< "${get_data[search_query]}") fi if [[ "${get_data[search_query]}" ]]; then 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" | format_numbers)) channel=($(jq -r '.channel' <<< "$data")) channel_id=($(jq -r '.channel_id' <<< "$data")) unset IFS declare -A strings nested_declare nyaa for (( i=0; i<${#id[@]}; i++ )); do strings[id]="${id[$i]}" strings[title]="${title[$i]}" strings[runtime]="$(date -d "@${runtime[$i]}" "+%H:%M:%S" -u)" 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 render meow "${cfg[namespace]}/templates/themes/${cfg[template]}/search.html"