-
-
Save joshthecoder/270103 to your computer and use it in GitHub Desktop.
This file contains 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 characters
#!/usr/bin/env python | |
# Usage: trim <url to shorten> | |
# A simple script that trims long urls using tr.im | |
# Requires the shorty library (http://github.com/joshthecoder/shorty-python). | |
# This script is public domain. | |
# Author: Joshua Roesslein | |
import sys | |
from shorty import Trim, ShortyError | |
try: | |
big_url = sys.argv[1] | |
except IndexError: | |
print 'Usage: trim <url>' | |
sys.exit(1) | |
trim = Trim() | |
try: | |
print trim.shrink(big_url) | |
except ShortyError, e: | |
print 'Error: %s' % e | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment