Sunday, January 06, 2013

XBMC and overlapping subtitles with iPlayer addon

There's often overlapping subtitles with XBMC and BBC iPlayer addon. Rather than modify actual addon and losing changes every time it's updated I hacked up script that edits SRT file after it's downloaded from BBC site but before XBMC reads it.

# Install inotify-tools
apt-get update
apt-get -y install inotify-tools

# Download perl script to mangle sub timings
cd /home/xbmc

# Create background processing script
cat <<'__EOF__' >/home/xbmc/
# Default location for iplayer subs
cd "/home/xbmc/.xbmc/userdata/addon_data/"
# Infinite loop
while true
 # Use inotify to monitor changes on disk
 inotifywait -e create,modify
 # Don't proceed until xbmc has finished writing subs to file
 while lsof
  # wait 100ms until next check
  sleep 0.100
 # fix overlapping subs
 perl ~/ -f -u -dd
 # save original subs
 mv -f 
 # and use our new fixed ones as default
 mv -f
 # Cleanup
 rm -f

# Make script executable
chmod a+x /home/xbmc/

# Launch script on background when system is restarted
echo 'su -l -c "/bin/bash /home/xbmc/" xbmc &' >>/etc/rc.local

No comments:

Post a Comment

Got something to say?!