Created
August 27, 2011 06:53
-
-
Save geekgonecrazy/1175086 to your computer and use it in GitHub Desktop.
Short URL link Expander
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
#!/bin/python | |
########################## | |
# # | |
# Created by: Aaron Ogle # | |
# # | |
########################## | |
from sys import argv | |
import urllib2 | |
import gtk | |
import webbrowser | |
def destroy(widget, data=None): | |
gtk.main_quit() | |
def openbrowser(widget): | |
webbrowser.open(link.get_text()) | |
gtk.main_quit() | |
def expandurl(url): | |
expandurlpage = 'http://api.longurl.org/v2/expand?url=' + url | |
expanded = urllib2.urlopen(expandurlpage).read() | |
return expanded.split('[')[2].split(']')[0] | |
dialog = gtk.Window() | |
dialog.set_resizable(False) | |
dialogicon = dialog.render_icon(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_MENU) | |
dialog.set_icon(dialogicon) | |
dialog.set_title("Aaron's Link Expander") | |
dialog.set_position(gtk.WIN_POS_CENTER) | |
link = gtk.Label(expandurl(''.join(argv[1:len(argv)]))) | |
buttons = gtk.HBox() | |
openbutton = gtk.Button("Open") | |
openbutton.connect("clicked", openbrowser) | |
buttons.pack_start(openbutton, False) | |
rejectbutton = gtk.Button("Reject") | |
rejectbutton.connect("clicked", destroy) | |
buttons.pack_start(rejectbutton, False) | |
contents = gtk.VBox() | |
contents.pack_start(link) | |
contents.pack_start(buttons) | |
dialog.add(contents) | |
dialog.show_all() | |
gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment