Nightly offload from Tablo to Plex

Based on comments about tools for downloading Tablo recordings found here and elsewhere, I have thrown together a script to run nightly to:

  1. Download “yesterday’s” recordings from Tablo, via Tablo2Go,
  2. Remove commercials with Comskip via PlexComskip.py,
  3. Move commercial-free files to Plex library folder.

I am posting this as I hope having all these pieces enumerated in one post will help others who are looking to do the same.

The script assumes Tablo2Go, Comskip, and PlexComskip have all been installed. All this is running on MacOS 10.12.5 and required install of Python3 (for Tablo2Go), via Homebrew, and ‘pip3 install requests’.

Find Tablo2Go here. contents of link saved as ${HOME}/Tablo2Go/tablo2go.

Find Comskip here. My install wound up in /usr/local/bin/comskip (I don’t recall the specific steps to get it there, it was a while ago.)

Find PlexComskip here. Installed and configured in ${HOME}/PlexComskip/…

Here’s the script which I setup as a “Run Shell Script” Automator iCal Event which runs at 1:30am every morning:

#!/bin/bash
ROOT="${HOME}"
YESTERDAY=`date +'%Y-%m-%d'`

loop_files () {
  find ${ROOT}/tablodvr -type f | while read f
  do
    eval "$1 \"${f}\""
  done
}

# download yesterdays Tablo recordings in ${ROOT}/tablodvr/...
${ROOT}/Tablo2Go/tablo2go --date ${YESTERDAY}

# get new mp4 file list
NEW_FILES=$( find ${ROOT}/tablodvr -type f )

if [[ ! -z $NEW_FILES ]]
then
  echo 'Found files:'
  loop_files 'echo'

  # PlexComskip each file
  loop_files "/usr/bin/python ${ROOT}/PlexComskip/PlexComskip.py"

  # copy to plex lib folder, ${ROOT}/dvr/...
  cp -rf ${ROOT}/tablodvr/* ${ROOT}/dvr

  # remove files from tablodvr folder
  loop_files 'rm'
fi
2 Likes

Excellent script and pointer to the resources required to download, commercial skip and archive shows.

1 Like

Script, take 2.

This does a better job at serializing the processing of each download and also runs comskip in parallel for all downloaded files. Works fine this way on my Late-2012 MacMini, YMMV depending on your server’s horsepower.

#!/bin/bash
logger() {
  echo "`date` -- ${1}" >> ~/Tablo2Go/tablo2plex.log
}

do_it() {
  f=$1
  
  logger "Start file '$f'"

  fname=`echo "${f##*/}"`
  fpath=`echo "${f%/*}"`
  destpath=`echo "${fpath//tablo/}"`

  logger "PlexComskip '$f'"
  /usr/bin/python ${HOME}/PlexComskip/PlexComskip.py "$f"
  passed=$?
  logger "PlexComskip returned $passed"

  [ $passed -eq 0 ] && mkdir -p "$destpath" && mv "$f" "$destpath" && logger "Moved '$fname' to '$destpath'"

  logger "End file '$f'"
}

# download yesterdays Tablo recordings in ${HOME}/tablodvr/...
logger "Downloading yesterday's recordings"
${HOME}/Tablo2Go/tablo2go --date `date +'%Y-%m-%d'`

FILECOUNT=`find ${HOME}/tablodvr -type f -iname *.mp4 | wc -l`
logger "Downloaded ${FILECOUNT} files"

find ${HOME}/tablodvr -type f -iname *.mp4]

if [[ ! -z ${FILECOUNT} ]]
then
  # PlexComskip each file and move to Plex lib
  find ${HOME}/tablodvr -type f -iname *.mp4 | while read f
  do
    do_it "$f" &
  done
fi

Here’s a small snippet of the generated log file:

