#!/usr/bin/env python
#
# $Source: /home/blais/repos/cvsroot/arubomu/bin/arubomu-xmms,v $
# $Id: arubomu-xmms,v 1.1 2005/01/26 04:07:49 blais Exp $
#

"""
Extract some information from xmms in our favourite format.

"""

__version__ = "$Revision: 1.1 $"
__author__ = "Martin Blais <blais@furius.ca>"


import re
from os.path import *

import xmms



def main():
    import optparse
    parser = optparse.OptionParser(__doc__.strip(), version=__version__)
    parser.add_option('-c', '--command', action='store',
                      choices=['current'],
                      default='current',
                      help="Command to execute.")
    opts, args = parser.parse_args()

    if opts.command == 'current':
        curfile = xmms.get_playlist_file( xmms.get_playlist_pos() )
        didstr = basename(dirname(curfile))
        mo = re.match('(\d+)', basename(curfile))
        if mo:
            no = int(mo.group(1))

        print '<songref dir="%s" no="%s" />' % (didstr, no)
        
if __name__ == '__main__':
    main()
