LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: lolilolicon

**** 心连心:各大网盘上传脚本大全 ****

[复制链接]
 楼主| 发表于 2009-5-25 03:16:24 | 显示全部楼层
上传图片到 scrnshots.com 的脚本
参见 http://groups.google.com/group/s ... documentation?pli=1
  1. #!/bin/sh
  2. #image size limit::5MB
  3. ###帐号和密码
  4. User=
  5. Pass=
  6. help()
  7. {
  8.                echo 'An uploader for ScrnShots.com.'
  9.                echo
  10.         echo "Usage: `basename "$0"` [OPTION]... [FILE]..."
  11.         echo
  12.         echo 'OPTIONs:'
  13.             echo ' -d, --description=DESC set DESC as description'
  14.             echo ' -t, --tag=TAGS set tags TAGS, space seperated'
  15.             echo ' -s, --srcurl=URL set sorce url to URL'
  16.            echo ' -h, --help display this help and exit'
  17.             return 0
  18. }
  19.    
  20. OPT_TEMP=$(getopt --longoptions tag:,description:,srcurl:,help \
  21.     --name "Scrn Uploader" --options t:d:s:h \
  22.     -- "$@")
  23. if [ $? != 0 ]; then echo 'Wrong option, calling the police... or use -h to save yourself $_$' ; exit 1; fi
  24. eval set -- "$OPT_TEMP"
  25.   
  26. while : ; do
  27. case "$1" in
  28.             -t|--tag) TAGS="$2"; shift 2;;
  29.             -d|--description) DESC="$2"; shift 2;;
  30.         -s|--srcurl) SRC="$2"; shift 2;;
  31.         -h|--help) help; exit 0;;
  32.             --) shift ; break ;;
  33.             *) echo 'Wrong option, calling the police... or use -h to save yourself $_$' ; exit 1 ;;
  34.   esac
  35. done
  36. for arg; do
  37. echo "**** Uploading `basename "${arg}"`... ****"
  38.         FMT=$( file -b --mime-type "${arg}" )
  39.         curl -# http://www.scrnshots.com/screenshots.xml -H 'Accept: application/xml' \
  40.         -F screenshot\[uploaded_data\]=@"${arg}"\;type="${FMT}" \
  41.         -F screenshot\[description\]="${DESC}" \
  42.         -F screenshot\[tag_list\]="${TAGS}" \
  43.         -F screenshot\[source_url\]="${SRC}" \
  44.         -u "${User}:${Pass}" --basic |
  45.         sed '/<images>/,/<\/images>/s/.*"\(.*\)".*/\1/;s/.*<link>\(.*\)<\/link>/\1/;/<.*>/d;'
  46.     if [ $? != 0 ]; then
  47. echo "**** failed. ****"
  48.     fi
  49. done
复制代码

