Tablocache.py, python program to cache Tablo data and make searching for rec_ids easier

http://endlessnow.com/ten/Source/tablocache-py.txt

Rename to tablocache.py

Edit the file and change GET_TABLO_ROOT to where you want the cache to be stored and change TABLO_IPS to list of Tablo IPs you have.

Usage is found at text at top of file.

Initial run will take quite some time.  Recommend that your Tablo not be doing anything for the first run.

Run the tablocache.py periodically to keep everything up to date.

This is all work in progress, but wanted to share anyhow…

The channel association to recording is probabilistic and may return wrong info if same show available on multiple channels simultaneously for a given area.

The search includes key data inside of the dictionary for a show… so a search for “channel” would match everything.  I think you’ll get the idea and since it uses regex patterns, you can filter things ok.  I tried to do something that iterated over keys and values, but it error’d on a bad entry in the json db cache file.  I removed the entry… it was weird… let’s just say that Python isn’t perfect…

Returns rec_ids that match to standard out and detail to standard error.

Usage:
Update cache or --noupdate and search cache for rec_ids:
tablocache3.py --search search_pattern

Update cache with new recording and deletions
tablocache3.py


Example of a search (assumes you have things cached):

tablocache.py --noupdate --search ‘fiore’
44421
{
    “air_date”: “2014-08-14T17:00Z”,
    “cast”: [
        “Ernest Borgnine”,
        “Joe Flynn”,
        “Tim Conway”,
        “Carl Ballantine”,
        “Gary Vinson”,
        “Bob Hastings”,
        “Billy Sands”,
        “Edson Stroll”,
        “Yoshio Yoda”,
        “Jane Dulo”,
        “Gavin MacLeod”,
        “John Wright”,
        “Henry Beckman”,
        “Simon Scott”,
        “Dick Wilson”,
        “Jay Novello”,
        “Peggy Mondo”
    ],
    “channel”: {
        “channel_affiliate”: “”,
        “channel_num”: “33.2”,
        “channel_res_height”: “480”,
        “channel_res_name”: “480i”,
        “channel_res_width”: “720”,
        “channel_sign”: “Antenna”
    },
    “meta_type”: “TV”,
    “original_air_date”: “1965-10-28”,
    “rec_id”: 44421,
    “title”: “McHale’s Navy - s04e08 - Voltafiore Fish-Fry”
}


The GET_TABLO_ROOT/GetTablo//rec_ids_db.json is saved in such a way as to be line greppable … for those that like that route better.

Just another example (searching for Cowboys football games):

