Editorial Workflows

NowPlaying

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: Insert now playing info into current cursor position or replace selection.

Shared by: moyashi

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import objc_util

action_in = workflow.get_input()

NSBundle = objc_util.ObjCClass("NSBundle")
NSBundle.bundleWithPath_("/System/Library/Frameworks/MediaPlayer.framework").load()
MPMusicPlayerController = objc_util.ObjCClass("MPMusicPlayerController")
player = MPMusicPlayerController.iPodMusicPlayer()
now_playing = player.nowPlayingItem()
if now_playing:
	artist = now_playing.valueForProperty_("artist").UTF8String()
	title = now_playing.valueForProperty_("title").UTF8String()
	album = now_playing.valueForProperty_("albumTitle").UTF8String()
	if album:		
		action_out = "NowPlaying: {} by {} from {}".format(title, artist, album)
	else:
		action_out = "NowPlaying: {} by {}".format(title, artist)		
else:
	action_out = action_in

workflow.set_output(action_out)
Replace Selected Text ?
Replacement Text
Input