样本输出
  1. : [~][soko:2:0]; bash scripts/handy_scripts/file_hosting/image_upload_scripts/scrnshots.sh  ~/SHOT/2009-05-25_\<04\:09\:55\>.png
  2. **** Uploading 2009-05-25_<04:09:55>.png... ****
  3. ######################################################################## 100.0%
  4. [url]http://www.scrnshots.com/users/lolilolicon/screenshots/165601[/url]
  5. [url]http://s3.amazonaws.com/scrnshots.com/screenshots/165601/55_png[/url]
  6. [url]http://s3.amazonaws.com/scrnshots.com/screenshots/165601/55_png_large[/url]
  7. [url]http://s3.amazonaws.com/scrnshots.com/screenshots/165601/55_png_med_rect[/url]
  8. [url]http://s3.amazonaws.com/scrnshots.com/screenshots/165601/55_png_small_square[/url]
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-25 18:00:53 | 显示全部楼层
于是偏离主题
虽然本人觉得这种网站的用途除了掩盖NSFW或者拿来恶作剧以外纯属无聊。。。但是。。。
好吧。
下面是一系列网址缩水用脚本
大概twitter的TX们会用到
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-25 18:01:56 | 显示全部楼层
  1. #!/bin/bash
  2. # "tag" is unique and you get it appended like this
  3. # http://a.nf/your_tag
  4. # "tag" is already taken, you gotta give it up
  5. #
  6. # "validtill" date format::"2009-06-01"
  7. OPT_TEMP=$( getopt --longoptions pass:,dead:,tag:,help \
  8.         --name "a.nf url_shrinker" --options p:d:t:h \
  9.         -- "$@" ) ||
  10.         echo 'Valid options:: p|pass d|dead t|tag h|help'
  11. eval set -- "$OPT_TEMP"
  12. while : ;
  13. do
  14.         case "$1" in
  15.                 -p|--pass)        my_pass="$2" ; shift 2 ;;
  16.                 -d|--dead)        my_dead="$2" ; shift 2 ;;
  17.                 -t|--tag)        my_tag="$2"  ; shift 2 ;;
  18.                 -h|--help)        echo 'Valid options:: p|pass d|dead t|tag h|help' ; exit 0 ;;
  19.                 --)                shift ; break ;;
  20.                 *)                echo "what the..." ; exit 1 ;;
  21.         esac
  22. done
  23. for my_URL ;
  24. do
  25. curl -s -d url="$my_URL" -d pass="$my_pass" -d validtill="$my_dead" -d tag="$my_tag" 'http://a.nf/?module=ShortURL&file=Add&mode=API'
  26. echo    # just to tidy things up
  27. sleep 2 # it tells me to slow down, so i sleep for 2 sec
  28. done
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-25 18:05:06 | 显示全部楼层
  1. #!/bin/bash
  2. #帐号和apiKey(注册后在‘account’里看)
  3. my_login=
  4. my_key=
  5. # my_URL="$1"
  6. # set default behaviour
  7. format=text
  8. action=shorten
  9. action_aim=longUrl
  10. history=0
  11. help() {
  12.         echo
  13.         echo "Script for bit.ly, a Url shorten/restore service."
  14.         echo
  15.         echo "USAGE:: `basename "$0"` [options] [urls]"
  16.         echo "OPTIONs::"
  17.         echo '-a {s|e|i|ss} :: choose action: shorten,expand,info,stats'
  18.         echo '-l (1|0) :: set to 1 if you want it to be logged in your account history'
  19.         echo '-f {t|x|j} :: choose output format: text ONLY,xml,json'
  20.         echo '-h :: of course you know what it means'
  21.         echo
  22. }
  23. OPT_TEMP=$(getopt --longoptions action:,log:,format:,help \
  24.            --name "bit.ly_API" --options a:l:f:h \
  25.            -- "$@")
  26. eval set -- "$OPT_TEMP"
  27. while : ;do
  28. case "$1" in
  29. -a|--action)
  30.         case "$2" in
  31.                 s|shorten) action=shorten && action_aim=longUrl  ; shift 2 ;;
  32.                 e|expand)  action=expand  && action_aim=shortUrl ; shift 2 ;; # hash
  33.                 i|info)    action=info    && action_aim=shortUrl ; shift 2 ;; # hash keys
  34.                 ss|stats)  action=stats   && action_aim=shortUrl ; shift 2 ;; # hash
  35.                 *)         echo "** Wrong action, using $action" ; shift 2 ;;
  36.         esac
  37.         ;;
  38. -l|--log)
  39.         case "$2" in
  40.                 1|log)     history=1   ; shift 2 ;;
  41.                 0|nolog)   history=0   ; shift 2 ;;
  42.                 *)         echo "** Wrong log option, using $history" ; shift 2 ;;
  43.         esac
  44.         ;;
  45. -f|--format)
  46.         case "$2" in
  47.                 t|text)    format=text ; shift 2 ;;
  48.                 x|xml)     format=xml  ; shift 2 ;;
  49.                 j|json)    format=json ; shift 2 ;;
  50.                 *)         echo "** Wrong format, using $format" ; shift 2 ;;
  51.         esac
  52.         ;;
  53. -h|--help)
  54.         help ; exit 0
  55.         ;;
  56. --)
  57.         shift ; break
  58.         ;;
  59. esac
  60. done
  61. for arg; do
  62. echo "+ $action +-> $arg ::"
  63. # Long URLs should be URL-escaped
  64. arg=$( echo "$arg" | perl -MURI::Escape -lne 'print uri_escape($_)' )
  65. curl -s http://api.bit.ly/"$action"\?version\=2.0.1\&"$action_aim"\="$arg"\&login\="$my_login"\&apiKey\="$my_key"\&format\="$format"\&history\="$history"
  66. done
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-25 18:06:26 | 显示全部楼层
  1. #!/bin/bash
  2. [ -z "$1" ] && my_URL=$( xsel -o ) || my_URL="$1"
  3. my_URL=$( echo "$my_URL" | perl -MURI::Escape -lne 'print uri_escape($_)' )
  4. FMT="plain" # options are: xml json plain
  5. curl -s http://burnurl.com/\?url\="$my_URL"\&output\="$FMT"
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-25 18:07:42 | 显示全部楼层
  1. #!/bin/bash
  2. [ -z "$1" ] && my_URL=$( xsel -o ) || my_URL="$1"
  3. my_URL=$( echo "$my_URL" | perl -MURI::Escape -lne 'print uri_escape($_)' )
  4. curl -s http://is.gd/api.php\?longurl\="$my_URL"
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-25 18:08:47 | 显示全部楼层
  1. #!/bin/bash
  2. # append '-d' to restore original url from shortened url
  3. [ -z "$1" ] && my_URL=$( xsel -o ) || my_URL="$1"
  4. [ "$2" == "-d" ] && my_type=short_url || my_type=long_url
  5. curl -s http://r.im/api/index.cfm\?"$my_type"\="$my_URL" | tail -1
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-25 18:09:39 | 显示全部楼层
  1. #!/bin/bash
  2. # this focking silly site needs you to type "http://" or "https://"
  3. # One thing::shuurl provides a bigger thumbnail for preview before you actually visit the site.
  4. # with WOT security rating.
  5. [ -z "$1" ] && my_URL=$( xsel -o ) || my_URL="$1"
  6. curl -s  -d url="$my_URL" http://shuurl.com/index.php | sed '/<input type\=text value\='"'"'http:\/\/shuurl.com\/.*'"'"' size=50 class='"'"'hi'"'"'>/!d;' | cut -d\' -f 2
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-25 18:10:21 | 显示全部楼层
  1. #!/bin/bash
  2. [ "$1" == "" ] && my_url=$( xsel -o ) || my_url="$1"
  3. curl -s http://tinyurl.com/api-create.php\?url\="$my_url"
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-25 18:11:46 | 显示全部楼层
  1. #!/bin/bash
  2. my_URL=$( echo "$1" | perl -MURI::Escape -lne 'print uri_escape($_)' )
  3. curl -s http://u.nu/unu\-api\-simple\?url\="$my_URL"
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表