This python script can be used with command line or as import from another script.
For additional information call:
python ./tinylink.py -h
Short | Expand | Description |
---|---|---|
-h | --help | Help menu |
-v | --verbose | Enable verbosity |
-c | --check | Check given URL |
-a | --api | YOURLS API URL |
-k | --key | YOURLS API key |
-u | --url | Short/expand URL |
------- | ----------- | -------------------- |
-s | --short | Short given URL |
-n | --name | Name for short URL |
------- | ----------- | -------------------- |
-e | --expand | Expand given URL |
# Short link without url check
python ./tinylink.py -a https://YOUR-API-URL/yourls-api.php -k API-KEY -u https://github.com/0x007e -s
# Short link with url check -c
python ./tinylink.py -a https://YOUR-API-URL/yourls-api.php -k API-KEY -u https://github.com/0x007e -s -c
# Short link with specific name -n
python ./tinylink.py -a https://YOUR-API-URL/yourls-api.php -k API-KEY -u https://github.com/0x007e -s -n linkname
# Return value is shorten URL or error message
# Expand a link without url check
python ./tinylink.py -a https://YOUR-API-URL/yourls-api.php -k API-KEY -u https://YOUR-API-UR/3jd7ed -e
# Expand link with url check -c
python ./tinylink.py -a https://YOUR-API-URL/yourls-api.php -k API-KEY -u https://YOUR-API-UR/3jd7ed -e -c
# Return value is expanded URL or error message
API: str = "https://YOUR-API-UR/"
KEY: str = "YOURKEY"
# ------------------------------------------------------------------------------
# Short link without url check
print(tinylink.short("https://github.com/0x007e"))
# Short link with url check
print(tinylink.short("https://github.com/0x007e", check=True))
# Short link with url check and specific name
print(tinylink.short("https://github.com/0x007e", check=True, keyword="MYLINK"))
# ------------------------------------------------------------------------------
# Expand link without url check
print(tinylink.expand("https://YOUR-API-UR/3jd7ed"))
# Expand link with url check
print(tinylink.expand("https://YOUR-API-UR/3jd7ed", check=True))
# ------------------------------------------------------------------------------