Created
April 27, 2013 17:45
-
-
Save spuder/5473927 to your computer and use it in GitHub Desktop.
Why wont Alfred accept this xml?
This file contains hidden or 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
import json | |
import urllib2 | |
url="http://data.mtgox.com/api/2/BTCUSD/money/ticker" | |
jsonURL=urllib2.urlopen(url) | |
jsonObject=json.load(jsonURL) | |
currentValue = jsonObject['data']['high']['display'] | |
# for some reason arg="+currentValue" doesn't work, but ..<subtitle>"+currentValue+"</subtitle> does | |
print ("<items><item uid='currentPrice' arg='+currentPrice+' valid='yes'><title>MtGox Current Price</title><subtitle>"+ currentValue +"</subtitle><icon>MtGox.png</icon></item></items>" ).encode('ascii', 'xmlcharrefreplace') | |
# if I change arg='+currentPrice+' to arg='42' then the workflow works perfectly. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed. Thanks to the comment on this forum.
arg='+currentPrice+' should be arg='"+currentPrice+"'
http://www.alfredforum.com/topic/2232-workflow-xml-does-not-accept-arg/#entry12531