Sep 23, 2010

Getting XBMC to work with Beyond TV's chapters.xml files

XBMC doesn't appear to read Beyond TV's commercials skip files (named file.chapters.xml), although it has support for them.

I found that recent Beyond TV software writes these files out as Unicode (UTF-16) which probably confuses XBMC. So I wrote this quick Python script to convert all the chapter files given on the command line to UTF-8 in /tmp. Save it as "convert_chapters.py" and run with "python convert_chapters.py *.chapters.xml"
#!/usr/bin/python
# Convert all the files given on command line from utf-16 to utf-8 in /tmp

import os.path, sys, codecs

for filename in sys.argv[1:]:
    f = codecs.open(filename, encoding="utf-16")
    data = f.read()
    f.close()
    newfilename = "/tmp/%s" % os.path.basename(filename)
    f = codecs.open(newfilename, "w", encoding="utf-8")
    f.write(data)
    f.close()
The newly converted files work under XBMC now. They do not appear as chapters (chapter skip still does not use this information) but as sort of on-the-fly video editing information. When you reach the commercials while viewing a recorded video you'll see XBMC doing an automated skip to the end of the commercial block, so you don't even have to reach for the remote.

Note: on Windows there is no "/tmp" so you should replace that with an appropriate location. Or you can replace newfilename with filename in the codecs.open() call and have it overwrite the chapter files in place - but make sure to make a backup first in case things don't go as planned!

No comments:

Post a Comment

Please keep your message on topic if at all possible...