[Surfraw-commits] [SCM] surfraw - a fast unix command line interface to WWW branch, master, updated. surfraw_2-2-5_1-175-g7688649

Ian Beckwith ianb at erislabs.net
Thu Mar 3 23:40:50 UTC 2011


The following commit has been merged in the master branch:
commit 8969eadcc6963f92fa7322b504232ea1191b0490
Author: Ian Beckwith <ianb at erislabs.net>
Date:   Thu Mar 3 20:59:10 2011 +0000

    google: support videos, maps, news, -i, -v, -m, -n

diff --git a/ChangeLog b/ChangeLog
index f94a5e6..03023be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,12 @@
 2011-03-03  Ian Beckwith  <ianb at erislabs.net>
 
 	* opensearch: new option -r, uses redirector at
-	  http://erislabs.net/ianb/webtools/opensearch/
-	  instead of calling opensearch-discover and
-	  opensearch-genquery. -r is selected automatically
-	  if those tools are not installed.
+	  http://erislabs.net/ianb/webtools/opensearch/ instead of calling
+	  opensearch-discover and opensearch-genquery. -r is selected
+	  automatically if those tools are not installed. This enables us
+	  to ship opensearch in the main surfraw package and it still
+	  functions if the dependencies are not installed. See
+	  debian/changelog.
 	* wikipedia: new options:
 	  + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/
 	    This redirector searches for a page with that name at wikipedia.
@@ -13,6 +15,10 @@
 	  + -f=w|d, -fallback=wikipedia|deletionpedia
 	    Implies -d. If page not found at either wikipedia or deletionpedia,
             whether to fallback to wikipedia search or deletionpedia search.
+	* google:
+	  + support video, maps and news.
+	  + new options -i, -v, -m, -n, shortcuts for
+	    -search={images,videos,maps,news}.
 
 2011-02-20  Ian Beckwith  <ianb at erislabs.net>
 
diff --git a/elvi/google b/elvi/google
index d01c784..a5dcd7c 100755
--- a/elvi/google
+++ b/elvi/google
@@ -21,16 +21,23 @@ Local options:
                                 Default: $SURFRAW_google_results
                                 Environment: SURFRAW_google_results
   -search=                      Specialized search on topic
+	  images	|	Images
+	  videos	|	Videos
+	  maps		|	Maps
+	  news		|	News
           bsd           |       BSD
           linux         |       Linux
           mac           |       Apple Macintosh
           unclesam      |       U.S. Government
-	  images	|	Images
                                 Environment: SURFRAW_google_search
   -country=			Select regional google site
 				Default is us (google.com)
 	   <ISO 3166 alpha-2 code>
-				Environment: SURFRAW_google_country 
+				Environment: SURFRAW_google_country
+  -i, -images                   Image Search (same as -search=images)
+  -v, -videos                   Video Search (same as -search=videos)
+  -m, -maps                     Map Search (same as -search=maps)
+  -n, -news                     News Search (same as -search-news)
 EOF
     w3_global_usage
 }
@@ -39,10 +46,14 @@ w3_parse_option_hook () {
     opt="$1"
     optarg="$2"
     case "$opt" in
-    -results=*) setopt   SURFRAW_google_results "$optarg" ;;
-    -search=*)  setopt   SURFRAW_google_search  "$optarg" ;;
+    -r*=*)      setopt   SURFRAW_google_results "$optarg" ;;
+    -s*=*)      setopt   SURFRAW_google_search  "$optarg" ;;
     -l|-lu*)    setoptyn SURFRAW_google_lucky   1         ;;
-    -country=*) setopt	 SURFRAW_google_country "$optarg" ;;
+    -c=*) 	setopt	 SURFRAW_google_country "$optarg" ;;
+    -i*)        setopt   SURFRAW_google_search  images    ;;
+    -v*)        setopt   SURFRAW_google_search  videos    ;;
+    -m*)        setopt   SURFRAW_google_search  maps      ;;
+    -n|-news)   setopt   SURFRAW_google_search  news      ;;
     *) return 1 ;;
     esac
     return 0
@@ -64,14 +75,36 @@ case "$SURFRAW_google_country" in
   *)  domain="$SURFRAW_google_country" ;;
 esac
 
-if test -z "$w3_args"; then
-    w3_browse_url "http://www.google.${domain}/"
+url="http://"
+
+if test -z "$w3_args" ; then
+    case "$SURFRAW_google_search" in
+	i*) url="${url}images" ;;
+	m*) url="${url}maps"   ;;
+	n*) url="${url}news"   ;;
+	v*) url="${url}video"  ;;
+	*)  url="${url}www"    ;;
+    esac
+    url="${url}.google.${domain}"
 else
+    search="$SURFRAW_google_search"
+    case "$SURFRAW_google_search" in
+	v*) url="${url}www"; search="search"; extra="&tbo=p&tbm=vid";;
+	i*) url="${url}images" ; search="images";;
+	m*) url="${url}maps"   ; search=maps    ;;
+	n*) url="${url}news"   ; search=news    ;;
+	*)  url="${url}www"    ;;
+    esac
+
+    url="${url}.google.${domain}/${search}"
     escaped_args=`w3_url_of_arg $w3_args`
-	if [ "$SURFRAW_google_lucky" = 1 ]; then
-		button=`w3_url_escape "I'm Feeling Lucky"`
-		w3_browse_url "http://www.google.${domain}/${SURFRAW_google_search}?q=${escaped_args}&btnI=$button&num=${SURFRAW_google_results}"	
-	else
-		w3_browse_url "http://www.google.${domain}/${SURFRAW_google_search}?q=${escaped_args}&num=${SURFRAW_google_results}"
-	fi
+    url="${url}?q=${escaped_args}&num=${SURFRAW_google_results}"
+    if [ "$SURFRAW_google_lucky" = 1 ]; then
+	button=`w3_url_escape "I'm Feeling Lucky"`
+	url="${url}&btnI=$button"
+    fi
+    url="${url}${extra}"
 fi
+
+w3_browse_url "$url"
+

-- 
surfraw -  a fast unix command line interface to WWW



More information about the Surfraw-commits mailing list