Quick'n'dirty twitter2xmbc hack to show #tatort related tweets on Sunday night

Download ttytter (command line twitter client):

# Get recent version of ttytter (old versions fail to auth)
wget http://www.floodgap.com/software/ttytter/ttytter.txt -O /usr/local/bin/ttytter && chmod +x /usr/local/bin/ttytter

Create the following script:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#!/bin/bash

# Get list of search result
TWEET=`ttytter -runcommand="/search #tatort"| tail -1 | python -c 'import json,sys; print json.dumps(sys.stdin.read())'`

# Prepare json request
echo "{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"GUI.ShowNotification\",\"params\":{\"title\":\"Tatort\",\"displaytime\":20000,\"message\":TWEET}}" | sed 's/TWEET/'"$TWEET"'/g' > /tmp/tmp.json

# Send request
curl -u xbmc:xbmc -H "Accept: application/json" -H "Content-type: application/json" -X POST --data @/tmp/tmp.json http://localhost:8080/jsonrpc

Btw. it is trivial to read the currently playing title from xbmc via curl as well to adapt to whatever one watches.


Want to comment? Send me an email to blog-comments-2018 at lemmster d.t de and I'll paste it here (I won't publish your address). Why don't you use an external comment service like disqus, you ask? Well, I like to keep this site under my control, comments included. You can use markdown to format your comment.