Skip to content
joncl edited this page Sep 27, 2014 · 10 revisions

Welcome to myth2kodi!... A tool for turning Kodi into a frontend for ALL MythTV recordings!

This wiki is the main source of info to setup myth2kodi. For additional info, or to post questions/comments, please see this myth2kodi thread on the XBMC forum: http://forum.xbmc.org/showthread.php?tid=205009


Overview

Unfortunately, mythicalLibrarian or mythlink (both very nice tools) didn't work for me like I had hoped. Most of my MythTV recordings are kids' shows, and close to 1/2 out of ~750 or so don't get recognized as actual show/episodes (call them "Specials"), so they end up under Videos instead of all together under TV Shows in XBMC. Even worse, these "Specials" show up as just folder icons without any posters, fanarts, or banners. I came across another project for Plex called mythPlex (see thread, and GitHub repo) which inspired me to try and roll my own solution for XBMC (all the while learn Python along the way, nice!)

Objectives

Duplicate the navigation of recordings in MythTV as much as possible (my family is used to Mythfrontend which works well, so similar functionality would be good!). This means that ALL recordings, whether they be episodes (recognized by show and episode number) or "Specials" (unrecognized by either ttvdb or tmdb) need to all go under "TV Shows" and under THE SAME SERIES in XBMC! It's also very important that posters, fanart, and banners be correct and present just like in Mythfrontend (well most of them come in, so maybe we can even improve a little!)

  1. Show both episodes and "Specials" under the same common series, all under "TV Shows" in XBMC.
  2. Scrape show/episode metadata into local .nfo files so that XBMC can read everything in as "Local information only".
  3. Pull down posters, fanarts, and banners from TheTVDB or TheMovieDB depending on the inetref from MythTV.

