Created
May 15, 2013 02:14
-
-
Save rkoopmann/5581204 to your computer and use it in GitHub Desktop.
For creating affiliate links for iTunes content with Pythonista for iOS.
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/python | |
# from subprocess import check_output | |
from sys import stdout | |
import clipboard | |
import webbrowser | |
# The procedure followed here is taken from Apple's instructions for for linking: | |
# http://www.apple.com/itunes/affiliates/resources/documentation/linking-to-the-itunes-music-store.html | |
# My affiliate ID. | |
myID = 'Oixde*akY4Q' # TODO: you will want to change this to be *your* affiliate ID. | |
safariPrefix = 'safari-' # make the URL open in Safari rather than built in browser. | |
# Get the URL from the clipboard. | |
clipURL = clipboard.get() | |
# Add my ID and the partnerId parameter to the URL. If there are already | |
# queries, add them as additional ones; if not, add them as the only ones. | |
if '?' in clipURL: | |
itemURL = '%s%s&partnerId=30&siteID=%s' % (safariPrefix, clipURL, myID) | |
else: | |
itemURL = '%s%s?partnerId=30&siteID=%s' % (safariPrefix, clipURL, myID) | |
# Open the App Store | |
webbrowser.open(itemURL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment