BBs19

TVmaze.com API UDF (TV-Series)

9 posts in this topic

#1 ·  Posted (edited)

Hey guys, i wrote a small TVmaze.com API UDF for my TV-Show-Manager program. You can get any tv-show info you like with this UDF. Everything like tv-schedule, series info, cast list, episode list etc. including image links can be downloaded and will be returned in arrays.
 
The API is way faster than for example tvrage.com.
 
 
In case anyone ever needs it:
 
 
 
Simple Example:

#include "TVMazeAPI_UDF.au3"
#include <Array.au3>


;===========TV Schedule for next 2 days==========
$TV_Schedule=_GetTVSchedule()
_ArrayDisplay($TV_Schedule,"TV Schedule")


;===============Search for a show================
$SearchResults=_SearchShow("person of interest")
If @error then Exit
_ArrayDisplay($SearchResults,"Searchresults")


;===============Get show info/details============
$ShowID=$SearchResults[0][1];Show id is taken from the searchresults first result
$ShowInfo = _GetShowInfo($ShowID)
_ArrayDisplay($ShowInfo,"Show Info")


;=============Get the cast of a show=============
$Cast=_GetCast($ShowID)
_ArrayDisplay($Cast,"Cast")


;============Get all Episodes of a Show==========
$AllEpisodes = _GetShowEpisodes($ShowID)
_ArrayDisplay($AllEpisodes,"All Episodes")


;========Filter Episodes by selected season======
$FilteredBySeason2 = _FilterBySeason($AllEpisodes, "2")
_ArrayDisplay($FilteredBySeason2,"Filtered by episodes of season 2")


;====Get only last and next episode of a show====
$LastAndNextEpisode = _GetShowEpisodes($ShowID, 0, @TempDir, 0, 1)
_ArrayDisplay($LastAndNextEpisode,"Last and Next Episodes only")

Example usage(image):
2qcmn38.jpg

 

 

Updated 30.12.2015:

- Bug fix

 

 

TVMazeAPI_UDF.zip

Edited by BBs19
Updated
3 people like this

Share this post


Link to post
Share on other sites



awesome udf.

very handy.

but I am getting errors for example with bones. I pinpointed it to a problem in processing an 'airstamp' value which is equal to 'null'

 

a simple code which shows the error :