tablocache.py --noupdate --search ‘Cowboys’
98736
{
    “air_date”: “2014-10-12T20:25Z”,
    “channel”: {
        “channel_affiliate”: “FOX”,
        “channel_num”: “4.1”,
        “channel_res_height”: “720”,
        “channel_res_name”: “720p”,
        “channel_res_width”: “1280”,
        “channel_sign”: “KDFWDT”
    },
    “game_date”: “2014-10-12”,
    “meta_type”: “Sports”,
    “rec_id”: 98736,
    “teams”: [
        “Dallas Cowboys”,
        “Seattle Seahawks”
    ],
    “title”: “Dallas Cowboys at Seattle Seahawks”
}
104387
{
    “air_date”: “2014-10-19T20:25Z”,
    “channel”: {
        “channel_affiliate”: “FOX”,
        “channel_num”: “4.1”,
        “channel_res_height”: “720”,
        “channel_res_name”: “720p”,
        “channel_res_width”: “1280”,
        “channel_sign”: “KDFWDT”
    },
    “game_date”: “2014-10-19”,
    “meta_type”: “Sports”,
    “rec_id”: 104387,
    “teams”: [
        “New York Giants”,
        “Dallas Cowboys”
    ],
    “title”: “New York Giants at Dallas Cowboys”
}
79145
{
    “air_date”: “2014-09-21T17:00Z”,
    “channel”: {
        “channel_affiliate”: “FOX”,
        “channel_num”: “4.1”,
        “channel_res_height”: “720”,
        “channel_res_name”: “720p”,
        “channel_res_width”: “1280”,
        “channel_sign”: “KDFWDT”
    },
    “game_date”: “2014-09-21”,
    “meta_type”: “Sports”,
    “rec_id”: 79145,
    “teams”: [
        “Dallas Cowboys”,
        “St. Louis Rams”
    ],
    “title”: “Dallas Cowboys at St. Louis Rams”
}
78637
{
    “air_date”: “2014-09-14T17:00Z”,
    “channel”: {
        “channel_affiliate”: “FOX”,
        “channel_num”: “4.1”,
        “channel_res_height”: “720”,
        “channel_res_name”: “720p”,
        “channel_res_width”: “1280”,
        “channel_sign”: “KDFWDT”
    },
    “game_date”: “2014-09-14”,
    “meta_type”: “Sports”,
    “rec_id”: 78637,
    “teams”: [
        “Dallas Cowboys”,
        “Tennessee Titans”
    ],
    “title”: “Dallas Cowboys at Tennessee Titans”
}
91749
{
    “air_date”: “2014-10-05T17:00Z”,
    “channel”: {
        “channel_affiliate”: “CBS”,
        “channel_num”: “11.1”,
        “channel_res_height”: “1080”,
        “channel_res_name”: “1080i”,
        “channel_res_width”: “1920”,
        “channel_sign”: “KTVT”
    },
    “game_date”: “2014-10-05”,
    “meta_type”: “Sports”,
    “rec_id”: 91749,
    “teams”: [
        “Houston Texans”,
        “Dallas Cowboys”
    ],
    “title”: “Houston Texans at Dallas Cowboys”
}
86922
{
    “air_date”: “2014-09-29T00:20Z”,
    “channel”: {
        “channel_affiliate”: “NBC”,
        “channel_num”: “5.1”,
        “channel_res_height”: “1080”,
        “channel_res_name”: “1080i”,
        “channel_res_width”: “1920”,
        “channel_sign”: “KXAS-DT”
    },
    “game_date”: “2014-09-28”,
    “meta_type”: “Sports”,
    “rec_id”: 86922,
    “teams”: [
        “New Orleans Saints”,
        “Dallas Cowboys”
    ],
    “title”: “New Orleans Saints at Dallas Cowboys”
}

Last one… searching for recordings with Cary Grant in them:

tablocache.py --noupdate --search ‘Cary Grant’
73233
{
    “air_date”: “2014-09-17T11:00Z”,
    “cast”: [
        “Katharine Hepburn”,
        “Cary Grant”,
        “Doris Nolan”,
        “Lew Ayres”,
        “Edward Everett Horton”,
        “Henry Kolker”,
        “Binnie Barnes”,
        “Jean Dixon”,
        “Henry Daniell”
    ],
    “channel”: {
        “channel_affiliate”: “”,
        “channel_num”: “33.2”,
        “channel_res_height”: “480”,
        “channel_res_name”: “480i”,
        “channel_res_width”: “720”,
        “channel_sign”: “Antenna”
    },
    “meta_type”: “Movie”,
    “rec_id”: 73233,
    “release_year”: 1938,
    “title”: “Holiday (1938)”
}
33212
{
    “air_date”: “2014-07-21T08:35Z”,
    “cast”: [
        “Cary Grant”,
        “Janet Blair”,
        “Ted Donaldson”,
        “James Gleason”,
        “Howard Freeman”,
        “William Demarest”,
        “Art Baker”,
        “Paul Stanton”,
        “Mickey McGuire”,
        “Edward Gargan”,
        “Cliff Clark”,
        “Emory Parnell”,
        “Torben Meyer”,
        “William Austin”,
        “Lane Chandler”
    ],
    “channel”: {
        “channel_affiliate”: “”,
        “channel_num”: “49.2”,
        “channel_res_height”: “480”,
        “channel_res_name”: “480i”,
        “channel_res_width”: “720”,
        “channel_sign”: “GetTV”
    },
    “meta_type”: “Movie”,
    “rec_id”: 33212,
    “release_year”: 1944,
    “title”: “Once Upon a Time (1944)”
}

The titles are designed to be in Plex friendly format (hint)

(Sport titles need some work, but ok for Movies and TV)