Browse Source

add tinyurl support

Signed-off-by: r4sas <r4sas@i2pmail.org>
dependabot/add-v2-config-file
R4SAS 5 years ago
parent
commit
92c38344e3
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 10
      pbincli/api.py
  2. 2
      pbincli/cli.py

10
pbincli/api.py

@ -136,11 +136,17 @@ class Shortener: @@ -136,11 +136,17 @@ class Shortener:
PBinCLIError("YOURLS: No status, statusCode or message fields in response! Received:\n{}".format(response))
elif self.api == 'clckru':
# from urllib.parse import quote_plus
request = {'url': url}
result = self.session.post(
url = "https://clck.ru/--",
proxies = self.proxy,
data = request)
print("Short Link:\t{}".format(result.text))
elif self.api == 'tinyurl':
request = {'url': url}
result = self.session.post(
url = "https://tinyurl.com/api-create.php",
proxies = self.proxy,
data = request)
print("Short Link:\t{}".format(result.text))

2
pbincli/cli.py

@ -38,7 +38,7 @@ def main(): @@ -38,7 +38,7 @@ def main():
choices=["zlib", "none"], help="set compression for paste (default: zlib). Note: works only on v2 paste format")
# URL shortener
send_parser.add_argument("-S", "--short", default=False, action="store_true", help="use URL shortener")
send_parser.add_argument("--short-api", default=argparse.SUPPRESS, action="store", choices=["clckru", "yourls"], help="API used by shortener service")
send_parser.add_argument("--short-api", default=argparse.SUPPRESS, action="store", choices=["clckru", "tinyurl", "yourls"], help="API used by shortener service")
send_parser.add_argument("--short-url", default=argparse.SUPPRESS, help="URL of shortener service API")
send_parser.add_argument("--short-user", default=argparse.SUPPRESS, help="Shortener username")
send_parser.add_argument("--short-pass", default=argparse.SUPPRESS, help="Shortener password")

Loading…
Cancel
Save