[4] | 1 | #!/usr/bin/python |
---|
| 2 | #if 0 |
---|
| 3 | # ----------------------------------------------------------------------- |
---|
| 4 | # $Id: mminfo,v 1.4 2004/05/28 12:26:24 dischi Exp $ |
---|
| 5 | # ----------------------------------------------------------------------- |
---|
| 6 | # $Log: mminfo,v $ |
---|
| 7 | # Revision 1.4 2004/05/28 12:26:24 dischi |
---|
| 8 | # Replace __str__ with unicode to avoid bad transformations. Everything |
---|
| 9 | # inside mmpython should be handled as unicode object. |
---|
| 10 | # |
---|
| 11 | # Revision 1.3 2004/05/24 12:54:35 dischi |
---|
| 12 | # debug update |
---|
| 13 | # |
---|
| 14 | # Revision 1.2 2004/05/17 19:10:57 dischi |
---|
| 15 | # better DEBUG handling |
---|
| 16 | # |
---|
| 17 | # Revision 1.1 2004/05/17 19:00:58 dischi |
---|
| 18 | # rename mediatest.py to mminfo and install it as script to bin |
---|
| 19 | # |
---|
| 20 | # |
---|
| 21 | # ----------------------------------------------------------------------- |
---|
| 22 | # MMPython - Media Metadata for Python |
---|
| 23 | # Copyright (C) 2003 Thomas Schueppel, Dirk Meyer |
---|
| 24 | # |
---|
| 25 | # This program is free software; you can redistribute it and/or modify |
---|
| 26 | # it under the terms of the GNU General Public License as published by |
---|
| 27 | # the Free Software Foundation; either version 2 of the License, or |
---|
| 28 | # (at your option) any later version. |
---|
| 29 | # |
---|
| 30 | # This program is distributed in the hope that it will be useful, but |
---|
| 31 | # WITHOUT ANY WARRANTY; without even the implied warranty of MER- |
---|
| 32 | # CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
| 33 | # Public License for more details. |
---|
| 34 | # |
---|
| 35 | # You should have received a copy of the GNU General Public License along |
---|
| 36 | # with this program; if not, write to the Free Software Foundation, Inc., |
---|
| 37 | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 38 | # |
---|
| 39 | # ----------------------------------------------------------------------- |
---|
| 40 | #endif |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | import sys |
---|
| 44 | import os |
---|
| 45 | |
---|
| 46 | # add .. for source usage |
---|
| 47 | sys.path = ['..'] + sys.path |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | print 'mmpython media info' |
---|
| 51 | |
---|
| 52 | if len(sys.argv) < 2 or sys.argv[1] in ('-h', '--help'): |
---|
| 53 | print |
---|
| 54 | print 'usage: mminfo [options] files' |
---|
| 55 | print |
---|
| 56 | print 'options:' |
---|
| 57 | print ' -d turn on debug information. For complete debug set -d 2' |
---|
| 58 | print |
---|
| 59 | print 'A file can be a normal file, a device for VCD/VCD/AudioCD' |
---|
| 60 | print |
---|
| 61 | print 'Examples:' |
---|
| 62 | print ' mminfo foo.avi bar.mpg' |
---|
| 63 | print ' mminfo /dev/dvd' |
---|
| 64 | print |
---|
| 65 | sys.exit(0) |
---|
| 66 | |
---|
| 67 | # turn on debug |
---|
| 68 | if sys.argv[1] == '-d': |
---|
| 69 | try: |
---|
| 70 | int(sys.argv[2]) |
---|
| 71 | os.environ['MMPYTHON_DEBUG'] = sys.argv[2] |
---|
| 72 | sys.argv = sys.argv[2:] |
---|
| 73 | except: |
---|
| 74 | os.environ['MMPYTHON_DEBUG'] = '1' |
---|
| 75 | sys.argv = sys.argv[1:] |
---|
| 76 | |
---|
| 77 | from mmpython import * |
---|
| 78 | |
---|
| 79 | for file in sys.argv[1:]: |
---|
| 80 | medium = parse(file) |
---|
| 81 | print |
---|
| 82 | if len(file) > 70: |
---|
| 83 | print "filename : %s[...]%s" % (file[:30], file[len(file)-30:]) |
---|
| 84 | else: |
---|
| 85 | print "filename : %s" % file |
---|
| 86 | if medium: |
---|
| 87 | print unicode(medium).encode('latin-1', 'replace') |
---|
| 88 | print |
---|
| 89 | print |
---|
| 90 | else: |
---|
| 91 | print "No Match found" |
---|