Editorial Workflows

Movies

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: This workflow grabs IMDB data, movie poster and a Youtube movie trailer link based upon user input for movie title and year (optional). Add your own rating, tags and review/notes for a personal touch. Currently operational export services are Day One and Dropbox.

Note: Movies grabs the top google search result for "Youtube + Movie Name + Official Trailer". Infrequently, for example with movie sequels, the selected Youtube link will not be for the correct movie.

Version: 0.2

Corresponding Launch Center Pro Action:

http://bit.ly/Z8W7g1

Shared by: @scotplum_tech

Comments: Comment Feed (RSS)

@mrmicksmith — 19 Feb
Does this editorial workflow still work because when I run it I get the following error;

Traceback (most recent call last):
File "/var/mobile/Containers/Data/Application/6F4B4336-AF9B-40EE-A6ED-47E185FB68ED/Library/Application Support/Commands/workflow_action_tmp.py", line 27, in <module>
title, url = google(terms)
TypeError: 'NoneType' object is not iterable

+ Add Comment

Workflow Preview
Enter Movie ?
Title
Please enter the movie name:
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Set userMovie ?
Variable Name
userMovie
Value
Input
Enter Year ?
Title
What year was this movie made? (optional)
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Set userYear ?
Variable Name
userYear
Value
Input
Google Search and Return YouTube URL ?
Source Code
# Modified Google Search for Pythonista/Editorial (iOS)
# Searches Google and ouputs the URL of the first result to the workflow.
#
# Inspired by Brett Terpstra's SearchLink:
# http://brettterpstra.com/searchlink-automated-markdown-linking-improved/
 
import clipboard
import workflow

movie = workflow.get_variable('userMovie')
 
def google(terms):
	import requests
	import cgi
	url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&filter=1&rsz=small&q=' + cgi.escape(terms)
	r = requests.get(url, headers={'Referer': 'http://brettterpstra.com'}).json()
	if r:
		response_data = r.get('responseData', None)
		if response_data:
			result = response_data['results'][0]
			output_url = result['unescapedUrl']
			output_title = result['titleNoFormatting']
			return output_title, output_url
			
if __name__ == '__main__':
	terms = 'Youtube ' + movie + ' Official Trailer'
	title, url = google(terms)
	
workflow.set_output(url)
Set YouTube URL Variable ?
Variable Name
youtubeURL
Value
Input
Find / Replace ?
Find
watch?v=
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
embed/
Set Variable ?
Variable Name
youtubeEMBEDurl
Value
Input
Run IMDB Script ?
Source Code
#Importing the modules

from bs4 import BeautifulSoup
import sys
import urllib2
import re
import json
import workflow

#Import Editorial workflow variables

title = workflow.get_variable('userMovie')
year = workflow.get_variable('userYear')

#Search for spaces in the title string
raw_string = re.compile(r' ')

#Replace spaces with a plus sign
searchstring = raw_string.sub('+', title)

#IMDB query
url = "http://www.imdbapi.com/?t=" + searchstring + "&y="+year

#Backup API Link
#url = "http://www.myapifilms.com/imdb?title="searchstring"

request = urllib2.Request(url)

response = json.load(urllib2.urlopen(request))

result = json.dumps(response,indent=2)

