My Ride
Started: Friday 24th May 2013 4:33pm
Distance: 17.46km
Duration: 00:39:15
Rest Time: 00:06:05
Climb: 124m
Max Speed: 51.48kmph
Average Speed: 26.68kmphInstagrams
-
Recent Posts
Recent Comments
- Arie on Tag Time: CakePHP Tag Plugin
- Paul on Sign Me Up A CakePHP User Registration Plugin
- Paul on Sign Me Up A CakePHP User Registration Plugin
- Watch The Big Bang Theory season 6 episode 13 on On My Tv: With Trakt.tv
- veloura et bellagenix on Ultimate Guestbook Tutorial: How to build a Guestbook with a honeypot, error checking, IP banning, pagination, e-mail notification and smilies with PHP and mySQL
Archives
- February 2013
- December 2012
- September 2012
- July 2012
- January 2012
- September 2011
- August 2011
- February 2011
- January 2011
- November 2010
- October 2010
- August 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
Categories
Meta
On My Tv: With Trakt.tv
July 28, 2012,
124 views
By now you’ve probably discovered I’m a big fan of trakt.tv, well scrobbling in general. I wan’t a way to show what I’m watching on my own blog in a way that isn’t the preformatting jpg’s trakt.tv provide (which is pretty cool in it’s own right).
So with my trakt.tv api key I decided to write up a quick ruby script to show what’s currently on my tv:
require "net/http"
require "uri"
require 'json'
require 'yaml'
uri = URI.parse("http://api.trakt.tv/user/watching.json/your_api_key/your_username")
response = Net::HTTP.get_response(uri)
result = JSON.parse response.body
if result.is_a?(Hash)
if result["show"]
title = "<div style="padding-left: 20px;"><h3>ON MY TV</h3><h5 style="margin-bottom: 10px;">#{result['show']['title']} - #{result['episode']['title']} (s#{result['episode']['season']}e#{result['episode']['number']})</h5>"
poster = result['show']['images']['poster'].gsub('.jpg', '-138.jpg')
title << "<img src="#{poster}" /></div>"
elsif result["movie"]
title = "<div style="padding-left: 20px;"><h3>ON MY TV</h3><h5 style="margin-bottom: 10px;">#{result['movie']['title']} (#{result['movie']['year']})</h5>"
poster = result['movie']['images']['poster'].gsub('.jpg', '-138.jpg')
title << "<img src="#{poster}" /></div>"
end
trakt = File.open("/path/to/text_file/playing.txt", "w")
trakt.write(title)
trakt.close
end
Three things to note here. You will need to update your api-key, username and the path to where you want the text file to be written.
Next up I poll trakt’s api every 5mins via:
crontab -e */5 * * * * ruby trakt.rb
Which updates the playlist.txt file. I then bring that into my blog with a simple:
echo file_get_contents('playlist.txt');
Let me know if you use this so I can checkout some new things to watch!






2 Comments
If you’re using trakt.tv, maybe you’re interested in TraktTV WordPress Widget. It’s free -check it out! If you like it, maybe write a review here
It’s a shame you don’t have a donate button! I’d certainly donate to this superb blog! I suppose for now i’ll settle for bookmarking and
adding your RSS feed to my Google account. I look forward to fresh updates and will talk
about this website with my Facebook group.
Talk soon!