comparison python/dlna.py @ 710:7f910ce4da04

STUB: python/dlna.py
author Jeff Hammel <k0scist@gmail.com>
date Sat, 06 Sep 2014 07:59:16 -0700
parents 4d9df2370659
children 02aec49585ab
comparison
equal deleted inserted replaced
709:c24a1b531b7e 710:7f910ce4da04
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3
4 """
5 serve DLNA
6 """
3 7
4 import argparse 8 import argparse
5 import os 9 import os
6 import shutil 10 import shutil
7 import subprocess 11 import subprocess
11 15
12 here = os.path.dirname(os.path.realpath(__file__)) 16 here = os.path.dirname(os.path.realpath(__file__))
13 string = (str, unicode) 17 string = (str, unicode)
14 18
15 def main(args=sys.argv[1:]): 19 def main(args=sys.argv[1:]):
20 """CLI"""
16 21
17 dlna = which('minidlna') 22 # parse command line
18 assert dlna
19
20 parser = argparse.ArgumentParser(description=__doc__) 23 parser = argparse.ArgumentParser(description=__doc__)
21 parser.add_argument('--name', dest='name', default='protest servant', 24 parser.add_argument('--name', dest='name', default='protest servant',
22 help="friendly name") 25 help="friendly name")
23 parser.add_argument('--db-dir', dest='db_dir', 26 parser.add_argument('--db-dir', dest='db_dir',
24 default=os.path.join(os.environ['HOME'], 'minidlna'), 27 default=os.path.join(os.environ['HOME'], 'minidlna'),
27 help="port") 30 help="port")
28 parser.add_argument('-v', '--videos', dest='videos', nargs='+', 31 parser.add_argument('-v', '--videos', dest='videos', nargs='+',
29 help="videos") 32 help="videos")
30 parser.add_argument('audio', nargs='+') 33 parser.add_argument('audio', nargs='+')
31 options = parser.parse_args(args) 34 options = parser.parse_args(args)
35
36 # dlna location
37 dlna = which('minidlnad')
38 if not dlna:
39 parser.error("minidlna command not found")
32 40
33 lines = [('friendly_name', options.name), 41 lines = [('friendly_name', options.name),
34 ('db_dir', options.db_dir), 42 ('db_dir', options.db_dir),
35 ('log_dir', options.db_dir), 43 ('log_dir', options.db_dir),
36 ('inotify', 'yes'), 44 ('inotify', 'yes'),