#include "TVMazeAPI_UDF.au3"
#include <Array.au3>
#include "_array2d.au3"
$sShowName="bones"
$aSearchResults = _SearchShow($sShowName)
;_arraydisplay($aSearchResults)
$iShowID = $aSearchResults[0][1];Show id is taken from the searchresults first result
consolewrite ($iShowID & @crlf)
$aAllEpisodes = _GetShowEpisodes($iShowID, 1, "C:\ttmp\output\")

 

and I get the error :

"XXXXXXXXXXXXXXXXXXXXXX\TVMazeAPI_UDF.au3" (443) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:Local $EpisodeAirDateTime = StringReplace(StringReplace(StringLeft($EpisodeAirDateTimes[$i], 16), "-", "/"), "T", " ")Local $EpisodeAirDateTime = StringReplace(StringReplace(StringLeft(^ ERROR->21:40:10 AutoIt3.exe ended.rc:1[/code

 

I started looking at your code, but I figured it would probably be easier for you to do a clean fix rather than me adding a dirty skip

if you don't feel like fixing it, please let me know I will put my brain into it.

thanks again,

Cheers

R.

Share this post


Link to post
Share on other sites

Uhm yes there were still many bugs. I have fixed and updated it some time ago but forgot to upload it here.

 

Check first post. I have updated it. There are also a few new features like user rating etc. but i was too lazy to document everything in the UDF :P

 

Share this post


Link to post
Share on other sites

BBs19,

thank you it works now :)

I really like your udf. nice and simple. I used to get all my info from TVRAGE, parsing their RSS feeds.. your udf has cut my script to only a few lines ;)

I wish you could share your full app as it looks slick.

cheers,

R

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

BBs19,

 

sorry I spoke too fast. The function does not fail anymore, but it returns an array with an empty line at the end. it seems to happen when TVRAGE has only the name of the episode but no details. Once again Bones is an example of this situation.

the _filterbyseason function does provide an array without the empy line per season (which could be a quick fix for a lot of people)

or I simply added a while loop in my script to handle it as I need the full episode list for my purpose

 

#include "TVMazeAPI_UDF.au3"
#include <Array.au3>
#include "_array2d.au3"
$sShowName="bones"
$aSearchResults = _SearchShow($sShowName)
$iShowID = $aSearchResults[0][1]

;returns an extra empty line at the end of the array (instead of the last known episode in TVRAGE)
$aAllEpisodes = _GetShowEpisodes($iShowID, 1, "C:\ttmp\output\")
_arraydisplay ($aAllEpisodes)

;gives an array without the extra line (but without the last episode)
$FilteredBySeason = _FilterBySeason($aAllEpisodes, "11")
_ArrayDisplay($FilteredBySeason,"Filtered season 11")

;dirty fix to preserve the full array as I need it in my script
;I chose a loop to make sure I do not fall in another weird case
While $aAllEpisodes[$iBound][1] = ""
    $aFlush = _ArrayPop($aAllEpisodes)
    $iBound -= 1
WEnd
_arraydisplay ($aAllEpisodes)

 

it is clearly not your UDF who has an issue. 

this specific situation where TVMAZE has an episode without any extra information seems to be rare, but if you choose to handle these exceptions let us know

 

Cheers,

R

 

edit . I ran into another show which would give empty lines at the end of the array : person of interest. once again it is due to episodes which are listed with only names but no details. so my loop is the right way for me to go. until you solve it if you choose to do so.

Edited by redia

Share this post


Link to post
Share on other sites

BBs19,

 

sorry I spoke too fast. The function does not fail anymore, but it returns an array with an empty line at the end. it seems to happen when TVRAGE has only the name of the episode but no details. Once again Bones is an example of this situation.

the _filterbyseason function does provide an array without the empy line per season (which could be a quick fix for a lot of people)

or I simply added a while loop in my script to handle it as I need the full episode list for my purpose

 

#include "TVMazeAPI_UDF.au3"
#include <Array.au3>
#include "_array2d.au3"
$sShowName="bones"
$aSearchResults = _SearchShow($sShowName)
$iShowID = $aSearchResults[0][1]

;returns an extra empty line at the end of the array (instead of the last known episode in TVRAGE)
$aAllEpisodes = _GetShowEpisodes($iShowID, 1, "C:\ttmp\output\")
_arraydisplay ($aAllEpisodes)

;gives an array without the extra line (but without the last episode)
$FilteredBySeason = _FilterBySeason($aAllEpisodes, "11")
_ArrayDisplay($FilteredBySeason,"Filtered season 11")

;dirty fix to preserve the full array as I need it in my script
;I chose a loop to make sure I do not fall in another weird case
While $aAllEpisodes[$iBound][1] = ""
    $aFlush = _ArrayPop($aAllEpisodes)
    $iBound -= 1
WEnd
_arraydisplay ($aAllEpisodes)

 

it is clearly not your UDF who has an issue. 

this specific situation where TVMAZE has an episode without any extra information seems to be rare, but if you choose to handle these exceptions let us know

 

Cheers,

R

 

edit . I ran into another show which would give empty lines at the end of the array : person of interest. once again it is due to episodes which are listed with only names but no details. so my loop is the right way for me to go. until you solve it if you choose to do so.

Updated @ first post.

Thanks for reporting, I haven't noticed that before, my tv show program had no problems due to the empty line in the array. I fixed it anyway.

And for the question about my program: You can get it here, including source: https://sourceforge.net/projects/tvshowcountdown/

 

Share this post


Link to post
Share on other sites

thanks.

I will test the UDF and tell you if I find anything else.

and I will also check your app.

 

Cheers,

R

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now