aboutsummaryrefslogtreecommitdiff
path: root/eyt
blob: d30ca1e73984dcc7b18017b3bac8757e014cf74e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/sh
getResults(){
echo "$response" | grep -oP "$1" | awk -F\" -v p="$2" '{ print $1 "\t" p $NF}'
}

read -r query
squery=$(echo "$query" | sed 's|+|%2B|g;s|#|%23|g;s|&|%26|g;s| |+|g')
response="$(curl -s "https://www.youtube.com/results?search_query=$squery") |\
sed 's|\\.||g')"
vgrep='"videoRenderer":{"videoId":"\K.{11}".+?"text":".+?[^\\](?=")'
videoids="$(getResults $vgrep)"
echo -e "$videoids" | awk -F'	' '{print $2 " -$- " $1}'