timproved the youtube search script - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit e15923a2d4ccf656070c9b6e7307bb58e388f271
(DIR) parent 9bd552b94e380e424ea03608a66799895877e8cf
(HTM) Author: z3bra <willy@mailoo.org>
Date: Thu, 22 May 2014 16:17:27 +0200
improved the youtube search script
Diffstat:
M ys | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
(DIR) diff --git a/ys b/ys
t@@ -1,11 +1,11 @@
#!/bin/sh
+#
+# z3bra - (c) wtfpl 2014
+# perform a search on youtube and return the best result (title + link)
+num=3
query=$(echo $@ | tr ' ' '+')
url="http://www.youtube.com/results?search_query=${query}"
-regex='s,^.*title="\([^"]*\)".*href="\(/watch[^"]*\)".*$,\1 http://youtube.com\2,p'
+regex='s,^.*title="\([^"]*\)".*href="\(/watch[^"]*\)".*$,\1 - http://youtube.com\2,p'
-
-curl -s "$url" | sed -n "$regex" | sed 3q | while IFS='' read t l; do
-
- echo "$t - $l"
-done
+curl -s "$url" | sed -n "$regex" | sed ${num}q