SurLaTablo.py - Python program to query and convert Tablo recordings

Playing some --queryformat enhancements. Let’s say your surlatablo.conf looks like:

SURLATABLO_ROOT = '/SurLaTablo'
TRANSCODER_DEFAULT = [ 'Mp4', 'Gif', 'Json' ]
TABLO_IPS = ['192.168.1.73']
options['truncate_ts'] = 25

options['queryformat'] = '## ${friendly_title} ##\n\t${friendly_date}\n\t${channel_sign}(${channel_affiliate}) - ${channel_res_name}\n\n\tDescription:\n\t${Wlong_description}\n'
options['wrapwidth'] = 80
options['wrapindent'] = '\t'
options['wrapsubindent'] = '\t'

What I’ve added is the ability to customize the default queryformat via surlatablo.conf (since they can be complex and you might have a default format that you like) and I’ve added word wrapped elements for description and long_description called Wdescription and Wlong_description, as well as a friendly_date too (where the format is customizable).

With the settings above you get the following on a query, let’s say for all movies:

surlatablo.py -n -q meta_type~=Movie

Uncommon Valor (1983)

    Friday, August 28, 2015 at 09:30 AM
    KTXD-DT() - unknown

    Description:
    Col. Cal Rhodes (Gene Hackman), a retired Marine officer, holds out hope that
    his son, believed to be a prisoner of war in Laos, is still alive. Despite the
    government's refusal to help Rhodes, he assembles a group to find and rescue
    his son, including skilled soldiers such as Wilkes (Fred Ward) and Sailor
    (Randall "Tex" Cobb). Funded by MacGregor (Robert Stack), a wealthy executive
    also looking for his son, Rhodes leads his men on a dangerous mission into the
    jungles of Laos.

Cops and Robbersons (1994)

    Monday, August 24, 2015 at 04:30 AM
    ThisTV() - 480i

    Description:
    Tough-guy police officer Jake Stone (Jack Palance) and his less seasoned
    partner, Tony Moore (David Barry Gray), are intent on taking down Osborn
    (Robert Davi), a ruthless criminal. However, since Osborn is holed up in the
    suburbs, Jake and Tony must hold their stakeout in a neighboring house, home to
    the Robbersons. The well-meaning family, including patriarch Norman (Chevy
    Chase), tries to assist the cops in their duties, but it proves to be unwanted
    help.

Not released just yet, but coming soon…

@cjcox That’s a pretty slick way of making the output to the terminal much more readable. Thanks in advance for enabling that feature.

By the way, have you given any more thought towards extending --keepdir so that you can specify keeping a subset of files to offer more granularity? IE: --keepdir S might only keep the SRT files.

@ccridge, I’ll see if I can add something like that in (will probably be a bit different that your suggestion though… but you’ll like it!).

First off this is pretty cool and practical. I unfortunately could not get this to successfully save the file. I don’t get any errors and it looks like it’s running through the tasks.

This is the command I used (nevermind the zapcommerials). Clearly I am missing some plugin or something for zapcommercials to work. I don’t need any fancy work. Just a simple transcode, convert and save.

surlatablo.py --noupdate --convert --rec_id 38500 --zapcommercials

This is my output.

