VoxCommando
VoxNastics (User Guides and Mods) => XML Exchange => Topic started by: nime5ter on November 04, 2016, 12:19:51 PM
-
TUNEFIND NO LONGER OFFERS A FREE API.
The minimum plan starts at $25/month.
Now that TV shows are often creative with their soundtracks, we keep wondering what songs (or artists) are playing while watching TV.
I just discovered TuneFind (http://www.tunefind.com/about), which has an API we can use in VC. The standard API is free, though it seems to have a few limitations.
I've been testing it out by grabbing show info from Kodi when an episode is playing, and then passing it to Tunefind to get episode soundtrack data (using our trusty Scrape and Regex actions).
The data is crowd-sourced. The site seems quite good for U.S. shows and possibly UK TV, but my test of our non-English-language TV shows suggests it's probably not great for global content.
If anyone is interested, let me know and I'll post some details about how I've implemented it. As always, there are different ways one could approach it.
There are a number of steps, so I don't want to spend half an hour posting an explanation unless it's wortwhile to others. :biglaugh (I live and learn!)
cheers.
-
Kodi-specific implementation:
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.0-->
<commandGroup open="True" name="TuneFind API commands for Kodi" enabled="True" prefix="" priority="0" requiredProcess="" description="">
<command id="111" name="Tell me about the soundtrack" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Song data is used under license from TuneFind LLC. Here I use XJson.ParseTokens to parse json data from TuneFind.">
<action>
<cmdType>PY.ExecString</cmdType>
<params>
<param>result = {var.episode}-1</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>ep_array</param>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Scrape</cmdType>
<params>
<param>https://www.tunefind.com/api/v1/show/{var.show}/season-{var.season}</param>
<param>YOUR TUNEFIND API USERNAME</param>
<param>YOUR TUNEFIND API PASSWORD</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>XJson.ParseTokens</cmdType>
<params>
<param>{episodes[{var.ep_array}].tunefind_api_url}</param>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Scrape</cmdType>
<params>
<param>{LastResult}</param>
<param>YOUR TUNEFIND API USERNAME</param>
<param>YOUR TUNEFIND API PASSWORD</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegEx</cmdType>
<params>
<param>","name":"(.*?)",.*?"artist.*?"name":"(.*?)"</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<if ifBlockDisabled="False" ifNot="False">
<ifType>LastActionSuccess</ifType>
<ifParams>&&</ifParams>
<then>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>Songs in the episode "{var.ep_title}", season {var.season} of {var.show_title}:</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.AddText</cmdType>
<params>
<param>"{Match.{i}.1}", by {Match.{i}.2}</param>
</params>
<cmdRepeat>{#M}</cmdRepeat>
</action>
<action>
<cmdType>TTS.SpeakSync</cmdType>
<params>
<param>Songs in this episode of {var.show_title} are:</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>{i}. {Match.{i}.1}, by {Match.{i}.2}</param>
</params>
<cmdRepeat>{#M}</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>Sorry. I couldn't find soundtrack information for that episode.</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>Sorry. I couldn't find soundtrack information for that episode.</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
<phrase>tell me about the soundtrack</phrase>
</command>
<command id="127" name="show me the soundtrack (in Tunefind)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description=" ">
<action>
<cmdType>PY.ExecString</cmdType>
<params>
<param>result = {var.episode}-1</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>ep_array</param>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Scrape</cmdType>
<params>
<param>https://www.tunefind.com/api/v1/show/{var.show}/season-{var.season}</param>
<param>YOUR TUNEFIND API USERNAME</param>
<param>YOUR TUNEFIND API PASSWORD</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>XJson.ParseTokens</cmdType>
<params>
<param>{episodes[{var.ep_array}].tunefind_url}</param>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Launch.OpenURL</cmdType>
<params>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>show me the soundtrack</phrase>
</command>
<command id="117" name="save now playing episode info" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="var.show_title stores friendly show name. var.show will store the show name in format needed by TuneFind.">
<action>
<cmdType>XJson.Raw</cmdType>
<params>
<param>Player.GetItem</param>
<param>"playerid":1, "properties": ["showtitle","season","episode","title"]</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>XJson.ParseTokens</cmdType>
<params>
<param>show:"{item.showtitle}" season:"{item.season}" episode:"{item.episode}" ep_title:"{item.title}"</param>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegEx</cmdType>
<params>
<param>"(.*?)"</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>season</param>
<param>{Match.2}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>episode</param>
<param>{Match.3}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>show_title</param>
<param>{Match.1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>ep_title</param>
<param>{Match.4}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>PY.ExecString</cmdType>
<params>
<param>result = "{Match.1}".replace(" ","-").lower()</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>show</param>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<event>Kodi.Player.OnPlay.episode</event>
<event>XBMC.Player.OnPlay.episode</event>
</command>
</commandGroup>
To sign up for your own api username and password: http://www.tunefind.com/api
The trial license has a limit that prevents us from accessing song data from shows aired in the last year. Technically, I think we meet their terms of use and should have access to the full data, but I haven't followed up with them.
-
There are a number of steps, so I don't want to spend half an hour posting an explanation unless it's wortwhile to others. :biglaugh (I live and learn!)
cheers.
Do you though? ::dis
-
Do you though? ::dis
::club
-
Hey Nimster do you think this could be adapted for movies easy??
-
Lol Nime5ster
-
I guess that depends on what "easy" means to you. :)
It would be easier to do than the TV episodes, because for movies you can go directly to the correct URL on TuneFind to scrape songs for that movie, whereas I had to jump through several hoops to get to specific episode info.
For example, to get song info from The School of Rock (2003) you'd just scrape the URL:
https://www.tunefind.com/api/v1/movie/school-of-rock-2003
You would need to get the movie title and year of the movie from Kodi (or whatever media player you use). Since Kodi will not put dashes between the words -- and TuneFind also requires all lowercase characters -- you'll have to customize the Kodi data in VC to create a string in the required format (which I had to do for the TV episode data as well).
The regex required to get the song info from the TuneFind site looks the same as the regular expression that I used in the example above.
-
If it's easier, feel free to use my real name -- Naomi
In my experience people struggle to spell that correctly even more often. :bonk
-
Hey Nimster do you think this could be adapted for movies easy??
Here's a movie soundtrack solution for Kodi that does not require an API key.
http://voxcommando.com/forum/index.php?topic=2675.0
-
Thnxxx Naomi.. :) :)
-
Hi Naomi im getting a 401 error when i use command for soundtrack eps, any clues you think. Why, can post my group with username and password if you need I'm just at a lost any help appreciated
-
Hi MMatty1,
Before posting your command group etc., are you sure you're using an API key and password? This is distinct from the username and password that you use when signing up to Tunefind. You have to actually apply for the key by filling out a special form:
http://www.tunefind.com/api
If I remember correctly, the key and pw are then issued automatically, but with the limit that you can't run queries on episodes released in the past year.
-
:bonk :bonk :bonk :bonk Thnx just created it and working great for tvshows and movies command works great Thnxxx so much... :-*
-
Hi I haven't used this command for awhile due to upgrading pc, it seems it won't work anymore they deactivated my account and tunefind now want 25 a month to request data just thought I'd post let you know