workflow.set_output(result)
Remove Special Characters ?
Find
[{}"]
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Set Output to imdbMovie ?
Variable Name
imdbMovie
Value
Input
Grab Movie Title Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Title:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Title:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
MovieTitle
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab Movie Year Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Year:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Year:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
MovieYear
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab Movie Released Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Released:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Released:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
MovieReleased
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab Film Rating Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Rated:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Rated:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
MovieRated
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab Runtime Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Runtime:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Runtime:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
MovieRuntime
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab Actors Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Actors:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Actors:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
MovieActors
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab Director Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Director:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Director:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
MovieDirector
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab Awards Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Awards:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Awards:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
MovieAwards
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab IMDB ID Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
imdbID:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
imdbID:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
imdbID
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab IMDB Rating Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
imdbRating:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
imdbRating:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
imdbRating
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab IMDB Poster Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Poster
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Poster:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
imdbPoster
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab Movie Plot Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Plot:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Plot:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.rstrip(',')

workflow.set_output(action_out)
Set Variable ?
Variable Name
imdbPlot
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Grab Genres Block ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
imdbMovie
Filter Lines ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Genre:
Output Format
  • Only Lines
  • Lines and Ranges
Find / Replace ?
Find
Genre:
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove End of Line "," and add Tags ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#Strip comma on end of line
action_1 = action_in.rstrip(',')
#Replace internal comma with tag 
action_2 = action_1.replace(", ",", #Movie")
#Add tag to first genre
action_out = "#Movie"+action_2

workflow.set_output(action_out)
Set Variable ?
Variable Name
MovieGenres
Value
Input
Generate Text ?
Text
imdbMovie
…End If
Rate This Movie From List ?
Title
Your Rating:
List (Lines)
10 9 8 7 6 5 4 3 2 1
Multiple Selection
OFF
Show in Popover
OFF
Set MyRating ?
Variable Name
MyRating
Value
Input
Add Movie Review/Notes ?
Title
Your Review/Notes:
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Set MyReview ?
Variable Name
MyReview
Value
Input
Select Tags From List ?
Title
Your Tags:
List (Lines)
#MovieFavorite #MovieFlop #MovieKids #MovieNoKids #MoviePopcorn #MovieRecommend
Multiple Selection
ON
Show in Popover
OFF
Set Movie Tags ?
Variable Name
MovieTags
Value
Input
Select Output Applications ?
Title
Select Output(s)
List (Lines)
Dropbox Day One
Multiple Selection
ON
Show in Popover
OFF
Set OutputApplications ?
Variable Name
OutputApplications
Value
Input
Send Markdown File to Dropbox ?
Run the block if
OutputApplications
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Dropbox
Set Filename Variable ?
Variable Name
filename
Value
Apps/Editorial/Movies/MovieTitle (MovieYear).md
Generate Movie Tags ?
Text
MovieTags
Remove End of Line Script ?
Source Code
#coding: utf-8
import workflow
import string

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in.replace("#","<br>\#")

workflow.set_output(action_out)
Set Variable ?
Variable Name
DropboxMovieTags
Value
Input
Create Markdown Text File ?
File Name
%var:filename
In Dropbox
ON
New Text
[MovieTitle (MovieYear)](http://www.imdb.com/title/imdbID/) youtubeEMBEDurl |___Genre(s)___|MovieGenres| |---:|:---| |___Plot___|imdbPlot| |___Director___|MovieDirector| |___Actors___|MovieActors| |___Runtime___|MovieRuntime| |___Film Rating___|MovieRated| |___Released___|MovieReleased| |___Awards___|MovieAwards| |___IMDB Rating___|imdbRating| |___My Rating___|MyRating| |___Review/Notes___|MyReview| ![Poster](imdbPoster) \#Movie DropboxMovieTags
If File Does Not Exist
  • Create
  • Stop Workflow
…End If
Send to Day One ?
Run the block if
OutputApplications
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Day One
Generate Day One Markdown ?
Text
[MovieTitle (MovieYear)](http://www.imdb.com/title/imdbID/) youtubeURL |___Genre(s)___|MovieGenres| |---:|:---| |___Plot___|imdbPlot| |___Director___|MovieDirector| |___Actors___|MovieActors| |___Runtime___|MovieRuntime| |___Film Rating___|MovieRated| |___Released___|MovieReleased| |___Awards___|MovieAwards| |___IMDB Rating___|imdbRating| |___My Rating___|MyRating| |___Review/Notes___|MyReview| ![Poster](imdbPoster) #Movie MovieTags
Set Clipboard ?
URL Encode Clipboard ?
Source Code
import clipboard
import urllib

s = clipboard.get()

s = s.encode('utf-8')
s = urllib.quote(s, safe='')

clipboard.set(s)
Set Encoded Review ?
Variable Name
encodedDOReview
Value
Clipboard
Day One URL ?
Open in
  • In-App Browser
  • Default App / Safari
URL
dayone://post?entry=encodedDOReview
Tab
  • Last-used Tab
  • New Tab
  • Tab with ID:
Unique identifier
Wait until Loaded
OFF
Reveal Browser Automatically
ON
…End If