diff options
| author | Arthur Melton <amtitan@icloud.com> | 2022-12-05 09:44:27 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-05 09:44:27 -0500 |
| commit | 8d86039abda2283b332a61d620688033c51dceb7 (patch) | |
| tree | 74ebf2a7714ecb0f93d9fdc9b98b4b170c609af7 /yts | |
| parent | 970f9bbf67965e1633210be0a3f4dac6daf3c87b (diff) | |
no temp file
Diffstat (limited to 'yts')
| -rwxr-xr-x | yts | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -2,10 +2,9 @@ query=$(echo $* | sed s/\ /+/g) file=$(mktemp) -$(curl -sL "www.youtube.com/results?search_query=${query}" >> ${file}) -watches=($(cat ${file} | grep -Po '"videoRenderer":{"videoId":"([a-zA-Z0-9_-]{11})' | awk -F: '{print $3}' | sed 's/^.//' | uniq | awk '{print "www.youtube.com/watch?v="$0}' | head -n5)) -titles=$(cat ${file} | grep -Po '"title":{"runs":\[{"text":.{1,100}"}\],' | awk -F: '{print $4}' | sed 's/....$//' | sed 's/.//' | head -n5) -rm ${file} +search=$(curl -sL "www.youtube.com/results?search_query=${query}") +watches=($(echo "$search" | grep -Po '"videoRenderer":{"videoId":"([a-zA-Z0-9_-]{11})' | awk -F: '{print $3}' | sed 's/^.//' | uniq | awk '{print "www.youtube.com/watch?v="$0}' | head -n5)) +titles=$(echo "$search" | grep -Po '"title":{"runs":\[{"text":.{1,100}"}\],' | awk -F: '{print $4}' | sed 's/....$//' | sed 's/.//' | head -n5) for ((i=0;i<5;i++)) do title[i]=$(echo "${titles}" | head -n$(echo "${i}+1" | bc) | tail -n1) |
