Author Topic: Get movie soundtrack info (a Kodi + Tunefind solution)  (Read 2255 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Get movie soundtrack info (a Kodi + Tunefind solution)
« on: December 11, 2016, 02:43:58 PM »
For Kodi users, assuming your Kodi events are working properly in VC, the following command group retrieves movie soundtrack information from Tunefind -- no API key needed.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.0-->
<commandGroup open="True" name="Tunefind movie scrape (no API key needed)" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="493" name="store now playing movie info" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This command should execute automatically when you start watching a movie in Kodi.">
    <action>
      <cmdType>XJson.Raw</cmdType>
      <params>
        <param>Player.GetItem</param>
        <param>"playerid":1,  "properties": ["title","year"]</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>XJson.ParseTokens</cmdType>
      <params>
        <param>{item.title}-{item.year}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>movieinfo</param>
        <param>http://www.tunefind.com/movie/{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>^(.*?)-\d{4}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>movietitle</param>
        <param>{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <event>XBMC.Player.OnPlay.movie</event>
    <event>Kodi.Player.OnPlay.movie</event>
  </command>
  <command id="84" name="Tell me about this movie soundtrack" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>One moment please</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>{var.movieinfo}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Tools.Decode.HTML</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>class="SongTitle.*?&gt;(.*?)&lt;/a&gt;.*?href="/artist/.*?"&gt;(.*?)&lt;/</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>Tunefind lists {#M} songs on the {var.movietitle} soundtrack:</param>
            <param>10000</param>
            <param>-5</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.AddText</cmdType>
          <params>
            <param>{i}. "{Match.{i}.1}", by {Match.{i}.2}</param>
          </params>
          <cmdRepeat>15</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.SpeakSync</cmdType>
          <params>
            <param>Tune find lists {#M} songs on this soundtrack</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Would you like to open Tune find?</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.TriggerEvent</cmdType>
          <params>
            <param>tunefind</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>I'm sorry, I couldn't find soundtrack information for {var.movietitle} on Tune find.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>Attempt to open this page failed.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <phrase>Tell me about this movie soundtrack</phrase>
  </command>
  <command id="485" name="show me the movie soundtrack (in Tunefind)" enabled="true" alwaysOn="False" confirm="True" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>OK. Launching Tune Find</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.OpenURL</cmdType>
      <params>
        <param>{var.movieinfo}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>show me the movie soundtrack</phrase>
    <event>tunefind</event>
  </command>
</commandGroup>

When you start playing a movie in Kodi, VC stores the information needed to scrape soundtrack data from the Tunefind website in 2 variables. (So, if you then watch a different movie, these variables will be overwritten.)

Then at any time you can say, "Tell me about this movie soundtrack" and it will try to find that information on Tunefind.

Of course, you can change the wording of the voice command if you like.

If successful, it will let you know what it found, and also ask if you want to open the Tunefind website. Otherwise it tells you that it couldn't retrieve soundtrack info from Tunefind.

TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

MMatty1

  • Jr. Member
  • **
  • Posts: 40
  • Karma: 4
    • View Profile
Re: Get movie soundtrack info (a Kodi + Tunefind solution)
« Reply #1 on: December 12, 2016, 05:18:35 AM »
 ;) ;) ;) ;) Awesome work thanks alot Naomi.. :)