Skip to content

Instantly share code, notes, and snippets.

@joshthecoder
Created January 6, 2010 07:19
Show Gist options
  • Save joshthecoder/270103 to your computer and use it in GitHub Desktop.
Save joshthecoder/270103 to your computer and use it in GitHub Desktop.
#!/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