python-id3-1.2.orig/0040755000175000017500000000000007453207353013575 5ustar mbanckmbanckpython-id3-1.2.orig/id3-tagger.py0100755000175000017500000000423107453206403016070 0ustar mbanckmbanck#!/usr/bin/env python # ID3 module example program # $Id: id3-tagger.py,v 1.5 2002/04/05 02:33:39 che_fox Exp $ # version 1.2 # written 2 May 1999 by Ben Gertzfield # This program is released under the GNU GPL, version 2 or later. import getopt, string, re, sys from ID3 import * version = 1.2 name = 'id3-tagger.py' def usage(): sys.stderr.write( "This is %s version %0.1f, a tool for setting ID3 tags in MP3 files.\n\n\ Usage: %s [-t title] [-a artist] [-A album] [-y year] [-c comment] \n\ %s [-g genre] [-T tracknum] [-d] [-h] [-v] file1 [file2 ...]\n\n\ -d: Delete the ID3 tag from specified file(s) completely\n\ -h: Display this text\n\ -v: Display the version of this program\n\n\ With no arguments, display the ID3 tag of the given file(s).\n" % (name, version, name, ' ' * len(name))) def main(): options = {} try: opts, args = getopt.getopt(sys.argv[1:], 't:a:A:y:c:g:T:dhvl') except getopt.error, msg: print msg usage() sys.exit(2) for opt, arg in opts: if opt == '-v': sys.stderr.write("This is %s version %0.1f.\n" % (name, version)) sys.exit(0) if opt == '-h': usage() sys.exit(0) if opt == '-t': options['TITLE'] = arg if opt == '-a': options['ARTIST'] = arg if opt == '-A': options['ALBUM'] = arg if opt == '-y': options['YEAR'] = arg if opt == '-c': options['COMMENT'] = arg if opt == '-g': options['GENRE'] = arg if opt == '-T': options['TRACKNUMBER'] = arg if opt == '-d': options['delete'] = 1 if len(args) == 0: usage() sys.exit(2) for file in args: try: id3info = ID3(file) needs_write = 0 if len(options.keys()) > 0: needs_write = 1 for k, v in options.items(): if k == 'GENRE' and re.match("\d+$", v): id3info[k] = string.atoi(v) else: id3info[k] = v if options.has_key('delete'): id3info.delete() print id3info if needs_write: id3info.write() except InvalidTagError, msg: print "Invalid ID3 tag:", msg continue main() python-id3-1.2.orig/ID3.py0100755000175000017500000004106307453206403014525 0ustar mbanckmbanck# ID3.py version 1.2 # Module for manipulating ID3 informational tags in MP3 audio files # $Id: ID3.py,v 1.6 2002/04/05 02:33:39 che_fox Exp $ # Written 2 May 1999 by Ben Gertzfield # This work is released under the GNU GPL, version 2 or later. # Modified 10 June 1999 by Arne Zellentin to # fix bug with overwriting last 128 bytes of a file without an # ID3 tag # Patches from Jim Speth and someone whose email # I've forgotten at the moment (huge apologies, I didn't save the # entire mail, just the patch!) for so-called ID3 v1.1 support, # which makes the last two bytes of the comment field signify a # track number. If the first byte is null but the second byte # is not, the second byte is assumed to signify a track number. # Also thanks to Jim for the simple function to remove nulls and # whitespace from the ends of ID3 tags. I'd like to add a boolean # flag defaulting to false to the ID3() constructor signifying whether # or not to remove whitespace, just in case old code depended on the # old behavior for some reason, but that'd make any code that wanted # to use the stripping behavior not work with old ID3.py. Bleh. # This is the first thing I've ever written in Python, so bear with # me if it looks terrible. In a few years I'll probably look back at # this and laugh and laugh.. # Constructor: # # ID3(file, filename='unknown filename', as_tuple=0) # Opens file and tries to parse its ID3 header. If the ID3 header # is invalid or the file access failed, raises InvalidTagError. # # file can either be a string specifying a filename which will be # opened in binary mode, or a file object. If it's a file object, # the filename should be passed in as the second argument to this # constructor, otherwise file.name will be used in error messages # (or 'unknown filename' if that's missing). Also, if it's a file # object, it *must* be opened in r+ mode (or equivalent) to allow # both reading and writing. # # If as_tuple is true, the dictionary interface to ID3 will return # tuples containing one string each instead of a string, for # compatibility with the ogg.vorbis module. # # When object is deconstructed, if any of the class data (below) have # been changed, opens the file again read-write and writes out the # new header. If the header is to be deleted, truncates the last # 128 bytes of the file. # # Note that if ID3 cannot write the tag out to the file upon # deconstruction, InvalidTagError will be raised and ignored # (as we are in __del__, and exceptions just give warnings when # raised in __del__.) # Class Data of Interest: # # Note that all ID3 fields, unless otherwise specified, are a maximum of # 30 characters in length. If a field is set to a string longer than # the maximum, it will be truncated when it's written to disk. # # As of ID3 version 1.2, there are two interfaces to this data. # You can use the direct interface or the dictionary-based interface. # The normal dictionary methods (has_key, get, keys, values, items, etc.) # should work on an ID3 object. You can assign values to either the # dictionary interface or the direct interface, and they will both # reflect the changes. # # If any of the fields are not defined in the ID3 tag, the dictionary # based interface will not contain a key for that field! Test with # ID3.has_key('ARTIST') etc. first. # # ID3.title or ID3['TITLE'] # Title of the song. # ID3.artist or ID3['ARTIST'] # Artist/creator of the song. # ID3.album or ID3['ALBUM'] # Title of the album the song is from. # ID3.year or ID3['YEAR'] # Year the song was released. Maximum of 4 characters (Y10K bug!) # ID3.genre # Genre of the song. Integer value from 0 to 255. Genre specification # comes from (sorry) WinAMP. http://mp3.musichall.cz/id3master/faq.htm # has a list of current genres; I spell-checked this list against # WinAMP's by running strings(1) on the file Winamp/Plugins/in_mp3.dll # and made a few corrections. # ID3['GENRE'] # String value corresponding to the integer in ID3.genre. If there # is no genre string available for the ID3.genre number, this will # be set to "Unknown Genre". # ID3.comment or ID3['COMMENT'] # Comment about the song. # ID3.track or ID3['TRACKNUMBER'] # Track number of the song. None if undefined. # NOTE: ID3['TRACKNUMBER'] will return a *string* containing the # track number, for compatibility with ogg.vorbis. # # ID3.genres # List of all genres. ID3.genre above is used to index into this # list. ID3.genres is current as of WinAMP 1.92. # Methods of Interest: # # write() # If the class data above have changed, opens the file given # to the constructor read-write and writes out the new header. # If the header is flagged for deletion (see delete() below) # truncates the last 128 bytes of the file to remove the header. # # NOTE: write() is called from ID3's deconstructor, so it's technically # unnecessary to call it. However, write() can raise an InvalidTagError, # which can't be caught during deconstruction, so generally it's # nicer to call it when writing is desired. # # delete() # Flags the ID3 tag for deletion upon destruction of the object # # find_genre(genre_string) # Searches for the numerical value of the given genre string in the # ID3.genres table. The search is performed case-insensitively. Returns # an integer from 0 to len(ID3.genres). # # legal_genre(genre_number) # Checks if genre_number is a legal index into ID3.genres. Returns # true if so, false otherwise. # # as_dict() # Returns just the dictionary containing the ID3 tag fields. # See the notes above for the dictionary interface. # import string, types try: string_types = [ types.StringType, types.UnicodeType ] except AttributeError: # if no unicode support string_types = [ types.StringType ] def lengthen(string, num_spaces): string = string[:num_spaces] return string + (' ' * (num_spaces - len(string))) # We would normally use string.rstrip(), but that doesn't remove \0 characters. def strip_padding(s): while len(s) > 0 and s[-1] in string.whitespace + "\0": s = s[:-1] return s class InvalidTagError: def __init__(self, msg): self.msg = msg def __str__(self): return self.msg class ID3: genres = [ "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "Alt. Rock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrum. Pop", "Instrum. Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Indust.", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", "Swing", "Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progress. Rock", "Psychadel. Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", "A Capella", "Euro-House", "Dance Hall", "Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", "Indie", "BritPop", "Negerpunk", "Polsk Punk", "Beat", "Christian Gangsta Rap", "Heavy Metal", "Black Metal", "Crossover", "Contemporary Christian", "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "Jpop", "Synthpop" ] def __init__(self, file, name='unknown filename', as_tuple=0): if type(file) in string_types: self.filename = file # We don't open in r+b if we don't have to, to allow read-only access self.file = open(file, 'rb') self.can_reopen = 1 elif hasattr(file, 'seek'): # assume it's an open file if name == 'unknown filename' and hasattr(file, 'name'): self.filename = file.name else: self.filename = name self.file = file self.can_reopen = 0 self.d = {} self.as_tuple = as_tuple self.delete_tag = 0 self.zero() self.modified = 0 self.has_tag = 0 self.had_tag = 0 try: self.file.seek(-128, 2) except IOError, msg: self.modified = 0 raise InvalidTagError("Can't open %s: %s" % (self.filename, msg)) return try: if self.file.read(3) == 'TAG': self.has_tag = 1 self.had_tag = 1 self.title = self.file.read(30) self.artist = self.file.read(30) self.album = self.file.read(30) self.year = self.file.read(4) self.comment = self.file.read(30) if ord(self.comment[-2]) == 0 and ord(self.comment[-1]) != 0: self.track = ord(self.comment[-1]) self.comment = self.comment[:-2] else: self.track = None self.genre = ord(self.file.read(1)) self.title = strip_padding(self.title) self.artist = strip_padding(self.artist) self.album = strip_padding(self.album) self.year = strip_padding(self.year) self.comment = strip_padding(self.comment) self.setup_dict() except IOError, msg: self.modified = 0 raise InvalidTagError("Invalid ID3 tag in %s: %s" % (self.filename, msg)) self.modified = 0 def setup_dict(self): self.d = {} if self.title: self.d["TITLE"] = self.tupleize(self.title) if self.artist: self.d["ARTIST"] = self.tupleize(self.artist) if self.album: self.d["ALBUM"] = self.tupleize(self.album) if self.year: self.d["YEAR"] = self.tupleize(self.year) if self.comment: self.d["COMMENT"] = self.tupleize(self.comment) if self.legal_genre(self.genre): self.d["GENRE"] = self.tupleize(self.genres[self.genre]) else: self.d["GENRE"] = self.tupleize("Unknown Genre") if self.track: self.d["TRACKNUMBER"] = self.tupleize(str(self.track)) def delete(self): self.zero() self.delete_tag = 1 self.has_tag = 0 def zero(self): self.title = '' self.artist = '' self.album = '' self.year = '' self.comment = '' self.track = None self.genre = 255 # 'unknown', not 'blues' self.setup_dict() def tupleize(self, s): if self.as_tuple and type(s) is not types.TupleType: return (s,) else: return s def find_genre(self, genre_to_find): i = 0 find_me = string.lower(genre_to_find) for genre in self.genres: if string.lower(genre) == find_me: break i = i + 1 if i == len(self.genres): return -1 else: return i def legal_genre(self, genre): if type(genre) is types.IntType and 0 <= genre < len(self.genres): return 1 else: return 0 def write(self): if self.modified: try: # We see if we can re-open in r+ mode now, as we need to write if self.can_reopen: self.file = open(self.filename, 'r+b') if self.had_tag: self.file.seek(-128, 2) else: self.file.seek(0, 2) # a new tag is appended at the end if self.delete_tag and self.had_tag: self.file.truncate() self.had_tag = 0 elif self.has_tag: go_on = 1 if self.had_tag: if self.file.read(3) == "TAG": self.file.seek(-128, 2) else: # someone has changed the file in the mean time go_on = 0 raise IOError("File has been modified, losing tag changes") if go_on: self.file.write('TAG') self.file.write(lengthen(self.title, 30)) self.file.write(lengthen(self.artist, 30)) self.file.write(lengthen(self.album, 30)) self.file.write(lengthen(self.year, 4)) comment = lengthen(self.comment, 30) if self.track < 0 or self.track > 255: self.track = None if self.track != None: comment = comment[:-2] + "\0" + chr(self.track) self.file.write(comment) if self.genre < 0 or self.genre > 255: self.genre = 255 self.file.write(chr(self.genre)) self.had_tag = 1 self.file.flush() except IOError, msg: raise InvalidTagError("Cannot write modified ID3 tag to %s: %s" % (self.filename, msg)) else: self.modified = 0 def as_dict(self): return self.d def items(self): return map(None, self.keys(), self.values()) def keys(self): return self.d.keys() def values(self): if self.as_tuple: return map(lambda x: x[0], self.d.values()) else: return self.d.values() def has_key(self, k): return self.d.has_key(k) def get(self, k, x=None): if self.d.has_key(k): return self.d[k] else: return x def __getitem__(self, k): return self.d[k] def __setitem__(self, k, v): key = k if not key in ['TITLE', 'ARTIST', 'ALBUM', 'YEAR', 'COMMENT', 'TRACKNUMBER', 'GENRE']: return if k == 'TRACKNUMBER': if type(v) is types.IntType: self.track = v else: self.track = string.atoi(v) self.d[k] = self.tupleize(str(v)) elif k == 'GENRE': if type(v) is types.IntType: if self.legal_genre(v): self.genre = v self.d[k] = self.tupleize(self.genres[v]) else: self.genre = v self.d[k] = self.tupleize("Unknown Genre") else: self.genre = self.find_genre(str(v)) if self.genre == -1: print v, "not found" self.genre = 255 self.d[k] = self.tupleize("Unknown Genre") else: print self.genre, v self.d[k] = self.tupleize(str(v)) else: self.__dict__[string.lower(key)] = v self.d[k] = self.tupleize(v) self.__dict__['modified'] = 1 self.__dict__['has_tag'] = 1 def __del__(self): self.write() def __str__(self): if self.has_tag: if self.genre != None and self.genre >= 0 and \ self.genre < len(self.genres): genre = self.genres[self.genre] else: genre = 'Unknown' if self.track != None: track = str(self.track) else: track = 'Unknown' return "File : %s\nTitle : %-30.30s Artist: %-30.30s\nAlbum : %-30.30s Track : %s Year: %-4.4s\nComment: %-30.30s Genre : %s (%i)" % (self.filename, self.title, self.artist, self.album, track, self.year, self.comment, genre, self.genre) else: return "%s: No ID3 tag." % self.filename # intercept setting of attributes to set self.modified def __setattr__(self, name, value): if name in ['title', 'artist', 'album', 'year', 'comment', 'track', 'genre']: self.__dict__['modified'] = 1 self.__dict__['has_tag'] = 1 if name == 'track': self.__dict__['d']['TRACKNUMBER'] = self.tupleize(str(value)) elif name == 'genre': if self.legal_genre(value): self.__dict__['d']['GENRE'] = self.tupleize(self.genres[value]) else: self.__dict__['d']['GENRE'] = self.tupleize('Unknown Genre') else: self.__dict__['d'][string.upper(name)] = self.tupleize(value) self.__dict__[name] = value python-id3-1.2.orig/COPYING0100644000175000017500000004311007162503470014620 0ustar mbanckmbanck GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. python-id3-1.2.orig/setup.py0100644000175000017500000000110007453206403015267 0ustar mbanckmbanck#!/usr/bin/env python """Setup script for the ID3 module distribution.""" __revision__ = "$Id: setup.py,v 1.3 2002/04/05 02:33:39 che_fox Exp $" from distutils.core import setup setup (# Distribution meta-data name = "ID3", version = "1.2", description = "Module for manipulating ID3 informational tags on MP3 audio files", author = "Ben Gertzfield", author_email = "che@debian.org", url = "http://id3-py.sourceforge.net/", # Description of the modules and packages in the distribution py_modules = ['ID3'] ) python-id3-1.2.orig/CHANGES0100644000175000017500000000277007453205655014576 0ustar mbanckmbanckv1.2 ---- 5 April 2002: New dictionary-based interface, compatible with ogg.vorbis module. Default genre will be 255 if not specified, not 0 ("Blues"). Rewrote id3-tagger.py to use new dictionary-based interface (simplifies code a lot). v1.1 ---- 23 December 2000: Overload the ID3 constructor to allow passing in either a filename *or* an already-opened file along with a filename. Make sure we open the file in r+b mode if we're given a filename, to make Windows (and VMS? *grin*) folks happy. No longer repeatedly opens/closes files; instead just opens in r+b mode right at the beginning and does flush() if necessary to make sure we have the old functionality. Changed example id3-tagger.py to properly do an explicit ID3.write() call if something's changed, to catch and print exceptions nicely. v1.0 ---- 21 September 2000: First 1.0 release. Add ID3 v1.1 support (the last byte of the Comments field is considered to be a track number if the previous byte is non-null). Add whitespace/null stripping to the end of all fields. If this breaks anything, please let me know! I shouldn't assume this, but I figure it'd be nice for folks not to have to do this on their own. I'll take it out if it causes problems. Write a README, COPYING, CHANGES file, and add a setup.py for Distutils and Python 1.6 users. v0.6 ---- 11 June 1999: Fix from Arne Zellentin (arne@unix-ag.org) to prevent wiping out the last 128 bytes of MP3 files that don't already have an ID3 tag. Oops! 0.5 --- 2 May 1999: Initial release. python-id3-1.2.orig/README0100644000175000017500000001404007453206265014452 0ustar mbanckmbanckREADME for ID3.py, version 1.2 Copyright (C) 1999, 2000, 2002 Ben Gertzfield -------------------------------------------------------------- This is a simple Python module for retrieving and setting so-called ID3 tags on MP3 compressed audio files through an object-oriented interface. MP3 players generally use this simple information for display track title, artist name, and album title while playing the sound file. ID3.py supports ID3 version 1.1, including the track number field. I have no current plans to code up the monstrosity that is ID3v2 (http://www.id3.org/id3v2.3.0.html) but if someone wants to add that functionality, feel free! ID3.py is hosted by SourceForge.Net, and the latest release will always be available from: http://id3-py.sourceforge.net/ To install ID3.py, either simply copy the ID3.py file to your site-wide Python module installation directory (/usr/local/lib/python/site-python, for instance) or, if you have Python v1.6 or later (or have Distutils installed), you can simply run: # python setup.py install from the command-line. Here's a simple example of using the ID3 module. This example prints the current ID3 information (nicely formatted) of a given MP3, changes the title and artist tags, and then (implicitly, when the object is destroyed) writes out the changes to the file. from ID3 import * try: filename = '/some/path/moxy.mp3' id3info = ID3(filename) # alternatively, can pass in a file or equivalent if opened in r+b mode # id3info = ID3(open(filename, 'r+b'), filename) print id3info id3info.title = "Green Eggs and Ham" id3info.artist = "Moxy Früvous" except InvalidTagError, message: print "Invalid ID3 tag:", message Notice that simply changing the value of the fields is enough; no special functions need to be called. NEW DICTIONARY-BASED INTERFACE ------------------------------ As of ID3.py version 1.2, a new dictionary-based interface compatible with ogg.vorbis is available. You can now use ID3 objects just like a dictionary: from ID3 import * try: filename = '/some/path/moxy.mp3' id3info = ID3(filename) id3info['TITLE'] = "Green Eggs and Ham" id3info['ARTIST'] = "Moxy Früvous" for k, v in id3info.items(): print k, ":", v except InvalidTagError, message: print "Invalid ID3 tag:", message Note that ID3.py (by default) stores just a string in each value in the dictionary-based interface. ogg.vorbis uses a *list*, not a single string, so if you want compatibility with ogg.vorbis, call the ID3 constructor with as_tuple=1: from ID3 import * try: id3info = ID3("moxy.mp3", as_tuple=1) for k, v in id3info.items() print k, ":", v[0] except InvalidTagError, message: print "Invalid ID3 tag:", message Of course, all the tuples will only have one string value inside them, as that's all the ID3 version 1.1 standard supports. ID3 OBJECT FIELDS ----------------- Here's a list of all the fields in an ID3 object that are interesting. Note that all ID3 fields, unless otherwise specified, are a maximum of 30 characters in length. If a field is set to a string longer than the maximum, it will be truncated when it's written to disk. If any of the fields are not defined in the ID3 tag, the dictionary based interface will not contain a key for that field! Test with ID3.has_key('ARTIST') etc. first. ID3.title or ID3['TITLE'] Title of the song. ID3.artist or ID3['ARTIST'] Artist/creator of the song. ID3.album or ID3['ALBUM'] Title of the album the song is from. ID3.year or ID3['YEAR'] Year the song was released. Maximum of 4 characters (Y10K bug!) ID3.genre Genre of the song. Integer value from 0 to 255. Genre specification comes from (sorry) WinAMP. http://mp3.musichall.cz/id3master/faq.htm has a list of current genres; I spell-checked this list against WinAMP's by running strings(1) on the file Winamp/Plugins/in_mp3.dll and made a few corrections. ID3['GENRE'] String value corresponding to the integer in ID3.genre. If there is no genre string available for the ID3.genre number, this will be set to "Unknown Genre". ID3.comment or ID3['COMMENT'] Comment about the song. ID3.track or ID3['TRACKNUMBER'] Track number of the song. None if undefined. NOTE: ID3['TRACKNUMBER'] will return a *string* containing the track number, for compatibility with ogg.vorbis. This field shouldn't be changed, but might be of use: ID3.genres List of all genres. ID3.genre above is used to index into this list. ID3.genres is current as of WinAMP 1.92. Here are the methods of interest that the ID3 module contains: write() If the class data above have changed, opens the file given to the constructor read-write and writes out the new header. If the header is flagged for deletion (see delete() below) truncates the last 128 bytes of the file to remove the header. NOTE: write() is called from ID3's deconstructor, so it's technically unnecessary to call it. However, write() can raise an InvalidTagError, which can't be caught during deconstruction, so generally it's nicer to call it when writing is desired. delete() Flags the ID3 tag for deletion upon destruction of the object find_genre(genre_string) Searches for the numerical value of the given genre string in the ID3.genres table. The search is performed case-insensitively. Returns an integer from 0 to len(ID3.genres). legal_genre(genre_number) Checks if genre_number is a legal index into ID3.genres. Returns true if so, false otherwise. as_dict() Returns just the dictionary containing the ID3 tag fields. See the notes above for the dictionary interface. The only exception is ID3.InvalidTagError; this exception will be raised from the constructor when the given file cannot be opened, when an IOError is raised while reading the file, and when an IOError occurs during a write, after the tag has been modified.