Fixing Sickbeard’s Plex Notifications

I use Sickbeard in 2018. Even though Sickbeard’s development is dead it still works for me and switching to something like Sonarr would take time I don’t want to spend.

Sickbeard is able to notify Plex when a new show is downloaded and force Plex to update its libraries. At some point either Plex or Sickbeard broke support for this. I found a way around to fix it.

The idea is we will write our own script to update Plex. We’ll give it a name and location that fits into what Sickbeard expects to find.

You’ll need a web server on the same network as Sickbeard and Plex.

You’ll need to get your Plex Authorization Token.

You’ll need the Plex library ID of the library you want to update. (Look for librarySectionID= in the same place you get the authorization token)

On your web server in the web root:

mkdir xbmcCmds
cd xbmcCmds/
mkdir xbmcHttp
cd xbmcHttp/

Once in the xbmcHttp dir, create index.php and add to it:

<?PHP
file_get_contents('http://PLEX-SERVER-IP:32400/library/sections/YOUR-LIBRARY-ID/refresh?force=1&X-Plex-Token=YOUR-PLEX-TOKEN');
print 'OK';

Replace PLEX-SERVER-IP with your Plex server’s IP address. Replace YOUR-LIBRARY-ID with the Plex library ID you want to update. Replace YOUR-PLEX-TOKEN with your Plex Authorization Token.

Now in Sickbeard go to Config and then Notifications. Make it look like the screen shot below, adding in your web server’s IP address.

That’s it. Save it and test. You should see the Plex library update.
 

UNRAID is Slow, What to do?

I recently built an UNRAID server for use as backup storage. The plan was to build a computer and then shuck and use the many USB drives I already had for storage. This mostly went to plan.

TLDR: Network equipment lies about connection speed.

I went with UNRAID because it boots off of a USB drive; saving a SATA port, works well with mixed drive types and sizes, and you can take a drive out of the array and read/write to it from any other PC.

The build:

Case: Cooler Master Elite 342 RC-342-KKRJ-GP 400W
CPU: Intel Celeron 2.90 GHz Dual Core FCLGA1151
Motherboard: MSI Pro Series Intel B250
Memory: Corsair Vengeance LPX 16GB (2x8GB) DDR4 DRAM 2400MHz
Boot Drive: SanDisk Cruzer Fit CZ33 16GB
Misc Items likes fans and cables I already had.

I had five 4TB Western Digital drives in USB enclosures that I planned on using in UNRAID. I bought a 4TB SATA drive, getting me a total of six drives. All of the USB drives appeared to work fine in their enclosures, no SMART errors, no problems reading and writing to them. After taking the drives out of their enclosures and putting them into the new server, three of them started reporting SMART errors. I wasn’t happy about this, but figured I would load them up and see what happens, only buying new drives if they actually failed.

Right off my transfer speeds were limited to 10-12MB/s. I was expecting more like 100MB/s, being on a gigabit network. After fiddling around for a bit I did a restart, UNRAID refused to boot. I got a monitor on it and saw in the message buffer that one of the drives was freaking out. I removed the drive and UNRAID booted up. I still had the slow transfer speeds though.

I disconnected the other two SMART error reporting drives. It was still slow. I logged in via the command line and did an rsync between one of the formerly USB drives and the new drive, still slow, albeit I was getting 15MB/s now. I put the two SMART error reporting drives back in.

I was a little lost at this point. If rsync between two sata drives was only getting me 15MB/s, something was seriously up. I figured the former USB drives were crappy and bought another new 4TB SATA drive. A day later I tried another rsync between the new drives. Same problem.

Now I started down the horrible path of googling ‘UNRAID slow.’ There wasn’t much to see here. Lots of posts about parity drives causing slow downs; I wasn’t using a parity drive. Lots of posts about using a cache drive; also not relevant since I’m not using parity.

I kept pounding my head trying everything and anything I could think of until I stumbled onto a problem with rsync. I was using the -z option, this compresses the files before they are copied. This is all good when sending files over the Internet like I normally would, but when going disk to disk the overhead kills the transfer speed. I ditched the -z option from my rsync command and I was getting full speed between all of my disks. 140MB/s+