Warning: No zap compatible transcoder provided. Transcode may have audio/video sync issues.
Working on: [./TV/Gotham/Season 2/Gotham - s02e01 - Rise of the Villains: Damned If You Do …]
Retrieving Tablo Data (38500): [####################] 100% Elapsed seconds 262.0
Searching for commercials: [####################] 100% Elapsed seconds 0.0
Removing commercials (z1): [####################] 100% Elapsed seconds 0.0
Elapsed seconds 0.0

Maybe you don’t have ffmpeg installed?

Yeah…I have linux mint where they no longer have ffmpeg but rather avconf…supposedly it is to be used instead but that apparently does not work. I will try the source or ppa download linked from ffmpeg website. It’s gotta be something simple. Thx!

Awesome! I downloaded the static ffmpeg build so that’s good now. My next question is what is a recommended “zap compatible” transcoder? I am not sure why I get that error because it transcoded just fine and I have no sync issues. Great work on this in any case! Just what I was looking for.

It would be great if they just made this a standard feature or option on the Tablo. I suppose that’s what’s great about the community!

Try adding Mp4z to the end of your command line. SurLaTablo will use default transcoder options, but commercials are a pain and really in order to stitch things together and keep audio/video in sync a fuller transcode is required. Mp4z is a predefined transcode option set. It’s pretty easy to add your own. Use the -t parm by itself to see what surlatablo know about with regards to transcoding options (things I built into it by default).

Same result. Can you clarify a bit on how I can add my own? or the command syntax using the Mp4z option.

Actually it did work now. I did not get that message anymore. I must have typed something wrong…anywho. Thanks!

You could add the new transcode “type” in your surlatablo.py like so:

TRANSCODER_OPTS['cjcox'] = {
                    'help': [ 'testing user added transcode type.' ],
                    'command': [ FFMPEG ],
                    'threads': [ '-threads', '0' ],
                    'inputfile': [ '-i', '${ts_filename}' ],
                    'subtitlefile': [ '-f', 'srt', '-i', '${srt_filename}' ],
                    'options': [ '-preset', 'ultrafast' ],
                    'subtitleoptions': [ '-c:s', 'mov_text', '-metadata:s:s:0', 'language=${lang3}' ],
                    'audiooptions': [ '-metadata:s:a:0', 'language=${lang3}' ],
                    'metadata': [],
                    'zap': [],
                    'ext': [ '-cjcox.mp4' ]
                }

I just copied the Mp4z one out of the program and put it into my surlatablo.conf with a new name, help and new ext. You can take a look at the others in the program to get some ideas. If you have reasonably newer ffmpeg, you can take a look at the Glow trancoder. It’s probably one of the slowest ones since it alters frame by frame (practice with a small video).

SurLaTablo 1.2 Released

I noticed that since a recent Tablo update most of the time it does not cut commercials. I know this is a challenging thing to do. Is there a setting within the code that I can play with to see if it works better?

The commercial cutting algorithm is independent of the Tablo… I do have plans for a new tool. Stay tuned.

4 Likes

This is my favorite Tablo downloader. I had a problem when using on my old Dell running Fedora 23 because the /tmp filesystem too small. Fixed when I added this to my surlatablo config file.

tempfile.tempdir = ‘/var/tmp’

Thanks,
Tom

1 Like

It’s my favorite too :smile:

And it runs on OSX, Windows and pretty much any *ix with python and ffmpeg. Which might be interesting to some.

SurLaTablo 2.0 is still inside of my head… just need to pry it out…

I had to install ffmpeg static to get the transcode options to work. The dnf/yum installed version did not work. Probably missing some codec libraries. I really like the h265 (smaller file sizes/less artifacts) but it takes a looong time to encode on my dual core 2.5 Ghz pentium (about 8 hours for 1 hour show). The Shrink transcode option works great and a lot faster. Can we adjust the Shrink bitrate or is that hard coded into ffmpeg?

Thanks,
Tom

Optimizations for h265 will take time (speaking for ffmpeg, though I really can’t).

As for bitrate, look at the options -b:v, -minrate and -maxrate, -bufsize

With that said, you mind find transcoding happening if you adjust those values, which may, or may not, be what you expected.

I have an autostart systemd bash script (same as /etc/rc.local) that downloads only a few of my favorite shows from tablo to my linux box and then shrinks and saves them to my nfs mounted /video folder on my synology nas (to slow of nas to ffmpeg files directly). All day long it sites in a loop looking for new files to archive. Thanks for writing surlatablo.

Thanks,
Tom

It may not as be as “friendly” as some of the alternatives, but it’s very flexible. Glad it is working out for you!!