Editorial Workflows

Insert Affiliate Link

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Generate iTunes affiliate links and insert them in the editor.

Shared by: @viticci

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
If… ?
Run the block if
Clipboard
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
https://itunes.apple.com/
Generate Text ?
Text
Clipboard
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Set Variable ?
Variable Name
clip
Value
Input
Set Variable ?
Variable Name
sel
Value
Selected Text
Run Python Script ?
Source Code
from subprocess import check_output
import workflow

# 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 = 'YOUR AFFILIATE ID HERE'

# Get the URL from the variable
clipURL = workflow.get_variable('clip')
  
# 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&partnerId=30&siteID=%s' % (clipURL, myID)
else:
  itemURL = '%s?partnerId=30&siteID=%s' % (clipURL, myID)

# Write it out
workflow.set_output(itemURL)
Set Variable ?
Variable Name
afflink
Value
Input
Request Text Input ?
Title
What's the app's name?
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
appname
Value
Input
Replace Selected Text ?
Replacement Text
[sel](afflink "appname")
…End If