Mon May 29 01:32:18 EDT 2017 -- Downloaded        0 files
Tue May 30 01:32:00 EDT 2017 -- Downloading yesterday's recordings
Tue May 30 01:41:07 EDT 2017 -- Downloaded        2 files
Tue May 30 01:41:07 EDT 2017 -- Start file '/Users/username/tablodvr/tv/Gotham/Season 03/Gotham - S03E20 - Heroes Rise: Pretty Hate Machine.mp4'
Tue May 30 01:41:07 EDT 2017 -- Start file '/Users/username/tablodvr/tv/Lucifer/Season 02/Lucifer - S02E18 - The Good, the Bad and the Crispy.mp4'
Tue May 30 01:41:07 EDT 2017 -- PlexComskip '/Users/username/tablodvr/tv/Gotham/Season 03/Gotham - S03E20 - Heroes Rise: Pretty Hate Machine.mp4'
Tue May 30 01:41:07 EDT 2017 -- PlexComskip '/Users/username/tablodvr/tv/Lucifer/Season 02/Lucifer - S02E18 - The Good, the Bad and the Crispy.mp4'
Tue May 30 01:47:01 EDT 2017 -- PlexComskip returned 0
Tue May 30 01:47:01 EDT 2017 -- Moved 'Gotham - S03E20 - Heroes Rise: Pretty Hate Machine.mp4' to '/Users/username/dvr/tv/Gotham/Season 03'
Tue May 30 01:47:01 EDT 2017 -- End file '/Users/username/tablodvr/tv/Gotham/Season 03/Gotham - S03E20 - Heroes Rise: Pretty Hate Machine.mp4'
Tue May 30 01:55:58 EDT 2017 -- PlexComskip returned 0
Tue May 30 01:55:58 EDT 2017 -- Moved 'Lucifer - S02E18 - The Good, the Bad and the Crispy.mp4' to '/Users/username/dvr/tv/Lucifer/Season 02'
Tue May 30 01:55:58 EDT 2017 -- End file '/Users/username/tablodvr/tv/Lucifer/Season 02/Lucifer - S02E18 - The Good, the Bad and the Crispy.mp4'
Wed May 31 01:32:00 EDT 2017 -- Downloading yesterday's recordings
Wed May 31 01:32:19 EDT 2017 -- Downloaded        0 files
Thu Jun  1 01:32:00 EDT 2017 -- Downloading yesterday's recordings
Thu Jun  1 01:32:19 EDT 2017 -- Downloaded        0 files

You can see the parallel processing in the timestamps in the log file.

1 Like

rbw, can you help me get this configured, I would really like to run this. But I have no clue how to setup the ical event. I am pretty sure I can get the items needed installed. But if you could assist me in getting this configured, I would use it and test it accordingly.

Two step process.

  1. Create Automator run shell script task:

    source ${HOME}/Tablo2Go/tablo2plex.sh

  2. Create iCal event with custom alert to open Automator file, repeats daily at 2am. For “Other…” select Automator file from file dialog that pops us.

See screenshots posted in separate reply.

Okay, I understand the part you have provided above, but yet again I am stuck. I have downloaded and installed python 3 on my mac.

Now I need to get theses 3 items installed:

Find Tablo2Go - do i copy the contents of the link, save it is a text file and place in the location mentioned in your post? Do I only copy a portion of the file and save it to the location mentioned in the post above?

Find Comskip - if I am usnng plex to remove commercials already, do I need this installed?, if so, is it installed in a different directory? can I use what is currently installed with plex?

Find PlexComskip - if I am usnng plex to remove commercials already, do I need this installed?, if so, is it installed in a different directory? can I use what is currently installed with plex?

I am currently running plex dvr with an hd homerun 2 tuner.

Do I need to install comskip and plexcomskip if they are already in use due to my plex server being up and running?

If I need to install them, when I click on the link to get Tablo2Go for example, how exactly do I set them up? I figured I would download them and run a package or something. Unfortunately that is not the case here.

Apologies for being daft, maybe I am missing instructions in the information on the links… Feeling very inadequate right now…

You’ll need to look at the tools available and decide what you want your solution to be. My post reflects my setup. Since it works for me, I have no need to look at other options, like using Plex to remove commercials, which is a feature that was added after my post was written.