Then I tried to do a copy from my Windows desktop to UNRAID’s windows share. Slow again. 10-12MB/s. I tried FTP, same deal. I tried rsync (no -z), same deal. Now I had a network problem.

My desktop, the unraid server, and my router all had gigabit ports. My desktop could do 100MB/s (Gigabit speeds, bit vs byte) to other devices in my house. Nothing could do better than 12MB/s to UNRAID though. UNRAID and my router both showed that UNRAID was connected at 1Gbp/s. Something was a liar.

I tried my laptop on the same ethernet cable and wall jack that UNRAID was using. The speed was bad. I tried UNRAID on a different cable and wall jack. The speed was great. Something was wrong with my cabling.

I swapped cables, redid did the wall jacks, no luck. I then tried making a simple network between my desktop and UNRAID, just a switch and two ethernet cables. The speed was great. There was only one thing left that could be the problem, the switch built into my router.

In the end, it ended up being a dodgy port in the router’s switch. Even though it says devices are connected at gigabit speeds, they are not. It works fine as a 100mbp/s port. No latency or dropped packet problems. I plugged the UNRAID server into a different port on the router, problem solved.

That’s my UNRAID saga. Hopefully my experience will help someone else.

Almost as a side note, I’ve been very happy with UNRAID. I have a 24TB array about 1/3 full. I have this 24TB array split into two 12TB user shares. I sync up the shares with rsync now and again as a backup. I’m not using parity. If a drive fails in the array I’ll either replace it with live data or use the backup in the other share to replace it. I still have a good collection of USB drives and I plug those in and rsync to them too, making for a nice third backup.

Here are some of the scripts I use to keep everything synced.

Syncing between the user shares:

rsync -Wa –delete –progress /mnt/user/UNRAID/* /mnt/user/UNRAID-BK/

Syncing between internal disks and USB disks:

dmesg | tail -10
echo -n “Mount which device? ”
read DEVICE
echo “Mounting $DEVICE”
mkdir /root/disk
mount $DEVICE /root/disk
if [ $? -gt 0 ]
then
echo “Could not mount $DEVICE”
exit
fi
echo -n “Which disk to sync? ”
read DISK
echo “SYNCING disk$DISK!”
rsync -aW –delete –progress /mnt/disk$DISK/* /root/disk
echo “UMOUNT $DEVICE”
umount $DEVICE
rmdir /root/disk

Amazon Fire TV NES, SNES, and GBA Emulators

The Amazon Fire TV can run NES, SNES, and GBA games. You can even use the included remote, though the game controller works much better.

I made up a package with a batch script that makes it pretty easy.

MyTechJam took it a big step further and made a video tutorial.

 

Here is how to play NES, SNES, and GBA games on your Amazon Fire TV.

Note: This does not require you to root your Fire TV. You will not lose access to the Amazon interface. Nothing will be removed or change. If in doubt look over the package you download and definitely look over all of the .bat files.

Enable USB Debugging and Find out the IP address of your Fire TV

This steps turns on the features that allow you to remotely install software on your Fire TV.

  1. From the Fire TV Home screen, select Settings
  2. Go to System -> Developer Options
  3. Select ADB Debugging to turn it ON
  4. Go to System -> About -> Network, and take note of the Fire TV’s IP address

(Thanks XBMC Wiki)

Download and Extract my Installer Package

Amazon Fire TV Emulator Package: Download

Once you have it downloaded, unzip it.

Install Emulators and Send Your ROMs to the Amazon Fire TV

Installing the emulators:

  1. Double click on INSTALL-EMULATORS.bat (in the installer package)
  2. When prompted, enter the IP of your Fire TV
  3. You should see the emulators install with a ‘Success’ message

Copying the ROMS:

There are folders for ROMs for each system in the installer package. Copy your ROMs into the folder appropriate for them. If your ROMs are zipped, unzip them. Make sure the NES ROMs have a .nes extension, SNES .smc, and GBA .gba.

To play GBA games you’ll need a GBA bios file. Put it in the ROMS-GBA folder.

Once you have everything in the appropriate folders, double click on INSTALL-ROMS.bat. When prompted, enter the IP of your Fire TV. You should see everything copy over.

If at some point in the future you want to add more ROMs to your Fire TV, just add them into the appropriate folder and double click on INSTALL-ROMS.bat again.

Launch Emulators and Configure 

You should now have your emulators and ROMs installed on the Fire TV. Unfortunately side loaded applications do not appear in the Home screen, you have to launch them via the Settings menu.

  1. From the Fire TV Home screen, select Settings
  2. Select Applications
  3. Find and select the emulator you want. (Nesoid, Snesoid, GameBoid)
  4. Select Launch Application

You will want to go into the settings for the emulator and map the buttons for the remote (or your controller) to the game buttons.

Where to go From Here?

If you’re only using the remote that came with the Fire TV you’ll want to get a real controller. The remote works OK for RPGs and games that don’t require twitchy actions. Amazon sells a very good controller made for the Fire TV. XBOX 360 and PS3 controllers work well too.

The emulators I’ve included are not the best out there. There are some really good commercial Android emulators out there, installing and using them makes for a better experience.

What Exactly does the Installer Package do?

The general idea is that it side loads the emulator’s apk files via winadb. The installer package (if you can call it that) contains a apks for the emulators, winadb, and a couple of .bat files. The .bat files launch winadb with the appropriate commands to connect to the Fire TV and install the emulators. You can easily modify the .bat files to allow you to install other emulators.

Amazon Fire TV and XBMC

My review of XBMC on Amazon’s Fire TV can be summed up easily, I’ve moved from my custom built HTPC to using a Fire TV for my day to day TV watching.

Commonly asked question I see about the Fire TV

  • It’s easy to install.
  • You don’t need to root the Fire TV
  • I have it plugged into a 5.1 surround system via HDMI. I didn’t have to go to any trouble to make it work.
  • I have about 3TB of media on an SMB share. My library is shared via MySQL. I had no problems getting this to work with the Fire TV. Navigating the library is just as snappy as my old HTPC.
  • The Fire TV will play a 1080p 5.1 surround sound movie without issue.
  • The Fire TV will play a 1080p MPEG-2 stream from a HDHomerun device without issue.
  • The Fire TV will play an USTVNow stream without issue.
  • The default remote map isn’t good. There are much better keymaps out there.
  • I could not get it to work correctly with a FLIRC and a Harmony remote. (See Cons below)
  • You can side load emulators. Anything up the PS1/N64 generation works. Though you’ll want to root it so you can use storage devices other than the built-in. This is much, much easier than getting emulators to work on other XBMC hardware/operating systems.
  • XBOX 360 and PS3 controllers work.
  • It’s by far the easiest way to get Netflix, Amazon Prime, and XBMC all on the same box.

Pros for the Fire TV

  • It makes no noise
  • It doesn’t produce any heat
  • It’s small. I have it hidden behind a photo 5×6 frame on my entertainment center.
  • It’s cheap! The Fire TV is $100. I spent about $375 on my HTPC less than a year ago. I thought it was cheap at the time.
  • You don’t have to jack with it much to get XBMC going. No custom hardware to put together, no OS install, ect, ect.

Cons for the Fire TV

TL;DR

The Amazon Fire TV is the best hardware to run XBMC on.

USTVnow Command Line Stream File Generator

I’ve changed the USTVnow script from my previous post. I needed it to work without XBMC running or even installed.

The script below will login into USTVnow, grab the stream info for each channel you have access to and then write out .strm files to a directory of your choosing. To use it just change email, password, and stream_dir to your own credentials.

I have the script set to run via CRON every thirty minutes. Then I have the scripts stream_dir setup as a source in XBMC so I can play the stream files.

The script is pure Python and should run on anything that will run Python. No need to have XBMC working.

Download: ustvnow.py

7/14/15: I’ve updated the script to work with USTVNOW’s website changes.

#!/usr/bin/python
'''
    ustvnow XBMC Plugin
    Copyright (C) 2011 t0mm0

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

20131227 - Modified by Dean Vaughan - http://deanvaughan.org to work from command line and output stream files to a directory
20140610 - Modified by Dean Vaughan - http://deanvaughan.org to work without XBMC running or installed

'''
email = 'youemail'
password = 'yourpassword'
stream_dir = 'Streams'

stream_type = 'rtmp'
quality = '1'

import cookielib
import os
import re
import urllib, urllib2
import sys

class Ustvnow:
    __BASE_URL = 'http://lv2.ustvnow.com'
    def __init__(self, user, password):
        self.user = user
        self.password = password

    def get_channels(self, quality=1, stream_type='rtmp'):
        self._login()
        html = self._get_html('iphone_ajax', {'tab': 'iphone_playingnow',
                                              'token': self.token})
        channels = []
        for channel in re.finditer('class="panel".+?title="(.+?)".+?src="' +
                                   '(.+?)".+?class="nowplaying_item">(.+?)' +
                                   '<\/td>.+?class="nowplaying_itemdesc".+?' +
                                   '<\/a>(.+?)<\/td>.+?href="(.+?)"',
                                   html, re.DOTALL):
            name, icon, title, plot, url = channel.groups()

            #tmp work around till ustvnow stablizes changes
            name = name.replace('\n','').replace('\t','').replace('\r','').replace('
','').replace('
','').replace('"','').replace(' ','') if not name: name = ((icon.rsplit('/',1)[1]).replace('.png','')).upper() name = name.replace('WLYH','CW').replace('WHTM','ABC').replace('WPMT','FOX').replace('WPSU','PBS').replace('WHP','CBS').replace('WGAL','NBC').replace('WHVLLD','MY9') try: if not url.startswith('http'): now = {'title': title, 'plot': plot.strip()} url = '%s%s%d' % (stream_type, url[4:-1], quality + 1) # if self.premium == False: # if name not in ['CW','ABC','FOX','PBS','CBS','NBS','MY9']: # raise print name channels.append({'name': name, 'url': url, 'icon': icon, 'now': now}) except: pass return channels def _build_url(self, path, queries={}): if queries: query = build_query(queries) return '%s/%s?%s' % (self.__BASE_URL, path, query) else: return '%s/%s' % (self.__BASE_URL, path) def _fetch(self, url, form_data=False): if form_data: req = urllib2.Request(url, form_data) else: req = url try: response = urllib2.urlopen(url) return response except urllib2.URLError, e: return False def _get_html(self, path, queries={}): html = False url = self._build_url(path, queries) response = self._fetch(url) if response: html = response.read() else: html = False return html def _login(self): self.token = None self.cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj)) urllib2.install_opener(opener) url = self._build_url('iphone_login', {'username': self.user, 'password': self.password}) response = self._fetch(url) #response = opener.open(url) for cookie in self.cj: if cookie.name == 'token': self.token = cookie.value def build_query(queries): return '&'.join([k+'='+urllib.quote(str(v)) for (k,v) in queries.items()]) ustv = Ustvnow(email, password) channels = ustv.get_channels(int(quality), stream_type) if(len(channels)): old_streams = os.listdir(stream_dir) for old_stream in old_streams: if 'USTV-' in old_stream: os.remove(stream_dir + '/' + old_stream) for c in channels: title = c['now']['title'] title = re.sub('[^\w\-_\. ]', '', title) title = title.replace(' amp ', ' and ') f = open(stream_dir + '/USTV-' + c['name'] + ': ' + title + '.strm', 'w') f.write(c['url']) f.close()

My XBMC Build as of January 2014

I was asked to give a run down of the XBMC computer I am currently using. It was assembled from parts and is running openELEC.

HTPC XBMC Computer
The case looks good.

My XBMC PC is capable of:

  • Playing 1080i video with no stutter or buffering. (Both local files and files from a Windows file server)
  • Playing 1080i streams of local cable TV channels.
  • Recoding those streams DVR style.
  • Playing 720p streams of premium cable TV channels via USTVNOW. (The 720p limit is from USTVNOW, not the computer)
  • Using my surround sound system for 5.1 sound.
  • Playing older video games from Super Nintendo, NES, Game Boy, Genesis, ect.
  • Throwing some colors on the wall with a Light Pack.

Parts List:

Total Cost: $638.26

Not cheap. You get what you pay for.

Some notes on the hardware:

My previous HTPC was an ASROCK Ion 330. It was prone to overheating. A lot of this was due to the small case size. The CPU fan lay under a spinning hard drive with a 1/4 inch gap. The fan blew hot air onto a hard drive producing its own heat. This was then blown out of the case by a 25mm fan. Because of the cramped quarters I didn’t have any other options for larger fans or moving parts. While the PC never got hot enough to shutdown it did get hot enough to make me worry about.

The case on this XBMC PC is roomy. The fan from the CPU isn’t constricted. It has a 65mm case fan with room for a second. I’m using an SSD drive as they produce little to no heat. The SSD has the added benefit of being silent. The PC as a whole is quiet enough that you cannot hear it without putting your ear near the case. Even under a load it doesn’t get hot enough to spin the fans up. Idle temperature is around 40C, loaded is around 55C.

The CPU has an integrated GPU. It comes with a heat sink and fan in the box. The CPU is overkill for playing videos. I went big with the CPU because someday I plan on emulating N64 and Playstation games. Possibly even Game Cube.

The HDHomeRun is for watching cable TV. If that’s not applicable to you, then no need to buy one.

The lighting arrangement can be had in a DIY kit for $50.

Software:

Putting it all together gets you this:


My camera is unable to capture the lighting effect. Here is a video from the vendor showing how it looks.
ADAlight demo from adafruit industries on Vimeo.

 

 

Running Emulators on OpenELEC

Being able to run emulators on an OpenELEC computer can be tricky. It takes a fair bit of knowledge from several different areas to setup. I’m going to try to give a good overview of putting all together into a working system. By the end you’ll have a setup that allows you to play all of your old games from the comfort of your couch.

Something to consider, the build of RetroArch I’m using doesn’t have emulators for a lot of systems. Here is a list of what it can emulate.

I’m going to break this up into sections. I’m going to assume you have OpenELEC installed and working.

Getting ROMs on OpenELEC

Be sure to organize your ROMs into folders based on their console. EG: put your SNES ROMs in a snes folder, put your NES ROMs into a nes folder, and so on.

By far the easiest way to get ROMs onto your OpenELEC computer is to put them onto a flash drive and plug it in. Once plugged in use XBMC to add a new file source pointing to the flash drive.

Go to Settings and then File Manager
Go to Settings and then File Manager
Select Add Media and then Browse
Select Add Media and then Browse
Select Root File System then Media. Your drive will be one of the folder in there. Select it.
Select Root File System then Media. Your drive will be one of the folders in there. Select it.
Once you've selected your flash drive, click OK.
Once you’ve selected your flash drive, click OK.

The file source is now added and your ROMs are now easily accessible by OpenELEC/XBMC.

Getting RetroArch working on OpenELEC

Our hero and savoir, zaggash, has written a RetroArch addon for OpenELEC which makes installing all of the emulators a breeze. First thing we need to do is download a copy of the addon and install it on OpenELEC. Go to Zaggash’s site and download build appropriate for your computer.  For instance I use the Generic build. Take that file and put it on the flash drive from the previous step and then plug the flash drive back into your OpenELEC computer. Now we need to install it.

Go back to System, then select Addon Browser. From there select Install from Zip file. Navigate to the source we created in the previous step and install the emulator.retroarch ZIP file.

Now we need to add another file source that points to RetroArch. Go back to System->File Manager->Add Source->Browse. This time select Home Directory->.xbmc->addons->emulator.retroarch->bin. Call the new source Emulator Bin.

Getting ROM Collection Browser working on OpenELEC

ROM Collection Browser is also available as an addon. It gives you a nice menu in XBMC to launch your ROMS from. You can install it via addon manager without doing anything special.

Once installed start the addon. We’ll need to add your ROMs. Here is how I would do it for Game Boy Advance ROMs.

Start ROM Collection Browser. Hit the Menu button on your remote and select Add Rom Collection->Scrape game info and artwork online->Game Boy Advance. Now we need to select where RetroArch is, open your Emulator Bin source and select retroarch.sh.

Now it will ask you for any arguments RetroArch needs to start. Change it to: vba_next “%ROM%”

Note that vba_next is the core from RetroArch. If you’re adding different game systems the core name will change. See here for a complete list of cores: http://sourceforge.net/p/zaggxbmcaddons/wiki/Core%20List/

Once it is done scrapping the artwork for your games you should be able to launch them with the remote.

Getting a controller to work on OpenELEC

For me, this was the toughest part of the setup. I tried numerous controllers and spent a lot of time banging my head against the wall. In the end I settled on a corded SNES USB controller.

Wireless XBOX 360 controller: An XBOX 360 controller will actually work just by plugging it in, problem is that the drivers included with OpenELEC are not able to control the LED lights on the controller. Where as on an XBOX the lights will go solid in a spot to represent which player you are, on OpenELEC they continue to flash, forever. If you can deal with the flashing its all good. I’ve had thoughts of taking the controller apart and removing the LEDs.

PS3 Dual Shock 3 Sixaxis: I couldn’t get the controller to work either wired or in Bluetooth mode. In both cases the OS detects it as a HID device, but never as a joystick.

Random corded USB controllers: I’ve had good luck with my SNES USB, old Microsoft Sidewinder, and Logitech USB controllers. All of which only needed to be plugged in to work.

Once you’ve made a choice on controllers you have to let RetroArch know about it. You’ll need to SSH into your OpenELEC computer. The login is root and the password is openelec.

Once logged in:

cd .xbmc/addons/emulator.retroarch/bin/
./retroarch-joyconfig

From there follow the prompts to hit the buttons on your controller. If you don’t have a button it asks for, just hit any button. If says anything about not finding a joystick, you’re in trouble.

Once down you’ll get a bunch of lines mapping buttons to action, you’ll want to copy all of this and put it at the bottom of /storage/emulators/retroarch/config/retroarch.cfg

Also at the bottom of your retroarch.cfg file add:

input_enable_hotkey_btn = 6
input_exit_emulator_btn = 7

Replace 6 and 7 with numbers representing the buttons on your controller you want to hit that will exit a ROM you’re playing. On my controller 6 and 7 represent the Select and Start buttons.

… and that’s it. You should now be able to start Rom Collection Browser, find a game with the remote, start it, play it with a controller, then return to XBMC by hitting two buttons on the controller.

 

How to install the Free Cable Addon on OpenELEC

Getting the Free Cable addon to work under OpenELEC takes a little bit of command line work. You’ll need to install some Python modules and create some directories on your OpenELEC computer.

Here’s what you need to do to get Free Cable working:

Install the Blue Cop Repository

From that repository, install Free Cable.

Open the configuration for Free Cable and then save it as is.

SSH to your OpenELEC computer. Run the following on the command line:

wget http://www.crummy.com/software/BeautifulSoup/bs4/download/4.3/beautifulsoup4-4.3.2.tar.gz
cd beautifulsoup4-4.3.2/
python setup.py install --prefix=/storage/usr
cp -R /storage/usr/lib/python2.7/site-packages/bs4/ /storage/usr/lib/python2.7/site-packages/beautifulsoup

wget http://deron.meranda.us/python/demjson/dist/demjson-1.6.tar.gz
tar zxvf demjson-1.6.tar.gz
cd demjson-1.6
python setup.py install --prefix=/storage/usr

mkdir /storage/.xbmc/addons/script.module.free.cable.database/
mkdir /storage/.xbmc/addons/script.module.free.cable.database/lib

touch /storage/.config/autostart.sh
chmod 755 /storage/.config/autostart.sh

Once that’s done edit /storage/.config/autostart.sh and add

#!/bin/sh
export PYTHONPATH=$PYTHONPATH:/storage/usr/lib/python2.7/site-packages/

If you already have ‘#!/bin/sh’ in the file, don’t add is again.

Reboot. Free Cable should now work.

Keeping hdhomerun_recorder always running under OpenELEC

I was having trouble keeping hdhomerun_recorder always running under openELEC. Sometimes it wouldn’t start at boot, or sometimes it would randomly stop running, causing my shows not to be recorded. Below is a short Python script I came up with. It runs under CRON every five minutes. If hdhomerun_recorder isn’t running, it starts it. I have not had a problem since.

import os

find = 'hdhomerun_recorder'
start = '/storage/etc/hdhomerun_recorder/start.sh &'

f = os.popen('ps ax | grep -v grep | grep "' + find + '"')
out = f.read()
if not find in out:
  print 'Running: ' + start
  os.system(start)

USTVNOW and HDHomeRun Stream Files in XBMC

What you see here is the act of a desperate man who got sick of trying to make XBMC’s PVR support work. I tried for several days to get tvheadend to work with my HDHomeRun. In the end I gave up and went my way. What you see may be a mess to setup but it works very well for me.

When all setup XBMC will have a directory full or playlist files representing your channels/streams. The playlist files will be named after the channel they represent along with the current and next show that is going to play.

Here is a video to show what I mean:

Quick note on my setup; I have an HDHomeRun receiving QAM channels from Cox cable. These channels come in as by product of the Internet service I receive. Via Cox and the HDHomeRun I receive local network stations. I also have an USTVNOW account for basic cable channels. Why do I use USTVNOW instead of getting basic cable from Cox? USTVNOW is about $10 a month cheaper and receives more channels.

Installation is a crazy mess. I didn’t expect to release this but I figured at the least the USTVNOW streams will be useful to someone.

I did all of this under openElec. XBMCbuntu works. Other Linux based installs should work. Windows will probably work if you install Python and something similar to CRON.

Prerequisites:

For USTV: Just make sure you have the USTVNOW plugin working. XBMC HUB Article About It

For HD Home Run: Make sure its connected to your network and can view some channels. Have hdhomerun_config working. (Part of libhdhomerun: Download It

Installation:

  • Download this repo. (Direct link to zip)
  • Unzip it and copy everything into /storage/dean. If you’re the picky sort this is where you begin to change pathnames. For narcissistic reasons I’m going to assume you’ve put everything in /storage/dean.
  • Make a directory: /storage/Streams. This is where all your stream files will go. Add that directory as video source in XBMC.

USTVNOW Streams

  • We’re going to add a script to the USTVNOW addon to download a list of channels and turn them into stream files (.strm). We’re going to place this in CRON so it updates itself.
  • Edit /storage/dean/ustvnow_stream_grabber.py and change the email and password variables to your USTVNOW credentials.
  • Move /storage/dean/ustvnow_stream_grabber.py to the directory your USTVNOW addon resides in. For me its /storage/.xbmc/addons/ustvnow/
  • Make sure it works by running /storage/dean/ustvnow.sh. After that you should see a bunch of stream files in /storage/Streams. Each file should represent one of your USTVNOW channels.
  • Add a cron job so that /storage/dean/ustvnow.sh is ran every thirty minutes. Example in /storage/dean/crontab.

Go to your stream video source in XBMC. You should be able to play each file in there.

HDHomeRun Streams

  • We’re going to build stream (.strm) files for each channel your HDHomeRun receives.
  • On a Windows box open up HDHomeRun Setup and look at the tab that shows all of your channels, Digital Cable for me.
  • Write down the channel numbers and what channel they represent. (FOX, ABC, ect)



  • Two options now. Build the stream files by hand or use HDHomeRun Stream Builder to do it for you.
  • If you’re doing it by hand and pretending we’re working on the file for CBS in Fort Smith, AR:
  • Create a file named KFSMDT.strm
  • Open the file up and add this: hdhomerun://103D1F0E-0/tuner0?channel=auto:92&program=1
  • Notice a few things you’ll need to change.
  • 103D1F0E-0 is the ID of my tuner. You’ll need to change it to your tuner’s ID.
  • tuner0 is the first tuner on my HDHomeRun. The second tuner is tuner1. I watch TV on tuner0. I record TV on tuner1.
  • channel=auto:92&program=1 represents CH92 – 1 from HDHomeRun Setup. Change the 92 and the 1 as appropriate for your channels.
  • Save the file and put it in /storage/dean/Streams-default
  • Repeat this for every channel your HDHomeRun receives.
  • HDHomeRun Stream Builder will automate all of this for you, but it is a PITA to setup. (As if all the above hasn’t been)
  • If you don’t care about having the currently playing show in the file name, copy the all the .strm file you made into /storage/Streams and call it done. Just like the USTVNOW streams they should play as if they were any other video file.

Getting the currently playing show to be in the HDHomeRun stream’s file name

  • Theory behind this is that we’re going to use mc2xml to download TV scheduling information, parse it, and rename our stream files using the info.
  • Get mc2xml working for your zip code. There is a copy in /storage/dean/mc2xml-local
  • For me the command line is ./mc2xml -c us -g 72714 -d 72 -f (72714 is my zip code)
  • Have cron run /storage/dean/update_xmltv.sh once a day. Example in /storage/dean/crontab
  • Have cron run /storage/dean/update_streams.sh every thirty minutes. Example in /storage/dean/crontab
  • Now your stream files in /storage/Streams should be all renamed with the current show playing.