Editorial Workflows

Embed

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: Given a tweet URL in the clipboard, the workflow queries the Twitter API to get the HTML embed code for that tweet. The Twitter account configured in the iOS Settings is used for authentication. HTML is copied into the clipboard.

Shared by: viticci

Comments: Comment Feed (RSS)

anonymous — 03 Feb 2016
do you just write useless workflows that only work with your own personal settings and then upload them here over and over and over and over again???

+ Add Comment

Workflow Preview
Generate Text ?
Text
Clipboard
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Remove Duplicate Lines ?
Repeat… ?
Repeat with
  • Every Line
  • Every Match of Regular Expression:
Match Group
0 (entire match)
Reverse
OFF
If… ?
Run the block if
Clipboard
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
mobile.twitter.com
Generate Text ?
Text
Clipboard
Find / Replace ?
Find
mobile.twitter.com
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
twitter.com
…End If
Generate Text ?
Text
Input
Run Python Script ?
Source Code
import twitter
import json
import urllib
import requests
import clipboard
import workflow
import console

item = workflow.get_input()

if 'youtube.com' in item:
	parameters = {'url': item, 'maxwidth': '1500'}
	data = requests.get('http://www.youtube.com/oembed', params=parameters)
	if data.status_code == 200:
		embed = json.loads(data.text)
elif 'instagram.com' in item:
	parameters = {'url': item, 'maxwidth': '850', 'omitscript': 'false', 'beta': 'true', 'align': 'center'}
	data = requests.get('http://api.instagram.com/oembed', params=parameters)
	if data.status_code == 200:
		embed = json.loads(data.text)
elif 'vimeo.com' in item:
	parameters = {'url': item, 'maxwidth': '850', 'omitscript': 'false', 'byline': 'false', 'align': 'center'}
	data = requests.get('http://vimeo.com/api/oembed.json', params=parameters)
	if data.status_code == 200:
		embed = json.loads(data.text)
elif 'ifttt.com' in item:
	parameters = {'url': item, 'maxwidth': '850', 'omitscript': 'false', 'align': 'center'}
	data = requests.get('http://www.ifttt.com/oembed/', params=parameters)
	if data.status_code == 200:
		embed = json.loads(data.text)
elif 'twitter' in item:
	all_accounts = twitter.get_all_accounts()
	if len(all_accounts) >= 1:
		account = all_accounts[0]
		parameters = {'url': item, 'align': 'center', 'omit_script': 'false', 'maxwidth': '550'}
		status, data = twitter.request(account, 'https://api.twitter.com/1.1/statuses/oembed.json', 'GET', parameters)
		if status == 200:
			embed = json.loads(data)

clipboard.set(embed['html'])
console.hud_alert('Embed Generated')
Set Variable ?
Variable Name
embeds
Value
embeds Clipboard
…End Repeat
Generate Text ?
Text
embeds
Set Clipboard ?