Skip to content

Commit

Permalink
Changing api URL to awau.moe
Browse files Browse the repository at this point in the history
  • Loading branch information
OkashiOdayakana committed Dec 18, 2016
2 parents 9219993 + 3c2bb03 commit 708be44
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 97 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A basic example/uploader for uploading to owo.what-th.is's image server. The aim was to have a script that allowed for users of all operating systems (that werent already supported by ShareX) to also be able to upload to whats-th.is related products.

Thank you to [jomo](https://github.com/jomo/) and his script [jomo/imgur-screenshot](https://github.com/jomo/imgur-screenshot), to which snippits and borrowing code guided me to improving my own script. This script wouldnt be anywhere near what it is today without his efforts.
Thank you to [jomo](https://github.com/jomo/) and his script [jomo/imgur-screenshot](https://github.com/jomo/imgur-screenshot), to which taking snippets and borrowing code has guided me to improving my own script. This script wouldn't be anywhere near what it is today without his efforts.

# Install

Expand All @@ -13,18 +13,18 @@ Thank you to [jomo](https://github.com/jomo/) and his script [jomo/imgur-screens
| MacOS | Terminal Notifier | Default OSX Notifications suck and barely work, this is a workaround for that.
| | Screencapture | Comes default with OSX and is the client that you use when you press CMD + Shift 3 or CMD + Shift 4.
| | Pbcopy | Comes default with OSX and is used to copy things to your clipboard.
| | GREP | Comes standard with all UNIX os's and is used to (in this case) decipher JSON.
| | cURL | Comes standard with all UNIX os's and is used to (in this case) upload to the owo server.
| | GREP | Comes standard with all UNIX OSes and is used to (in this case) decipher JSON.
| | cURL | Comes standard with all UNIX OSes and is used to (in this case) upload to the owo server.
| Linux | Notify-Send | Default Linux barely has any, if at all, notification support from terminal. This is a workaround.
| | Maim | A rich screenshotting client, that better than what comes default with Linux.
| | XClip | Comes default with most Unix based os's and allows for things to copied to clipboards.
| | GREP | Comes standard with all UNIX os's and is used to (in this case) decipher JSON.
| | cURL | Comes standard with all UNIX os's and is used to (in this case) upload to the owo server.
| | XClip | Comes default with most UNIX based OSes and allows for things to copied to clipboards.
| | GREP | Comes standard with all UNIX OSes and is used to (in this case) decipher JSON.
| | cURL | Comes standard with all UNIX OSes and is used to (in this case) upload to the owo server.

##instructions

1. Clone the repo with `git clone https://github.com/whats-this/owo.sh.git`
2. Make sure `script.sh` has permissions, `chmod a+x script.sh`.
2. Make sure `script.sh` has permissions: `chmod a+x script.sh`.
3. Download the dependencies, you can check what you need with `./script.sh --check`
4. Put your token inside of `{HOME}/Documents/.owo/conf.cfg`, `nano {HOME}/Documents/.owo/conf.cfg`.
5. Run the command `./setup.sh` to add the owo command.
Expand Down
8 changes: 7 additions & 1 deletion conf.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
# In here you can find multiple values to which you can edit
# in order to fit what you need. Please make sure you know what
# you are editing before you change it, all errors can be
# reffered to https://github.com/whats-this/owo.sh/wiki.
# referred to https://github.com/whats-this/owo.sh/wiki.

# DO NOT CHANGE. Used to track when new values are added.
config_version=1

# -------------------------------------
# owo.whats-th.is
# -------------------------------------

userkey=""
debug=false


# -------------------------------------
Expand All @@ -29,9 +33,11 @@ userkey=""
scr_directory=Screenshots
scr_filename="shot_`date '+%Y-%m-%d_%H-%M-%S'`.png"
scr_path=${HOME}/Documents/$directoryname/
scr_copy=false


# -------------------------------------
# urlshortener
# -------------------------------------

url_copy=false
131 changes: 60 additions & 71 deletions script.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,46 @@
# and url shortener component of whats-th.is. Through this you can do
# plethora of actions.
#
# A big thankyou to jomo/imgur-screenshot to which i've edited parts
# A big thank you to jomo/imgur-screenshot to which I've edited parts
# of his script into my own.

current_version="v0.0.7"
current_version="v0.0.10"
config_version=1

##################################

if [ ! -d "${HOME}/.config/owo/" ]; then
echo "INFO : Could not find file, downloading..."
mkdir -p ${HOME}/.config/owo/
curl -s -o ${HOME}/.config/owo/conf.cfg https://cdn.rawgit.com/whats-this/owo.sh/master/conf.cfg
owodir="$HOME/.config/owo"

if [ ! -d $owodir ]; then
echo "INFO : Could not find config directory. Please run setup.sh"
exit 1
fi
source ${HOME}/.config/owo/conf.cfg
source $owodir/conf.cfg

key=$userkey >&2

directoryname=$scr_directory >&2
filename=$scr_filename >&2
path=$scr_path >&2

print_debug=$debug >&2

##################################

function is_mac() {
uname | grep -q "Darwin"
}

function check_key() {
if [ -z "$key" ]; then
echo "INFO : \$key not found, please enter your key."
read key
if [[ -z "$key" ]]; then
check_key
fi
function check_key() {https://raw.githubusercontent.com/whats-this/owo.sh/master/script.sh
exit 1
fi
}

function notify() {
if is_mac; then
terminal-notifier -title owo.whats-th.is -message "${1}" -appIcon $owodir/icon.icns
else
notify-send owo.whats-th.is "${1}" -i $owodir/icon.png
fi
}

Expand All @@ -56,12 +63,12 @@ function check_key() {
if [ "${1}" = "--h" ] || [ "${1}" = "--help" ]; then
echo "usage: ${0} [-h | --check | -v]"
echo ""
echo " -h --help Show this help screen to you."
echo " -v --version Show current application version."
echo " -c --check Checks if dependencies are installed."
echo " --update Checks if theres an update available."
echo " -l --shorten Begins the url shortening process."
echo " -s --screenshot Begins the screenshot uploading process."
echo " --h --help Show this help screen to you."
echo " --v --version Show current application version."
echo " -c --check Checks if dependencies are installed."
echo " --update Checks if theres an update available."
echo " -l --shorten Begins the url shortening process."
echo " -s --screenshot Begins the screenshot uploading process."
echo ""
exit 0
fi
Expand All @@ -76,13 +83,8 @@ fi
##################################

if [ "${1}" = "-c" ] || [ "${1}" = "--check" ]; then
(which grep &>/dev/null && echo "FOUND : found grep") || echo "ERROR : grep not found"
if is_mac; then
if which terminal-notifier &>/dev/null; then
echo "FOUND : found terminal-notifier"
else
echo "ERROR : terminal-notifier not found"
fi
(which terminal-notifier &>/dev/null && echo "FOUND : found terminal-notifier") || echo "ERROR : terminal-notifier not found"
(which screencapture &>/dev/null && echo "FOUND : found screencapture") || echo "ERROR : screencapture not found"
(which pbcopy &>/dev/null && echo "FOUND : found pbcopy") || echo "ERROR : pbcopy not found"
else
Expand All @@ -91,6 +93,7 @@ if [ "${1}" = "-c" ] || [ "${1}" = "--check" ]; then
(which xclip &>/dev/null && echo "FOUND : found xclip") || echo "ERROR : xclip not found"
fi
(which curl &>/dev/null && echo "FOUND : found curl") || echo "ERROR : curl not found"
(which grep &>/dev/null && echo "FOUND : found grep") || echo "ERROR : grep not found"
exit 0
fi

Expand Down Expand Up @@ -118,16 +121,13 @@ if [ "${1}" = "--update" ]; then
fi

##################################

if [ "${1}" = "-l" ] || [ "${1}" = "--shorten" ]; then

check_key

if [ -z "${2}" ]; then
if is_mac; then
terminal-notifier -title owo.whats-th.is -message "Please enter the URL you wish to shorten." -appIcon ./icon.icns
else
notify-send owoshorten "Please enter the URL you wish to shorten."
fi
notify "Please enter the URL you wish to shorten."

echo "INFO : Please enter the URL you wish to shorten."
read url
Expand All @@ -144,21 +144,16 @@ if [ "${1}" = "-l" ] || [ "${1}" = "--shorten" ]; then
if grep -q "https://" <<< "${result}"; then
if is_mac; then
echo $result | pbcopy
terminal-notifier -title owo.whats-th.is -message "Copied the link to the keyboard." -appIcon ./icon.icns
else
echo $result | xclip -i -sel c -f |xclip -i -sel p
notify-send owo.whats-th.is "Copied the link to the keyboard."
exit
echo $result | xclip -i -sel c -f | xclip -i -sel p
fi
notify "Copied the link to the keyboard."
exit 0
else
notify-send owoshorten "Shortening failed!"
notify "Shortening failed!"
fi
else
if is_mac; then
terminal-notifier -title owo.whats-th.is -message "Link is not valid!" -appIcon ./icon.icns
else
notify-send owoshorten "Link is not valid!"
fi
notify "Link is not valid!"
echo "ERROR : Link is not valid!"
fi

Expand All @@ -172,11 +167,7 @@ if [ "${1}" = "-s" ] || [ "${1}" = "--screenshot" ]; then
check_key

# Alert the user that the upload has begun.
if is_mac; then
terminal-notifier -title owo.whats-th.is -message "Select an area to begin the upload." -appIcon ./icon.icns
else
notify-send owo.whats-th.is "Select an Area to Upload."
fi
notify "Select an area to begin the upload."

# Begin our screen capture.
if is_mac; then
Expand All @@ -192,42 +183,34 @@ if [ "${1}" = "-s" ] || [ "${1}" = "--screenshot" ]; then
entry=$path$filename
upload=$(curl -F "files[]=@"$entry";type=image/png" https://api.awau.moe/upload/pomf?key="$key")

if is_mac; then
if egrep -q '"success":\s*true' <<< "${upload}"; then
item="$(egrep -o '"url":\s*"[^"]+"' <<<"${upload}" | cut -d "\"" -f 4)"
if [ "$print_debug" = true ] ; then
echo $upload
fi

if egrep -q '"success":\s*true' <<< "${upload}"; then
item="$(egrep -o '"url":\s*"[^"]+"' <<<"${upload}" | cut -d "\"" -f 4)"
if is_mac; then
echo "https://owo.whats-th.is/$item" | pbcopy
terminal-notifier -title "Upload complete!" -message "Copied the link to your clipboard." -appIcon ./icon.icns
else
terminal-notifier -title "Upload failed!" -message "Please check your logs for details." -appIcon ./icon.icns
echo "UPLOAD FAILED" > log.txt
echo "The server left the following response" >> log.txt
echo "--------------------------------------" >> log.txt
echo " " >> log.txt
echo " " $upload >> log.txt
fi
else
if egrep -q '"success":\s*true' <<< "${upload}"; then
item="$(egrep -o '"url":\s*"[^"]+"' <<<"${upload}" | cut -d "\"" -f 4)"
echo "https://owo.whats-th.is/$item" | xclip -i -sel c -f | xclip -i -sel p
notify-send -a owoscreenshot "Upload complete" "Copied the link to your clipboard." -t 500
else
notify-send -a owoscreenshot "Upload Failed" "Please check your logs for details." -i "$errnum" -t 500
echo "UPLOAD FAILED" > log.txt
echo "The server left the following response" >> log.txt
echo "--------------------------------------" >> log.txt
echo " " >> log.txt
echo " " $upload >> log.txt
fi
notify "Upload complete! Copied the link to your clipboard."
else
notify "Upload failed! Please check your logs ($owodir/log.txt) for details."
echo "UPLOAD FAILED" > $owodir/log.txt
echo "The server left the following response" >> $owodir/log.txt
echo "--------------------------------------" >> $owodir/log.txt
echo " " >> $owodir/log.txt
echo " " $upload >> $owodir/log.txt
fi

exit 0

fi

##################################

if [ ! -n "$1" ]; then
echo "ERROR : Incorrect Syntax."
echo "ERROR : Sorry, but thats incorrect syntax."
echo "ERROR : Please use \"owo file.png\""
exit 1
fi
Expand All @@ -236,5 +219,11 @@ check_key

entry=$1
upload=$(curl -F "files[]=@"$entry";type=image/png" https://api.awau.moe/upload/pomf?key="$key")
item="$(egrep -o '"url":\s*"[^"]+"' <<<"${upload}" | cut -d "\"" -f 4)"

if [ "$print_debug" = true ] ; then
echo $upload
fi

echo "RESP : " $upload
echo $upload | xclip -i -sel c -f | xclip -i -sel p
echo "URL : https://owo.whats-th.is/$item"
43 changes: 25 additions & 18 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,53 @@

##################################

#if [ "$EUID" -ne 0 ]; then
# echo "ERROR : You need to run the script as sudo."
# echo "ERROR : It should look like \"sudo ./setup.sh\""
# exit
#fi
if [ $(id -u) -ne 0 ]; then
echo "ERROR : You need to run the script as sudo."
echo "ERROR : It should look like \"sudo ./setup.sh\""
exit 1
fi

##################################

if [ "${1}" = "--uninstall" ]; then

rm /usr/local/bin/owo
echo "INFO : Uninstallation finished!"
echo "INFO : Uninstallation of owo.sh finished!"
echo "INFO : However APT packages have not been removed."

exit
exit 0
fi

##################################

#Create a symbolic link to /usr/local/bin
scriptdir=$(dirname $(which $0))
owodir="$HOME/.config/owo"
if [ ! -d "$owodir" ]; then
mkdir "$HOME/.config/owo"
cp -r ./* $HOME/.config/owo

if [ ! -d $owodir ]; then
mkdir $owodir
cp -r $scriptdir/* $owodir
fi

sudo ln -s $HOME/.config/owo/script.sh /usr/local/bin/owo
# Give directory ownership to the actual user
chown -R $(who am i | awk '{print $1}') $owodir

# Create a symbolic link to /usr/local/bin
ln -s $owodir/script.sh /usr/local/bin/owo

function is_mac() {
uname | grep -q "Darwin"
uname | grep -q "Darwin"
}


# Install dependencies
if is_mac; then
echo ""
echo "INFO : Dependencies are unavaliable for Mac."
echo "INFO : Please run \"owo --check\" to check later on."
else
(which notify-send &>/dev/null && echo "FOUND : found screencapture") || apt-get install notify-send
(which maim &>/dev/null && echo "FOUND : found maim") || apt-get install notify-send
(which xclip &>/dev/null && echo "FOUND : found xclip") || apt-get install xclip
(which notify-send &>/dev/null && echo "FOUND : found screencapture") || apt-get install notify-send
(which maim &>/dev/null && echo "FOUND : found maim") || apt-get install maim
(which xclip &>/dev/null && echo "FOUND : found xclip") || apt-get install xclip
fi

# Tell the user its done!
echo "INFO : Installation finished. Use it like \"owo file.png\""
echo "INFO : Installation finished of owo.sh. Use it like \"owo file.png\""

0 comments on commit 708be44

Please sign in to comment.