ql_nero

A Quod Libet plugin to write a Nero Linux audio compilation file.

Get the source file here: ql_nero.py
To install, put it into ~/.quodlibet/plugins/songsmenu/

It will put selected songs in a Nero Linux audio compilation and write to the file /tmp/quodlibet.nlc - it does nothing fancy. Just load it into Nero and Nero should do all the dirty work.

# This plugin is based on the serpentine plugin by Benjamin De Besses
# and Joe Wreschnig. It just writes a NERO audio compilation file in
# the /tmp directory to open with NERO Linux
# Copyright (C) 2007  Francois du Toit <bluegraydragon@gmail.com>

# 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/>.

import os, xml.sax.saxutils
import util
from qltk import ErrorMessage
from plugins.songsmenu import SongsMenuPlugin

gap = 0 # gap in frames (75 frames/sec)

head = '''<?xml version='1.0' encoding='UTF-8'?>
<Compilation type='5' media='1' />
<AudioTracks>
'''

track = '''
  <Track>
    <Origin encoding='UTF-8' value=%s />
    <Pregap value='%d' />
  </Track>
'''

tail = '''
</AudioTracks>'''

class Serpentine(SongsMenuPlugin):
    PLUGIN_ID = 'BurnWithNero'
    PLUGIN_NAME = _('Write Audio CD with Nero')
    PLUGIN_DESC = 'Puts a Nero compilation in /tmp/quodlibet.nlc'
    PLUGIN_ICON = 'gtk-cdrom'
    PLUGIN_VERSION = '0.2'

    def plugin_songs(self, songs):
        if not util.iscommand("nero"):
            ErrorMessage(
                None, "Nero not found",
                "The Nero burning program was not found. "
                "You can get Nero at http://www.nero.com/eng/NeroLINUX.html").run()
        else:
            files = [song['~filename'] for song in songs]

            file = '/tmp/quodlibet.nlc'
            f = open(file, 'w')
            f.write(head)
            for file in files:
                f.write(track %(xml.sax.saxutils.quoteattr(file), gap))
            f.write(tail)
            f.close()