fix using default answer on install (#175)
* fix using default answer on install * fix shortening and expanding URLs, simplifying Replace "ki.tc" with more stable and actually working "tinyurl.com" for shortening. Add separate service for expanding any shortened link. Simplifying the code.
This commit is contained in:
parent
b270518de8
commit
cddc232e7b
|
@ -1,3 +1,6 @@
|
||||||
|
# IDE
|
||||||
|
.idea
|
||||||
|
|
||||||
# Meta files
|
# Meta files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
|
@ -9,8 +9,9 @@ prefix="/usr/local"
|
||||||
|
|
||||||
askInstall()
|
askInstall()
|
||||||
{
|
{
|
||||||
echo -n "Do you wish to install $1 [Y/n]: "
|
read -p "Do you wish to install $1 [Y/n]: " answer
|
||||||
read -r answer
|
answer=${answer:-Y}
|
||||||
|
|
||||||
if [[ "$answer" == [Yy] ]]; then
|
if [[ "$answer" == [Yy] ]]; then
|
||||||
cd $1 || return 1
|
cd $1 || return 1
|
||||||
echo -n "Installing $1: "
|
echo -n "Installing $1: "
|
||||||
|
|
13
short/short
13
short/short
|
@ -136,22 +136,21 @@ expandURL()
|
||||||
else
|
else
|
||||||
url=$1
|
url=$1
|
||||||
fi
|
fi
|
||||||
response=$(httpGet http://ki.tc/short?url=$url)
|
response=$(httpGet https://unshorten.me/s/$url)
|
||||||
errorCheck=$(echo $response | python -c "import sys, json; print json.load(sys.stdin)['/short']['message']" 2> /dev/null )
|
errorCheck=$(echo $response)
|
||||||
if [[ $errorCheck == "Error in /short" ]]; then
|
if [[ $errorCheck == "Invalid Short URL" ]]; then
|
||||||
echo "Error: 404 could not find the website"
|
echo "Error: 404 could not find the website"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
returnedURL=$(echo $response | python -c "import sys, json; print json.load(sys.stdin)['/short']['destination']" 2> /dev/null )
|
returnedURL=$(echo $response)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shortenURL()
|
shortenURL()
|
||||||
{
|
{
|
||||||
newURL=$1
|
newURL=$1
|
||||||
if [[ $(echo $1 | grep -Eo "^[h]ttp[s]?://") == "" ]]; then newURL="http://"$1; fi
|
if [[ $(echo $1 | grep -Eo "^[h]ttp[s]?://") == "" ]]; then newURL="http://"$1; fi
|
||||||
response=$(curl -A curl -s -i -H "Content-Type: application/json" -X POST -d "{\"url\": \"$newURL\"}" http://ki.tc/ || exit 1)
|
response=$(httpGet http://tinyurl.com/api-create.php?url=$newURL)
|
||||||
returnedURL=$(echo $response | grep -Eo "http://ki.tc/[0-9a-zA-Z]*" | tail -n 1)
|
returnedURL=$(echo $response)
|
||||||
}
|
}
|
||||||
|
|
||||||
printResults()
|
printResults()
|
||||||
|
|
Loading…
Reference in New Issue