l e m m s t e r . d e
  • Home
  • impressum
  • talks
  • Categories
  • Tags
  • Archives

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.


Published

Nov 27, 2013

Category

hacks

Contact

  • Powered by Pelican. Theme: Elegant