Last active
February 16, 2018 18:13
-
-
Save loyd/9449618 to your computer and use it in GitHub Desktop.
Revisions
-
loyd renamed this gist
Jan 4, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ EXTENSION= # forced extension for upload usage() { echo "Usage:" echo " $(basename $0) [-l|s|c] [-e <ext>] [files...] Upload files (use '-' for stdin)" echo " $(basename $0) [-h|v] Show meta information" echo "Options:" echo " -l Make long-time links" echo " -s Make short links (uses tinyurl.com)" -
loyd revised this gist
May 18, 2014 . 1 changed file with 16 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,27 @@ #!/bin/bash # ovrload.ru file uploader # ovrload — former troloload VERSION='v0.1.3' URL='http://ovrload.ru' SHORTER_URL='http://tinyurl.com' FAILURES=0 # number of upload fails LONGTIME=0 # whether to make long-time links SHORT=0 # whether to make short links COPY=0 # whether to copy link EXTENSION= # forced extension for upload usage() { echo "Usage:" echo " $(basename $0) [-l|s|c] [-e <ext>] [files...] Upload files (use '-' for stdin)" echo " $(basename $0) [-h|v] Show meta information" echo "Options:" echo " -l Make long-time links" echo " -s Make short links (uses tinyurl.com)" echo " -e Forced extenstion (good with stdin)" echo " -h Show this message and quit" echo " -c Copy link" echo " -v Show version ($VERSION) number and quit" } @@ -51,7 +54,7 @@ shorten() { } ## Analysis of options while getopts ":lsce:hv" OPT; do case "$OPT" in l) LONGTIME=1 @@ -65,6 +68,9 @@ while getopts ":lse:hv" OPT; do EXTENSION=".$EXTENSION" fi ;; c) COPY=1 ;; h) usage exit 0 @@ -96,7 +102,11 @@ for FILE; do fi if [[ "$RESULT" =~ ^http:// ]]; then if [ $COPY -ne 0 ]; then echo -n "$RESULT" | xclip -filter -selection clipboard else echo "$FILE: $RESULT" fi else echo "$FILE: fail" let "FAILURES+=1" -
loyd revised this gist
Mar 9, 2014 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # troloload.ru file uploader VERSION='v0.1.1' URL='http://troloload.ru' SHORTER_URL='http://tinyurl.com' @@ -12,8 +12,8 @@ EXTENSION= # forced extension for upload usage() { echo "Usage:" echo " $(basename $0) [-l|s] [-e <ext>] [files...] Upload files (use '-' for stdin)" echo " $(basename $0) [-h|v] Show meta information" echo "Options:" echo " -l Make long-time links" echo " -s Make short links (uses tinyurl.com)" @@ -96,10 +96,10 @@ for FILE; do fi if [[ "$RESULT" =~ ^http:// ]]; then echo "$FILE: $RESULT" else echo "$FILE: fail" let "FAILURES+=1" fi done -
loyd created this gist
Mar 9, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,106 @@ #!/bin/bash # troloload.ru file uploader VERSION='v0.1' URL='http://troloload.ru' SHORTER_URL='http://tinyurl.com' FAILURES=0 # number of upload fails LONGTIME=0 # whether to make long-time links SHORT=0 # whether to make short links EXTENSION= # forced extension for upload usage() { echo "Usage:" echo " $0 [-l|s] [-e <ext>] [files...] Upload files (use '-' for stdin)" echo " $0 [-h|v] Show meta information" echo "Options:" echo " -l Make long-time links" echo " -s Make short links (uses tinyurl.com)" echo " -e Forced extenstion (good with stdin)" echo " -h Show this message and quit" echo " -v Show version ($VERSION) number and quit" } gen_name() { local ext="$EXTENSION" if [ -z "$ext" ] && [ "$1" != '-' ]; then local filename=$(basename "$1") ext=".${filename##*.}" # No extenstion if [ "$ext" == ".$filename" ]; then ext=''; fi fi printf "$(< /dev/urandom tr -dc a-zA-Z0-9 | head -c16)$ext" } upload() { local name=$(gen_name "$1") local link=$(curl -sL -F 'fileframe=true' \ -F "file=@$1;filename=$name" \ -F "temp=$((LONGTIME == 0))" \ "$URL" | grep -o "\"$URL.*\"" | head -n 1) echo "${link:1:-1}" } shorten() { echo $(curl -s "$SHORTER_URL/api-create.php?url=$1") } ## Analysis of options while getopts ":lse:hv" OPT; do case "$OPT" in l) LONGTIME=1 ;; s) SHORT=1 ;; e) EXTENSION=$OPTARG if [ "${EXTENSION:0:1}" != '.' ]; then EXTENSION=".$EXTENSION" fi ;; h) usage exit 0 ;; v) echo $VERSION exit 0 ;; \?) usage >&2 exit 42 ;; esac done shift $((OPTIND-1)) ## Process files if [ $# -eq 0 ]; then usage >&2 exit 42; fi for FILE; do RESULT=$(upload "$FILE") if [ "$FILE" == '-' ]; then FILE='(stdin)'; fi if [[ "$RESULT" =~ ^"$URL" ]] && [ $SHORT -ne 0 ]; then RESULT=$(shorten "$RESULT") fi if [[ "$RESULT" =~ ^http:// ]]; then echo "$FILE: $RESULT" else echo "$FILE: fail" let "FAILURES+=1" fi done exit $FAILURES