💾 Archived View for gmi.bacardi55.io › blog › 2017 › 02 › 22 › opening-tv-show-episode-via-kalliope captured on 2023-11-14 at 08:03:23. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Opening Tv show episode via Kalliope

Posted on 2017-02-22

Introduction

Today, a quick blog post about something I've put in place when I started playing with Kalliopé: asking kalliope to read videos from me.

The idea is simple: I have a raspberry pi in my living room plugged on my TV. On it kodi[1] is installed and a hard drive with some tv shows episode on it (legally acquired!). The goal was to simply ask Kalliope to find a file on kodi hard drive and run it on kodi, eg: "Launch tv show friends episode 101"

1: http://kodi.tv

The idea

First I asked myself if a neuron was useful or not here.

If I created a neuron, it would be either

Looking at my alternatives, I decided to manage it mainly via a simple shell script that would parse a simple text to find the name of the show, the episode and season. The script would then look over ssh to find the file name and then run a request against Kodi API to launch the file directly.

What does the shell script do

The script will receive in argument something like <TvShow_name> <season_number><episode_number>

Based on this three information, the script will connect via ssh and run a find command on to find a file containing either:

This are the 2 uses cases for my file name. So a couple of example:

Once a file is found (first one), the Kodi API is used to start this file. The API command looks like this:

curl -g 'http://kodi/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"file":"'"$result_string"'"}}}'

Where $result_string is the name of file (and thus the result of the find/grep command) and kodi is the hostname of your kodi server.

Setup

The shell script

Enable ssh access

First, make sure the user that runs kalliope can connect via ssh without password (via ssh key or by manually opening an ssh-agent connection before launching kalliope)

I leave you find some tuto online about this kind of setup, there is already a lot of documentation!

Install the script

The full script can be found here[2].

2: https://github.com/bacardi55/kalliope-starter55/blob/master/script/find-episode.sh

Download it, make it executable (chmod +x find-episode.sh) and put it somewhere accessible by the user running kalliope.

(In my case, in a script directory[3] in my kalliope starter kit[4]

3: https://github.com/bacardi55/kalliope-starter55/blob/master/script/

4: https://github.com/bacardi55/kalliope-starter55

Create a brain file

This is my example but you can change to your needs:

  - name: "Start-episode"
    signals:
      - order: "start episode {{ query }}"
    neurons:
      - shell:
          cmd: "/path/to/script/find-episode.sh "
          args:
             - query

The important thing is is to send the arguments as one query to the script that will manage the rest itself.

I could have created an order like start tv show {{tvshow}} season number {{season}} episode number {{number}} but the shell neuron didn't take arguments. I made an accepted PR[5] to be able to send an argument to the shell script.

5: https://github.com/kalliope-project/kalliope/pull/132/files

Maybe I should PR it again to add the ability to pass unlimited number of arguments that will be send to the shell script … But that then raise questions of orders, options, …

I hope this will work for you as well so you will be able to fire tv show episode without looking at your remote!

/gemlog/

Send me a gemini mention

send me an email!