-
Notifications
You must be signed in to change notification settings - Fork 7
Home
A tool for turning XBMC(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
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(Kodi). 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(Kodi) (all the while learn Python along the way, nice!)
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(Kodi)! 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!)
- Show both episodes and "Specials" under the same common series, all under "TV Shows" in XBMC(Kodi).
- Scrape show/episode metadata into local .nfo files so that XBMC(Kodi) can read everything in as "Local information only".
- Pull down posters, fanarts, and banners from TheTVDB or TheMovieDB depending on the inetref from MythTV.
- Read the metadata for each recording stored in the MythTV backend database
- Create a directory and tvshow.nfo file for each series
- Scrape poster, fanart, and banner links from TTVDB or TMDB, and copy image files alongside tvshow.nfo for each series
- Create a symlink to the video file for each episode
- Create a nfo file for each episode alongside the video symlink with the same name
- Ability to add a single video by command line (useful to add as a Mythbackend user job when the recording finishes for each schedule
- Ability to cleanup symlinks, nfo files, and/or series directories when shows are deleted from MythTV (this is still TODO)
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
-
Create a myth2kodi directory to store the script and config file (or /usr/local/bin/myth2kodi works too):
sudo mkdir ~/myth2kodi ```
-
Copy config.py and myth2kodi.py (from this GitHub repo) to your new directory.
-
Make myth2kodi executable:
sudo chmod +x ~/myth2kodi/myth2kodi.py ``` 4. Make a directory to store and share MythTV recordings, such as /pool/myth2kodi/recordings 5. Make another directory to store TTVDB zip files (this is for caching the show/episode metadata zip files), such as /pool/myth2kodi/ttvdb 6. Set the ownership and permissions with something like this:
```
sudo chown mythtv:mythtv -R /pool/myth2kodi sudo chmod 755 -R /pool/myth2kodi ``` 7. Request for a TTVDB API key here: http://thetvdb.com/?tab=apiregister 8. Request for a TMDB API key here: https://www.themoviedb.org/documentation/api 9. Edit your config.py:
**config.py**
```
hostname = ""
host_port = "6544"
mythtv_recording_dirs = ["/pool/mythtv/recordings/"]
symlinks_dir = "/pool/mythtv2kodi/recordings/"
ttvdb_key = ""
ttvdb_zips_dir = "/pool/myth2kodi/ttvdb/"
tmdb_key = ""
db_user = "mythtv" db_passwd = "mythtv" db_name = "mythconverg"
comskip_exe = "/home/mythtv/comskip/comskip.exe" ``` 9. Install PIL (Python Imaging Library) This will be used to create a banner image for TMDB episodes found in MythTV (TMDB only has posters and fanart). I used these commands in Ubuntu 12.04 which did the trick:
```
$ sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk python-dev python-setuptools $ sudo pip install pillow ```
-
Download Comskip from http://www.kaashoek.com/comskip/
- Optional donate to the Comskip project to enable additional Comskip features. See website for details.
-
Extract the contents of the zip file to a directory such as:
/home/mythtv/comskip ```
-
Wine is needed to run Comskip in Linux. To install Wine in Ubuntu for example, execute these commands:
sudo apt-get install wine sudo apt-get install xvfb ```
NOTE: the package xvfb is needed if the server is headless (X is not available)
-
Have MythTV lookup the TTVDB or TMDB reference number for your existing recording schedules:
mythmetadatalookup --refresh-all-rules ```
- Alternatively, go to mythweb > Recording Schedules > pick a schedule > Look up Metadata. There should be a reference number filled in for each of your schedules. The format should be ttvdb.py_# or tmdb.py_#:
-
Open up a shell and run as root /usr/bin/local/myth2kodi/myth2kodi.py
sudo /usr/bin/local/myth2kodi/myth2kodi.py --comskip-off ```
NOTE: use the argument --comskip-off initially to test that symbolic links, nfo files and poster, fanart, and banner images are created successfully. Once you have everything running, then run the script with --comskip-all.
WARNING: it may take many hours for Comskip scan all recordings. For example, it took ~36 hours to scan 670 30-minute recordings using the "donator" version of Comskip, and an 8 core processor. The maximum speed reached was 400mbps, probably constricted by the read speed of a 4TB hard drive.
The scripts lists each new series as it's being added, and displays some stats at the end:
-
Make a network share to your symlinks directory so that XBMC(Kodi) can see them. My XBMC(Kodi) happens 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 ```
-
Below is my samba config, with the myth2kodi share added to the very bottom of the file (note "follow symlinks" and "wide links" enable XBMC(Kodi) to play the video file through the symlink):
[myth2kodi Recordings] comment = myth2kodi Recordings path = /pool/myth2kodi/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:
On your XBMC(Kodi) machine, make a new file 'advancedsettings.xml'... (this is for a Windows box, do a quick search for the correct location in Linux):
%AppData%\XBMC\userdata\advancedsettings.xml
Here is the entire contents of the file, or just update an existing advancedsettings.xml as needed:
<advancedsettings>
<videolibrary>
<importwatchedstate>true</importwatchedstate>
</videolibrary>
</advancedsettings>
Here are the steps to add a new video source in XBMC(Kodi):
-
On the main screen, select **VIDEOS **> FILES
-
Files
-
Add Videos...
-
Browse
-
Windows network (SMB)
-
Pick your Mythbackend server
-
Enter the username and password > OK
-
Pick your share from the list
-
OK
-
OK
-
Set "This directory contains" to TV shows, then pick "Local information only" > OK
-
"Do you want to refresh info for all items within this path?" > YES
-
Hit ESC back to return to the main screen
-
Select TV SHOWS
Have **myth2kodi **automatically add a new recording after Mythbackend finishes recording 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:
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 "myth2kodi" and update it:
-
mysql:
$ mysql -umythtv -pmythtv mythconverg mysql> update record set autouserjob2=1 where autouserjob2=0; ```
- 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 ```
- 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.