amazon - dotfiles - leot's dotfiles
 (HTM) hg clone https://bitbucket.org/iamleot/dotfiles
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       amazon
       ---
            1 #!/bin/sh
            2 # $Id$
            3 # elvis: amazon         -- Search the amazon.com bookstore
            4 . surfraw || exit 1
            5 
            6 w3_config_hook () {
            7 def   SURFRAW_amazon_country    "$SURFRAW_lang"
            8 def   SURFRAW_amazon_search     all
            9 }
           10 
           11 w3_usage_hook () {
           12     cat <<EOF
           13 Usage: $w3_argv0 [options] [search-string]
           14 Description:
           15   Search amazon
           16 Local options:
           17   -country=COUNTRY              Two letter domain-style country code
           18            com              |   Main amazon.com site (default)
           19            ca               |   Canada
           20            cn               |   China
           21            de               |   Germany
           22            fr               |   France
           23            it               |   Italy
           24            jp               |   Japan
           25            uk                   UK
           26                                 Environment: SURFRAW_amazon_country, SURFRAW_lang
           27                                 Default: $SURFRAW_amazon_country
           28   -search=                      Specialised search on topic
           29             all                 All Departments.
           30       amazon.com:
           31             apparel             Apparel & Accessories
           32             automotive          Automotive
           33             baby-products       Baby
           34             beauty              Beauty
           35             books               Books
           36             wireless-aps        Cell Phones & Service
           37             electronics         Electronics
           38             misc                Everything Else
           39             gourmet             Gourmet Food
           40             grocery             Grocery
           41             hpc                 Health & Personal Care
           42             garden              Home & Garden
           43             tools               Home Improvement
           44             industrial          Industrial & Scientific
           45             jewelry             Jewelry
           46             digital-text        Kindle Store
           47             magazines           Magazines
           48             dvd                 Movies & TV
           49             digital-music       MP3 Downloads
           50             popular             Music
           51             mi                  Musical Instruments
           52             office-products     Office Products & Supplies
           53             shoes               Shoes
           54             software            Software
           55             sporting            Sports & Outdoors
           56             toys-and-games      Toys & Games
           57             vhs                 VHS
           58             videogames          Video Games
           59             amazontv            Video On Demand
           60             watches             Watches
           61     uk:
           62             books               Books
           63             electronics         Electronics
           64             popular             Music
           65             classical           Classical Music
           66             digital-music       MP3 Downloads
           67             dvd                 DVD
           68             vhs                 VHS
           69             software            Software
           70             videogames          Video Games
           71             software-videogames Software & Games
           72             diy                 DIY & Tools
           73             outdoor             Garden & Outdoors
           74             kitchen             Kitchen & Home
           75             drugstore           Health & Beauty
           76             beauty              Beauty
           77             toys                Toys & Games
           78             sports              Sports & Leisure
           79             jewelry-watches     Jewellery & Watches
           80             clothing            Clothing
           81             shoes               Shoes & Accessories
           82             baby                Baby
           83     fr:
           84             books               Livres en français
           85             english-books       Livres en anglais
           86             electronics         High-tech
           87             popular             Musique
           88             classical           Musique classique
           89             dvd                 DVD & Vidéo
           90             blu-ray             Blu-ray
           91             software            Logiciels
           92             videogames          Jeux vidéo
           93             toys                Jeux et Jouets
           94             kitchen             Cuisine & Maison
           95             jewelry-watches     Montres & Bijoux
           96     de:
           97             books               Bücher
           98             english-books       Englische Bücher
           99             magazines           Zeitschriften
          100             popular             Musik
          101             classical           Klassische Musik
          102             dvd                 DVD
          103             blu-ray             Blu-ray
          104             electronics         Elektronik & Foto
          105             computer            Computer
          106             photo               Kamera & Foto
          107             kitchen             Küche & Haushalt
          108             diy                 Baumarkt
          109             automotive          Auto & Motorrad
          110             outdoor             Garten & Freizeit
          111             drugstore           Drogerie & Bad
          112             beauty              Parfümerie & Kosmetik
          113             software            Software
          114             videogames          Games
          115             toys                Spielzeug
          116             sports              Sport & Freizeit
          117             jewelry-watches     Uhren & Schmuck
          118             baby                Babyausstattung
          119             clothing            Bekleidung
          120             shoes               Schuhe & Handtaschen
          121     ca:
          122             books               Books
          123             popular             Music
          124             classical           Classical Music
          125             dvd                 DVD
          126             vhs                 VHS
          127             electronics         Electronics
          128             software            Software
          129             videogames          Video Games
          130     jp:
          131             books               a書
          132             english-books       m酪
          133             electronics         痩d&塔Jメラ
          134             kitchen             zメ[ム&Lャb\`ャ
          135             popular             塔~ュ[<WbャN
          136             classical           Nャ宴VbャN音y
          137             dvd                 DVD
          138             software            PC潟\tャg
          139             videogames          Qメ[ム
          140             toys                おもちゃ&zャr[
          141             sporting            <X|メ[c&ャAEャghャA
          142             hpc                 wャ泣X&rャ[eャB[
          143             beauty              <RXャ
          144             food-beverage       $Hi&譜料
          145             watch               時v
          146             baby                激xrメ[&}ャ^jャeB
          147             apparel             ャApャ激&泣t@ャbVャ梼G貨
          148     cn:
          149             1                   图书
          150             2                   音乐
          151             3                   影视
          152             5                   手机
          153             6                   家电
          154             7                   化妆
          155             8                   厨具
          156             9                   家居
          157             10                  运动健康
          158             11                  玩具
          159             12                  钟表首饰
          160             14                  个人护理
          161             15                  软件
          162             16                  游戏/娱乐
          163             17                  礼品箱包
          164             20                  摄影摄像
          165             21                  Mp3/Mp4
          166             22                  视听设备
          167             23                  电脑配件
          168             25                  教育音像
          169                                 Default: $SURFRAW_amazon_search
          170                                 Environment: SURFRAW_amazon_search
          171 
          172 Examples:
          173   $w3_argv0 -search=books -country=uk -q The Lotus and The Robot
          174 EOF
          175     w3_global_usage
          176 }
          177 
          178 w3_parse_option_hook () {
          179     opt="$1"
          180     optarg="$2"
          181     case "$opt" in
          182         -search=*)      setopt  SURFRAW_amazon_search           $optarg ;;
          183         -country=*)     setopt  SURFRAW_amazon_country          $optarg ;;
          184         *) return 1 ;;
          185     esac
          186     return 0
          187 }
          188 
          189 w3_config
          190 w3_parse_args "$@"
          191 # w3_args now contains a list of arguments
          192 
          193 case "$SURFRAW_amazon_country" in
          194     uk) host=www.amazon.co.uk         ;;
          195     de) host=www.amazon.de            ;;
          196     fr) host=www.amazon.fr            ;;
          197     it) host=www.amazon.it            ;;
          198     jp) host=www.amazon.co.jp         ;;
          199     ca) host=www.amazon.ca            ;;
          200     cn|zh|zt) host=www.amazon.cn      ;;
          201     *)  host=www.amazon.com           ;;
          202 esac
          203 
          204 if null "$w3_args"; then
          205     w3_browse_url "https://${host}/"
          206 else
          207     escaped_args=`w3_url_of_arg $w3_args`
          208     if [ "$SURFRAW_amazon_search" = books ] ; then
          209         SURFRAW_amazon_search=stripbooks
          210     elif [ "$SURFRAW_amazon_search" = all ] ; then
          211         SURFRAW_amazon_search=aps
          212     fi
          213     case "$host" in
          214     www.amazon.cn)
          215         path="mn/searchApp"
          216         if [ "$SURFRAW_amazon_search" = "aps" ] ;then
          217             SURFRAW_amazon_search=""
          218         fi
          219         args="ix=sunray&pageletid=headsearch&searchType=${SURFRAW_amazon_search}&keywords=${escaped_args}&Go.x=0&Go.y=0&bestSaleNum=0"
          220          break;;
          221     www.amazon.co.jp)
          222         path="s/ref=nb_ss_gw"
          223         args="__mk_ja_JP=%83J%83%5E%83J%83i&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
          224         break;;
          225     www.amazon.co.uk)
          226         path="s/ref=nb_ss_w_h_"
          227         args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
          228         break;;
          229     www.amazon.fr)
          230         path="s/ref=nb_ss_w"
          231         args="__mk_fr_FR=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
          232         break;;
          233     www.amazon.it)
          234         path="s/ref=nb_ss_w"
          235         args="__mk_it_IT=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
          236         break;;
          237     www.amazon.de)
          238         path="s/ref=nb_ss_w"
          239         args="__mk_de_DE=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
          240         break;;
          241     www.amazon.ca)
          242         path="s/ref=nb_ss_gw"
          243         args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
          244         break;;
          245     *)
          246         path="s/ref=nb_ss_gw"
          247         args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
          248     esac
          249     w3_browse_url "https://${host}/${path}?${args}"
          250 fi