Matsimitsu

A trakt.tv siri proxy plugin


Hi, Siri

With the siri proxy gem (https://github.com/plamoni/SiriProxy) creating your own fun stuff for iPhone 4s’s Siri is pretty straight forward.

Hi, Trakt

Trakt.tv has an amazing API and I wrote a small wrapper (see lib/trakt.tv) in the project) to fetch a users’s calendar for that night.

How i did it.

First off make sure you read all the documentation on the proxy github page, setting up the DNS server can be tricky if you don’t follow all the steps in the video.

Naming

Naming is very important for the siri proxy so make sure you do it right! The name you set in the siri proxy config should be the classname you extend the plugin from. The name downcased should be the gem name (with siriproxy prepended) It took me a while to figure out and get everything up and running.

Code

def generate_calendar_response(ref_id)
  object = SiriAddViews.new
  object.make_root(ref_id)
  object.views << SiriAssistantUtteranceView.new("Here is your trakt calendar!")

  episodes = Trakt::User::Calendar.new.results.first['episodes']
  episodes.each do |calendar_result|
    object.views << SiriAssistantUtteranceView.new(calendar_result['show']['title'])
  end
  object
end

listen_for /what's on tv tonight/i do
  send_object self.generate_calendar_response(last_ref_id)
  request_completed
end

The listen_for tells the proxy what words to match with the response from apple, the code in the block gets executed when the words match

In the generate_calendar_response i create a new view and add every episode i get from trakt to it. The whole thing gets returned to your iPhone and siri tells you the results :)

The result

The video below shows the result.

As always the code can be found on GitHub

More posts


Switching to Svelte

I have rewritten my middleman site to Svelte/SvelteKit, here's what I encountered.

Remote uploads with pre-signed URLs on Scaleway's object storage.

Or, make sure your headers match, otherwise you'll get a lot of strange errors.

Upload a file to an AWS pre-signed S3 url with RestClient.

Or, how something so simple cost me so much time.

Publish articles from iA Writer to your static site.

My hope with this project is that with less friction to write and publish a note/article, I'll do it more.

AppSignal

Kafka and Ruby, a Sidekiq lovestory

In today's article, we’ll cover performance from a different angle: The choices we made in our stack for AppSignal.