What It Does

  1. Read the metadata for each recording stored in the MythTV backend database
  2. Create a directory and tvshow.nfo file for each series
  3. Scrape poster, fanart, and banner links from TTVDB or TMDB, and copy image files alongside tvshow.nfo for each series
  4. Create a symlink to the video file for each episode
  5. Create a nfo file for each episode alongside the video symlink with the same name
  6. Ability to add a single video by command line (useful to add as a Mythbackend user job when the recording finishes for each schedule
  7. Ability to cleanup symlinks, nfo files, and/or series directories when shows are deleted from MythTV (this is still TODO)

Download

myth2kodi is written in Python with help from PyCharm 3.4, tested with Python 2.7.3 in Ubuntu 12.04 running Mythbackend .27. You can find the latest myth2kodi right here on GitHub:

https://github.com/joncl/myth2kodi

Intial Setup

  1. Request for a TTVDB API key here: http://thetvdb.com/?tab=apiregister
  2. Request for a TMDB API key here: https://www.themoviedb.org/documentation/api
  3. Copy config.py and myth2kodi.py (from this GitHub repo) to your backend server here as root:
/usr/local/bin/myth2kodi
  1. Create a directory where symlinks to MythTV recordings will go, such as /pool/myth2kodi/recordings
  2. Create a separate directory to store TTVDB zip files (this is for caching the show/episode metadata zip files), such as /pool/myth2xbmc/ttvdb
  3. Set the ownership and permissions with something like this:
sudo chown mythtv:mythtv -R /pool/myth2kodi
sudo chmod +x -R /pool/myth2kodi
  1. Edit config.py to suite. Here's how mine looks:

config.py

# IP or hostname of your MythTV backend
hostname = "<ip or hostname>"

# Port number of your MythTV backend (this is the default, can probably leave as-is)
host_port = "6544"

# A list of MythTV recording directories, full paths in quotes, separated by commas
mythtv_recording_dirs = ["/pool/mythtv/recordings/"]

# Path to write symlinks
symlinks_dir = "/pool/mythtv2xbmc/recordings/"

# API key for TheTVDB
ttvdb_key = "<your ttvdb key>"

# Path to store TheTVDB series zips
ttvdb_zips_dir = "/pool/myth2xbmc/ttvdb/"

# API key for TheMovieDB
tmdb_key = "<your tmdb key>"

Configure Your Recording Schedules

  • Have MythTV lookup the TTVDB or TMDB reference number for your existing recording schedules:
mythmetadatalookup --refresh-all-rules
  • Alternatively, go to mythweb > click Recording Schedules > pick a schedule > pick "Look up Metadata". You should have a reference number filled in for each of your schedules. Format should be ttvdb.py_# or tmdb.py_#:

Run It

  • Open up a shell and run ./myth2xbmc from your myth2xmbc directory (where the script is located of course). The scripts lists each new series as it's being added, and displays some stats at the end:

Make a Network Share

  • You'll need to share your symlinks directory on the network so that XBMC can see them. My XBMC runs on a Windows HTPC PC, so I added a samba share on the Mythbackend server, something like this:
sudo nano /etc/samba/smb.conf
  • My samba config looks like this, added to the very bottom of the file (note "follow symlinks" and "wide links" enable XBMC to actually play the video file through the symlink):
[myth2xbmc recordings]
        comment = myth2xbmc recordings
        path = /pool/myth2xbmc/recordings
        readonly = yes
        write list = jon
        create mode = 0755
        directory mode = 0755
        follow symlinks = yes
        wide links = yes
        force user = mythtv
  • Restart samba:
sudo service smbd restart
  • Check that the new share is accessible from Windows Explorer:

Add a New Video Source in XBMC

Here are the steps to add a new video source in XBMC:

  1. On the main screen, select VIDEOS > FILES

  2. Files

  3. Add Videos...

  4. Browse

  5. Windows network (SMB)

  6. Pick your Mythbackend server

  7. Enter the username and password > OK

  8. Pick your share

  9. OK

  10. OK

  11. Set "This directory contains" to TV shows, then pick "Local information only" > OK

  12. "Do you want to refresh info for all items within this path?" > YES

  13. ESC back to the main screen

  14. Select TV SHOWS

Configure Your Mythbackend

Have myth2kodi automatically add a new recording after Mythbackend finishes one. My backend server is actually headless (running as a ESXi VM), so I access the Mythbackend setup screens using Putty and Xming:

  • Install Xming. Once installed, run Xming Launch from your Start Menu, and then pick these options:

  • Get a copy of Putty, make an SSH profile to your backend server, then set these settings:

  • Open an SSH shell to your backend, and enter "mythtv-setup":

  • Switch over to your Xming window, and you should see some prompts:

  • You will hopefully see Xming connecting to your backend:

  • Hit Enter to navigate into the General pages. Keep hitting Enter until you get to these pages. Highlighted in red are the important changes to make:

  • Once you get back to the main menu, hit ESC and follow the prompts to exit out of MythTV Setup:

  • In the SSH shell, you should see the mythtv-backend process is running again:

Set the myth2kodi User Job for Existing Recording Schedules

Now that we have a new myth2kodi user job, we need to tell the Recording Schedules to actually use it. You can do this from mythweb or mysql...

  • mythweb: For each recording schedule, check "myth2xbmc" and update it:

  • mysql:

$ mysql -umythtv -pmythtv mythconverg
mysql> update record set autouserjob2=1 where autouserjob2=0;

Tips / Workarounds

  • Poster, fanart, or banner is image incorrect for an existing series
    • You may need to update the database directly. Here is the code I used for "Tom & Jerry" (backup your database first!):

$ mysql -umythtv -pmythtv mythconverg mysql> show tables; mysql> describe recorded; mysql> select inetref from recorded where title = "Tom & Jerry"; mysql> update recorded set inetref='ttvdb.py_72860' where title = "Tom & Jerry"; mysql> quit ````

TODO

  • Add argument so a user job can clean up symlinks, nfo files, and directories when MythTV recordings are deleted.
  • Handle a "--refresh-nfos" argument (not sure if this is really need yet).
  • Possibly add commercial markers from MythTV. Not sure yet exactly how this is done. I might just transcode out the commercials anyway.
Clone this wiki locally