[xiph-cvs] cvs commit: vorbis-python/src pyvorbisinfo.c
Andrew Catham Master of Python
andrew at xiph.org
Tue Jul 23 21:15:38 PDT 2002
andrew 02/07/23 21:15:38
Modified: . ChangeLog README setup.py
src pyvorbisinfo.c
Log:
2002-07-23 Andrew H. Chatham <andrew at andrewchatham.com>
* README - documented new comment interface
* Bumped to 1.0 to match Vorbis
* pyvorbisinfo.c: Removed printf
Revision Changes Path
1.15 +5 -0 vorbis-python/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/ChangeLog,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ChangeLog 2002/07/17 05:04:39 1.14
+++ ChangeLog 2002/07/24 04:15:37 1.15
@@ -1,3 +1,8 @@
+2002-07-23 Andrew H. Chatham <andrew at andrewchatham.com>
+ * README - documented new comment interface
+ * Bumped to 1.0 to match Vorbis
+ * pyvorbisinfo.c: Removed printf
+
2002-07-16 Andrew H. Chatham <andrew at andrewchatham.com>
* pyvorbisinfo.c: Can now create comments from dictionaries
(a MUCH better interface)
<p><p>1.6 +27 -25 vorbis-python/README
Index: README
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/README,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- README 2002/01/28 02:52:13 1.5
+++ README 2002/07/24 04:15:37 1.6
@@ -62,35 +62,37 @@
from the vorbiscomment program, which is by Michael Smith and released
under the LGPL. It has not been modified by me (Andrew).
-The comment structure is a lot like a Python dictionary, with a few
-changes. First, there can be multiple entries per key, because that's
+There was an old way of dealing with VorbisComment objects, which
+sucked, so I won't tell you how to use it. It still works but is
+deprecated.
+
+The current way of using VorbisComment objects is just to convert to
+and from Python dictionaries. Note that there can be multiple entries
+per key and that keys are case-insensitive 7-bit ASCII, because that's
how vorbis comments work. So I might do:
+>>> import ogg.vorbis
+>>> v = {'mykey' : ['myval1', 'myval2']}
+>>> v['artist'] = u'andrew' # Unicode string for Python >= 1.6
+>>> print v
+{'artist': 'andrew', 'mykey': ['myval1', 'myval2']}
+>>> comments = ogg.vorbis.VorbisComment(v)
+
+There, we made a comment object from a dictionary. The values of the
+dictionary are either strings or lists or strings. We can also convert
+back to a dictionary, though it'll look a little different:
+
+>>> print comments.as_dict()
+{'ARTIST': [u'andrew'], 'MYKEY': ['myval1', 'myval2']}
+
+We could also have gotten a comment object from a vorbis file:
+
>>> import ogg.vorbis
->>> v = ogg.vorbis.VorbisComment()
->>> v['mykey'] = 'myval1'
->>> v['mykey'] = 'myval2'
->>> print v.items()
-[('MYKEY', 'myval1'), ('MYKEY', 'myval2')]
->>> print v['mykey']
-['myval1', 'myval2']
-
-Each entry in the "dictionary" is a list of values. Each key is
-treated as case-insensitive. If you use Python >= 1.6, the values (but
-not keys) will be unicode strings.
-
-To delete a comment entry, you just do "del v[key]". This will delete
-_all_ tags which have that key (there may be more than one). This is
-implemented by just creating a new comment structure and copying in
-every comment that doesn't match the one you want to delete, so if you
-plan to delete or replace a lot of keys, it might be faster to just
-construct a new object.
-
-You can also get the comments from an existing file by opening that
-file as a VorbisFile object and then calling .comment() on it. This is
-treated the same way as above.
+>>> f = ogg.vorbis.VorbisFile('test.ogg')
+>>> print f.comment().as_dict()
To write the comments to an existing ogg/vorbis file, call v.write_to
or v.append_to. The former will add lots of keys, so if you already
have an artist key, and you add another, you now have two arist keys
-in that file.
+in that file. Note that currently the VENDOR tag (which is special)
+doesn't get written to the file. I'll have to look into that.
<p><p>1.7 +2 -2 vorbis-python/setup.py
Index: setup.py
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/setup.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- setup.py 2002/07/17 05:04:39 1.6
+++ setup.py 2002/07/24 04:15:37 1.7
@@ -6,8 +6,8 @@
from distutils.core import setup
from distutils.extension import Extension
-VERSION_MAJOR = 0
-VERSION_MINOR = 5
+VERSION_MAJOR = 1
+VERSION_MINOR = 0
pyvorbis_version = str(VERSION_MAJOR) + '.' + str(VERSION_MINOR)
try:
<p><p>1.11 +0 -1 vorbis-python/src/pyvorbisinfo.c
Index: pyvorbisinfo.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/src/pyvorbisinfo.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- pyvorbisinfo.c 2002/07/17 05:04:40 1.10
+++ pyvorbisinfo.c 2002/07/24 04:15:38 1.11
@@ -701,7 +701,6 @@
vcomment->vendor = strdup(tag_str);
} else {
snprintf(tag_buff, sizeof(tag_buff), "%s=%s", key, tag_str);
- printf("Add tag %s\n", tag_buff);
vorbis_comment_add(vcomment, tag_buff);
}
return 1;
<p><p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list