Viewing TV on Mac OSX using an HDHomeRun and Plex
Friday, May 10th, 2013The original HDHomeRun plug-in for Plex Media Server no longer works on the later versions of Plex and V2 is still in need of work. Thanks to those on the PlexApp forums, especially enduser, I am able to easily generate a quick work-around until the plug-in can be finished.
The work around involves creating .strm files for each of the active channels. I wrote a simple bash script, to run as a user on OSX, to find the HDHomeRun device, determine the channel list, and create a number of .strm files in your ~/Movies folder. Make sure to run this app as the person who will be running Plex.
To view a channel, select Video Channels in Plex, then select Movies, and finally select the channel you wish to view.
Copy the following code to a file on your desktop, create-hdhomerun-strms.sh, and when comfortable with the code within, execute the script in the Terminal app, using
sh create-hdhomerun-strms.sh
#!/bin/sh
CleanUp()
{
rm -rf $SCAN_FILE
}
TUNER_ID=$(hdhomerun_config discover | awk '{ print $3 }')
SCAN_FILE=/tmp/${TUNER_ID}.log
trap CleanUp 1 2 3 15
read -p "Ready to create .strm files for HDHomeRun Tuner ID $TUNER_ID? " -r
if ! [[ "$REPLY" =~ ^[Yy]$ ]]
then
exit 1
fi
if ! [ -r $SCAN_FILE ]
then
echo
echo Please wait while scanning channels. This may take a few minutes
echo
hdhomerun_config $TUNER_ID scan /tuner0 $SCAN_FILE
fi
for IDX in 0
do
sed -En "
/^SCANNING: [0-9]/ {
s/^SCANNING: //
s/ .*//
h
}
/(encrypted)/ d
/^PROGRAM [0-9]+: 0/ d
/^PROGRAM [0-9]+: [0-9]+\.[0-9]+ / {
s/^PROGRAM ([0-9]+): ([0-9]+\.[0-9]+) ([- A-Z0-9a-z.]+)/hdhomerun:\/\/$TUNER_ID-$IDX\/tuner$IDX \2 \3\?channel=auto:##\&program=\1\&range=/
G
s/(.+):##(.+)\n([0-9]+)/\1:\3\2/
P
}
" $SCAN_FILE | while read url
do
file=$(echo $url | sed -e 's/.* //' -e 's/\?.*//')
if [ $IDX -gt 0 ]
then
file="$file ($IDX)"
fi
file="${file}.strm"
echo $url > ~/Movies/$file
echo $file
done
done



