Skip to content

Instantly share code, notes, and snippets.

@KainokiKaede
Created February 27, 2014 04:01
Show Gist options
  • Save KainokiKaede/9244149 to your computer and use it in GitHub Desktop.
Save KainokiKaede/9244149 to your computer and use it in GitHub Desktop.
This is a Pythonista (for iOS) script to obtain short URL of your photo from Flickr photostream. Please download [base58](https://gist.github.com/mursts/2247355) module before use.
'''Usage: hold at your favorite photo
and copy the URL, then press Done.
'''
username = 'kainokikaede'
# Download base58 module from here and place it in the same directory:
# https://gist.github.com/mursts/2247355
from base58 import Base58
import re
import clipboard
import webbrowser
webbrowser.open('http://www.flickr.com/photos/{0}/'.format(username), modal=True )
url = clipboard.get()
photo_id = re.search('([0-9]{10,})', url).group(1) # nasty! plz help improving this.
encoded_id = Base58().encode(photo_id)
short_url = 'http://flic.kr/p/{0}'.format(encoded_id)
clipboard.set(short_url)
print 'copied: ', short_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment