oxcd/bin/0xcd

32 lines
1 KiB
Text
Raw Normal View History

2012-09-06 10:08:30 +00:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import sys
from optparse import OptionParser
root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
if os.path.exists(os.path.join(root, 'oxcd')):
sys.path.insert(0, root)
import oxcd
2012-09-08 17:37:51 +00:00
import oxcd.itunes
import oxcd.rhythmbox
2012-09-06 10:08:30 +00:00
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-p', '--port', dest='port', help='port', default=2681)
2012-09-08 17:37:51 +00:00
parser.add_option('-i', '--itunes', dest='itunes', help='iTunes xml', default=oxcd.itunes.path())
parser.add_option('-r', '--rhythmbox', dest='rhythmbox', help='Rhythmbox xml', default=oxcd.rhythmbox.path())
2012-09-06 10:08:30 +00:00
(opts, args) = parser.parse_args()
2012-09-08 17:37:51 +00:00
if None in (opts.port, ) or not filter(None, (opts.itunes, opts.rhythmbox)):
2012-09-06 10:08:30 +00:00
parser.print_help()
sys.exit()
2012-09-08 17:37:51 +00:00
if opts.itunes:
backend = oxcd.itunes.iTunes(opts.itunes)
elif opts.rhythmbox:
backend = oxcd.rhythmbox.Rhythmbox(opts.rhythmbox)
oxcd.main(opts.port, backend)