Iso-play.sh
Note: The correct title of this article is iso-play.sh. It appears incorrectly here due to technical restrictions.
This script can be used as a replacement external player for ISO files and works with local paths or storage groups. It automatically detects between Bluray and DVD images, and either mounts as a filesystem using the loopback device, or opens directly. Remote content must be mounted over NFS.
Configuration to use this script is straightforward. Under Setup -> Media Settings -> Video Settings -> File Types, simply replace the default player for the "<.iso>" file type with the "iso-play" script. If the ISO images will be accessed from remote frontends, then define NFS mounts to duplicate the folder structure to match the local server.
By default, this script mounts Bluray discs at /loop. This directory must be created, or another directory specified in the script. Also, the line near the end of the /etc/sudoers file that starts with Cmnd_Alias MYTHDORA
needs to have the /bin/mount
and /bin/umount
commands appended to the end.
## Copyright 2010 Steve Schulz (steve.schulz@earthlink.net) ## ## MythTV script to merge DVD and Blu-Ray playback for any ISO image, supporting both local file paths ## and Storage Groups. Requires mythtv 0.24 or later. For remote frontend playback, assumes that NFS ## mounts are used to enable access using standard linux / unix file paths. ## MySQL server access ## . ~/.mythtv/mysql.txt ## Define mount point for Blu-Ray ISO's ## mp="/loop" #### Functions #### sg2path () { ## Convert a storage group URL into a local file path ## (using NFS mounts to duplicate layout) ## ## parse SG URL ## SGtype=`echo "$1" | awk -F@ '{print $1}'` server=`echo "$1" | awk -F@ '{print $2}' | awk -F: '{print $1}'` port=`echo "$1" | awk -F@ '{print $2}' | awk -F: '{print $2}' | awk -F/ '{print $1}'` fil=`echo "$1" | awk -F@ '{print $2}' | sed -e "s%$server:$port%%"` # get SG dirs (using local mysql access) ## paths=`echo "select groupname,dirname from storagegroup where groupname='Videos'" | mysql --user=${DBUserName} --password=${DBPassword} --database=${DBName} --host=${DBHostName} > /tmp/out1.$$` # get SG dirs (using remote mysql access) # # paths=`ssh ${DBUserName}@${DBHostName} "echo \"select groupname,dirname from storagegroup where groupname='Videos'\" | mysql --user=${DBUserName} --password=${DBPassword} --database=${DBName} --host=${DBHostName}" >/tmp/out1.$$` for i in `cat /tmp/out1.$$` do test -e "$i$fil" case $? in 0) echo "$i$fil" | sed -e "s://:/:" ;; esac done /bin/rm /tmp/out1.$$ } #### End Functions #### #### Begin Main Program #### cwdir=`pwd` ## If using a Storage Group URL, convert to pathname ## case `echo "$1" | grep '@'` in "") imag="$1";; *) imag=`sg2path "$1"`; cwdir="" ;; esac echo "URL resolves to path: $imag" ## Determine if ISO is a BD or DVD ## dvdtest=`head -30 "$imag" 2>/dev/null | strings | grep VIDEO_TS` case $dvdtest in "") bdtest=`head -30 "$imag" 2>/dev/null | strings | grep BDMV` case $bdtest in "") echo "Error -- not a DVD or BluRay image, aborting." exit 1 ;; *) typ=bd ;; esac ;; *) typ=dvd ;; esac ## Open mythavtest player with appropriate arguments ## case $typ in bd) bas=`basename "$imag"` sudo umount "$mp" 2>/dev/null sudo mount -o loop -t udf "$imag" "$mp" echo "Playing Blu-Ray disc $imag..." mythavtest bd://$mp/ >/dev/null echo "" sudo umount "$mp" && echo "Unmounted $mp OK." exit 0 ;; dvd) dir=`dirname "$imag"` bas=`basename "$imag"` echo "Playing DVD disc $imag..." mythavtest dvd:/"$cwdir"/"$dir"/"$bas" >/dev/null exit 0 ;; esac