tformat ys output - scripts - random scripts
HTML git clone git://parazyd.org/scripts.git
DIR Log
DIR Files
DIR Refs
---
DIR commit 8f61a806f43371328a0805e6d74432ea3a6790dc
DIR parent e46c23f80627e322524c87cec39653b291110188
HTML Author: parazyd <parazyd@dyne.org>
Date: Fri, 17 Mar 2017 22:46:27 +0100
format ys output
Diffstat:
M ys | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
DIR diff --git a/ys b/ys
t@@ -17,14 +17,21 @@ search() {
sstr=$1
fi
- curl -s \
+ json="$(curl -s \
-G "https://www.googleapis.com/youtube/v3/search" \
-d part="snippet" \
-d q=$sstr \
-d maxResults=$NRES \
-d key=$KEY | \
jq '[.items[] | {"title":.snippet.title,
- "url": ["https://www.youtube.com/watch?v=" + .id.videoId] }]' -
+ "url": ["https://www.youtube.com/watch?v=" + .id.videoId] }]' -)"
+
+ printf -- "---------------------------------------------\n"
+ for i in $(seq 0 $(( $NRES - 1)) ); do
+ printf "%s" "$json" | jq ".[${i}].title"
+ printf "%s" "$json" | jq ".[${i}].url[]"
+ printf -- "---------------------------------------------\n"
+ done
}
case $1 in