API/interface to pull recorded show listings, metadata, and files off of the Tablo

I am finished for now, please test the new script, version 2.0b17 has been posted at https://sites.google.com/a/moboard.com/tablo/  If any issues are found I will try to address them over the next week or so.


In addition to what I posted earlier, this script has:

- -delay option prevents recently recorded shows from being selected (useful it you use kmttg like me and want the TiVo to have priority until they add multichannel sound).  Just provide an argument like -delay:84600 to wait a day (it measures time in seconds since the video stopped recording)
- -summary option just displays the basic match / tablo information and stops
- -not option reverses the selection criteria

- Updated the scripts so that newer recordings would take precedence if their were duplicates
- Updated the scripts to gracefully shut down with a Ctrl-C (vice ignoring it completely)

@jskenney

Quick question, it does not appear that the metadata is included in the file when it’s removed from the Tablo and placed in a .ts or .mp4 on my local PC… Is this the case?

No there is no data embeded, I do not embed any metadata in the file either.  Never thought of trying that, sounds like a great option.  Is there a “standard” naming convention for metadata in a .mp4 file (no metadata for .ts) - to implement this I would need an undestanding of the naming conventions and have to find a good command line tool that would do the work for me.

I am playing with line 600 where the FFMPEG cmd is called.  It looks like -metadata can be added to that line to add the metadata to the file.  I was able to add, -metadata title = “test”.   When I check out the metadata after it processed, it was included in the file.  Just need to add the rest of the metadata information based on what you’re already pulling out of the meta.txt file

For the metadata, I will work on a TV -> metadata, and Movie -> metadata following https://code.google.com/p/mp4v2/wiki/iTunesMetadata and http://wiki.multimedia.cx/index.php?title=FFmpeg_Metadata (and looking at the tags from a previous TV show and Movie iTunes purchase).  This seams rather doable.

Thanks for working on this … !

jskenney - I updated my server to use the new script yesterday and wanted to say thanks for the great work. I like the use of the file vs the DB. It definitely makes modifying the data a lot easier.


I did have a couple ?'s/suggestions though:
  • For the format of date-based episodes why did you change from Season Title - YYYY-MM-DD - Episode Title to Season Title - Episode Title (YYYY-MM-DD). The former is the supported format for Plex and what was used in the original script. Another thing I did was change the date in the date-based episode to use the original air date. I have made the changes to my local script and can share my edits in case you wanted to see my changes.
  • Would it be possible to turn off directory creation for TV shows through a command line flag? On my server I have a workflow where the unprocessed files are dumped to a directory that MCE Buddy reads and removes commercials and them moves them to Plex. I can update the scripts if needed and send you my changes for this as well.

I also ran into the one-off scenario where I updated my Tablo while it was in the middle of recording a TV show. After the update was applied the Tablo recorded the rest of the show. As a result I had two parts for the same TV show. I’m not sure if this is something that is common enough to handle within the script but thought I’d let you know.

@mjarends I just uploaded b21 to my site, you can now prevent the tv directory structure from being created with option -tvcreate:False


For the file naming I was using the below (do i need to change 3.a.?)

1. Movies = Title (Year).ext
2. TV = Series - SxxExx - Title.exe
3a. Unknown TV w/ Title = Series - Title (AirDate)
3b. Unknown TV w/o Title = Series (AirDate)

I don’t think there is anything I can do about the last scenario (two parts due to update), neither are the right version.

Additionally version b20+ “attempts” to add all of the metadata to a .mp4, but it seams to be completely dependent on the version/os/compile options for whatever ffmpeg you are using.

Thanks for the update.


Here is what I was looking at for the TV show date-based Plex naming: https://support.plex.tv/hc/en-us/articles/200381053-Naming-Date-based-TV-Shows

I was actually looking at enhancing some of my own scripts with MP4 tagging and found the mutagen python library: https://bitbucket.org/lazka/mutagen

I see sickbeard uses the mutagen library to set MP4 tags from TVDB: https://github.com/mdhiggins/sickbeard_mp4_automator/blob/master/tvdb_mp4.py
@mjarends b23 changes the file format (for 3a and 3b) to what is listed below, everything should be Plex compatible now (I use a separate set of scripts for unmatched shows, so I was using kmttg compatible formatting)

1. Movies = Title (Year).ext
2. TV = Series - SxxExx - Title.ext
3a. Unknown TV w/ Title = Series - AirDate - Title.ext
3b. Unknown TV w/o Title = Series - AirDate.ext

For the metadata, thanks for the links I will look at that later, the script now creates all of the appropriate apple tags (so that part is done), it is just getting the best way of embedding them.

@jskenney

This is working great.  Thank you for all of the time that you have put into this.

Just a suggestions for a future enhancement, could there be an option to delete the folder on Tablo after it has been copied to a local drive?   

@mjarends b30 fully integrates mutagen (if installed) on your system, and I can get all of the metadata filled in.  Nice library, that solved many problems.


@BoomerTheWeim - I have no idea how to delete things from the tablo, as everything I have done so far just reads from the tablo’s web server - I have no insight into any api’s that might exist (which could have made this so much easier, if that had been available…) 

@jskenny I saw that you had posted the change last night (including the mutagen change). I have updated my server with the new script. Thanks again for incorporating my suggestions.

@jskenney

I am trying to use the -a -sleep:900 and it runs ok but it does not see any new files.  If I stop and start the process again, it find the files without any issues. 

Do you know if this is an issue?


@BoomerTheWeim beta b31 has been posted, that should fix the issue, I had it set so that If the video was being recording while the scan occurred it was being completely ignored in the future - oops.


Thanks for testing this!

Awesome, thanks.  I am trying it out now.

Thanks everyone for testing. b33 has been uploaded and will be the last one for a few days (while I let it run against all of the videos on my two tablos to test).  I think I got all of the issues sorted with downloading metadata (so that it will download videos if they were recording during the last metadata load, and if the video was finished I no longer bother attempting to download the metadata again).


Also, changed the download printing to show %, MB downloaded, and a guestimate of time remaining.

Hope that helps.

@jskenney  I’d like to try this. How do I define/configure paths for the Movie directory and TV directory? Do I add this as a PATH in system Variables or is it something I can do with the flags? I want to put my videos on a D:Video directory where I have a lot of room.


There are two options, one is to change the defaults by editing the script, you will see the lines


    ‘tvdir’:    [’./tv’,               ‘PATH’,   ‘Save TV shows here’],
    ‘moviedir’: [’./movies’,           ‘PATH’,   ‘Save movies to this directory’],
    ‘tempdir’:  [’./’,                 ‘PATH’,   ‘Location of temp directory’],
    ‘faildir’:  [’./fail’,             ‘PATH’,   ‘Location to save unknown files’],
    ‘existdir’: [’./exists’,           ‘PATH’,   ‘Location to move duplicate files’],

just change the portion inside the quotes (ie ./tv or ./movies) to what you want them to be, this is how you can make anything permanent.

To change it via the command line, give it the options in this format

python tablo2go-2.0b33.py -tvdir:/mytvshows -moviedir:/mymovies

or use windows like paths

python tablo2go-2.0b33.py -moviedir:c:/movies -tvdir:"c:/tv shows"

use the option -help to see all of the available fields.  

Make sure you tell it where ffmpeg is.

Thanks! I’m looking forward to trying this.