From 754d440973db76564c4e61bfc431d962a6ac958e Mon Sep 17 00:00:00 2001 From: yomguy Date: Sun, 11 Jan 2009 23:19:13 +0000 Subject: [PATCH] first import based on the old telemeta 0.2.9 git-svn-id: http://svn.parisson.org/svn/telemaster/trunk@2 353fd7da-fb10-4236-9bec-1a49139083f2 --- AUTHORS | 1 + COPYING | 340 ++++++++++++++++++++ ChangeLog | 94 ++++++ INSTALL | 51 +++ Makefile | 68 ++++ README | 140 ++++++++ audio_marking.py | 63 ++++ audio_tools.py | 180 +++++++++++ collection.py | 37 +++ consts.py | 37 +++ debian/README.Debian | 6 + debian/changelog | 94 ++++++ debian/compat | 1 + debian/control | 28 ++ debian/copyright | 23 ++ debian/dirs | 1 + debian/docs | 1 + debian/files | 1 + debian/pycompat | 1 + debian/rules | 68 ++++ debian/telemaster.1 | 110 +++++++ debian/telemaster.debhelper.log | 12 + debian/telemaster.postinst.debhelper | 8 + debian/telemaster.preinst.debhelper | 25 ++ debian/telemaster.prerm.debhelper | 45 +++ debian/telemaster.sgml | 271 ++++++++++++++++ debian/telemaster.substvars | 2 + default_options.py | 33 ++ default_tags.py | 33 ++ install.py | 43 +++ tag_tools.py | 309 ++++++++++++++++++ telemaster.py | 461 +++++++++++++++++++++++++++ typeToolBox.py | 41 +++ 33 files changed, 2628 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile create mode 100644 README create mode 100644 audio_marking.py create mode 100644 audio_tools.py create mode 100644 collection.py create mode 100644 consts.py create mode 100644 debian/README.Debian create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/docs create mode 100644 debian/files create mode 100644 debian/pycompat create mode 100755 debian/rules create mode 100644 debian/telemaster.1 create mode 100644 debian/telemaster.debhelper.log create mode 100644 debian/telemaster.postinst.debhelper create mode 100644 debian/telemaster.preinst.debhelper create mode 100644 debian/telemaster.prerm.debhelper create mode 100644 debian/telemaster.sgml create mode 100644 debian/telemaster.substvars create mode 100644 default_options.py create mode 100644 default_tags.py create mode 100755 install.py create mode 100644 tag_tools.py create mode 100755 telemaster.py create mode 100644 typeToolBox.py diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..3f9cf61 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Guillaume Pellerin diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + 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. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..7b32a3c --- /dev/null +++ b/ChangeLog @@ -0,0 +1,94 @@ +telemaster (0.2.9) unstable; urgency=low + + * Fix MP3 bitrate + + -- Guillaume Pellerin Fri, 12 Sep 2008 15:10:22 +0200 + +telemaster (0.2.8) unstable; urgency=low + + * Renamed + + -- Guillaume Pellerin Wed, 10 Jun 2008 10:57:13 +0100 + +telemeta (0.2.5-2) unstable; urgency=low + + * Fixed --help page + + -- Guillaume Pellerin Wed, 10 Jan 2007 12:01:13 +0100 + +telemeta (0.2.5-1) unstable; urgency=low + + * Fixed --create and --backup option behaviors, thanks to Olivier Guilyardi + * Created the Collection class and interface + * Fixed error messages + * Made the collection XML file saved in collection dir AND user default dir + + -- Guillaume Pellerin Mon, 8 Jan 2007 02:50:04 +0100 + +telemeta (0.2.4-3) unstable; urgency=low + + * Fixed README and INSTALL pages + + -- Guillaume Pellerin Thu, 4 Jan 2007 18:56:05 +0100 + +telemeta (0.2.4-2) unstable; urgency=low + + * Fixed --help menu and man page + + -- Guillaume Pellerin Wed, 3 Jan 2007 22:18:05 +0100 + +telemeta (0.2.4-1) unstable; urgency=low + + * Rewrited the whole main structure + * Defined a class and xml for consts + * Fixed --erase-media option + * Fixed --recover option + * Added --create option: creates a database repository and default database xml + * Added --backup option: backups a media to the database + * Added --album option: proccesses an entire directory (one shot album) + * Added --from-xml: takes tags and opts in original xml source + * Added --all-default: chooses default argument for all question + * Added --par2 : forces par2 file creation + * Added --rsync : synchronizes database to a remote server (ssh+rsync) + * Added --clean-strings : cleans input strings + + -- Guillaume Pellerin Wed, 3 Jan 2007 18:55:52 +0100 + +telemeta (0.2.3-3) unstable; urgency=low + + * Fixed --force mode bug + + -- Guillaume Pellerin Wed, 22 Nov 2006 12:33:52 +0100 + +telemeta (0.2.3-2) unstable; urgency=low + + * fixed non audio file detection with 'file' command + + -- Guillaume Pellerin Wed, 15 Nov 2006 15:30:10 +0100 + +telemeta (0.2.3-1) unstable; urgency=low + + * Added python-xml parser dependency : + xml tag files are now exported to user default directory and in dir_in. + * Added par2 dependency : creates secure recovery key file with the "par2" method + * Added python-mutagen dependency : new tagging functions + * Cleaned : audio functions + * Fixed : help page + * Debianized + + -- Guillaume Pellerin Tue, 01 Nov 2006 00:25:46 +0100 + +telemeta (0.2.2) unstable; urgency=low + + * Defined : the tag and option lists + * Created : main audio functions + * Created : main tags functions + + -- Guillaume Pellerin Tue, 14 Jul 2006 00:00:01 +0100 + +telemeta (0.1) unstable; urgency=low + + * Initial release + * Created : First flac, ogg, mp3 exporting, tagging with basic functions + + -- Guillaume Pellerin Tue, 01 May 2006 23:45:42 +0200 diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..c1a629a --- /dev/null +++ b/INSTALL @@ -0,0 +1,51 @@ +INSTALL +======= + +Telemeta is written in python. So it doesn't require any compilation step +but the installation of some other programs. + +* On debian or Ubuntu just add these lines to your /etc/apt/sources-list: + + deb http://debian.parisson.org/ binary/ + deb-src http://debian.parisson.org/ source/ + + Then, + + sudo apt-get update + sudo apt-get install telemeta + + All the depending packages will be installed. + +* On other platforms, the first thing to do is then to install +python for your system with your favorite package manager (Linux +based distribution) or download and install it (Windows, MacOS) from +http://www.python.org/download/. + + To access the full power of telemeta's useful features, compile + and/or install by the same way (you may find them in your package + manager) the following programs : + + - python (http://www.python.org) + - python-xml + - python-mutagen + - oggenc (http://www.vorbis.com/) + - sox (http://sox.sourceforge.net/) + - flac (http://flac.sourceforge.net/) + - lame (http://lame.sourceforge.net/) + - ecasound (http://eca.cx/ecasound/) + - wavbreaker (http://huli.org/wavbreaker/) + - festival (http://www.cstr.ed.ac.uk/projects/festival/) + - par2 + + Get the lastest version with : + + svn co http://svn.parisson.org/svn/telemeta/trunk telemeta --username=anonymous + + Now, open a shell (console, terminal, etc..), go to the main + Telemeta directory and type AS ROOT : + + python install.py + + +type telemeta --help for more informations. + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9ba13ab --- /dev/null +++ b/Makefile @@ -0,0 +1,68 @@ +INSTALL ?= install +MAKE ?= make +RM ?= rm +RMDIR ?= rmdir +prefix ?= /usr/local + + +PREFIX = $(DESTDIR)$(prefix) + +BINDIR = $(PREFIX)/bin +MANDIR = $(PREFIX)/share/man/man1 +DATADIR = $(PREFIX)/share/telemaster +SRCDIR = $(DATADIR) +#PIXDIR = $(DATADIR)/pix +#RESDIR = $(DATADIR)/res + +#APPDIR = $(PREFIX)/share/applications +#ICONDIR = $(PREFIX)/share/pixmaps +#LOCALEDIR = $(PREFIX)/share/locale + +#LANGUAGES = `find locale/ -maxdepth 1 -mindepth 1 -type d -printf "%f "` + +help: + @echo Usage: + @echo "make - not used" + @echo "make clean - removes temporary data" + @echo "make install - installs data" + @echo "make uninstall - uninstalls data" + @echo "make help - prints this help" + @echo + + +install: + echo $(PREFIX) + $(INSTALL) -m 755 -d $(BINDIR) $(MANDIR) $(DATADIR) $(SRCDIR) +#$(PIXDIR) $(RESDIR) $(APPDIR) + $(INSTALL) -m 644 *.py $(SRCDIR) +# $(INSTALL) -m 644 res/*.glade $(RESDIR) + $(INSTALL) -m 644 debian/telemaster.1 $(MANDIR) +# $(INSTALL) -m 644 pix/*.png $(PIXDIR) +# $(INSTALL) -m 644 pix/telemaster.xpm $(ICONDIR) +# $(INSTALL) -m 644 res/telemaster.desktop $(APPDIR) + if test -L $(BINDIR)/telemaster; then ${RM} $(BINDIR)/telemaster; fi + ln -s $(SRCDIR)/telemaster.py $(BINDIR)/telemaster + chmod +x $(SRCDIR)/telemaster.py +# $(MAKE) -C po dist +# for lang in $(LANGUAGES); do \ +# ${INSTALL} -m 755 -d $(LOCALEDIR)/$$lang/LC_MESSAGES;\ +# $(INSTALL) -m 644 locale/$$lang/LC_MESSAGES/telemaster.mo $(LOCALEDIR)/$$lang/LC_MESSAGES/; \ +# done + + +uninstall: + ${RM} $(PREFIX)/bin/telemaster +# ${RM} $(APPDIR)/telemaster.desktop + ${RM} $(MANDIR)/telemaster.1 +# ${RM} $(ICONDIR)/telemaster.xpm + ${RM} -rf $(DATADIR) + $(RMDIR) --ignore-fail-on-non-empty $(BINDIR) $(MANDIR) +#$(APPDIR) +# for lang in $(LANGUAGES); do \ +# ${RM} $(LOCALEDIR)/$$lang/LC_MESSAGES/telemaster.mo; \ +# done + +clean: + ${RM} src/*.py[co] res/*~ res/*.bak + +.PHONY: help clean install diff --git a/README b/README new file mode 100644 index 0000000..22056f9 --- /dev/null +++ b/README @@ -0,0 +1,140 @@ +# README +# ====== + +Telemaster: backups, transcodes, tags and marks any audio content with metadata + + +# 1. Introduction +# =============== + +Telemaster is an audio tool which creates audio transcoded databases fast +from fresh mastered files. It can be useful to backup digitalized audio +media from vinyls, old tapes or whatever. + +Telemaster first creates a simple structure where original sounds will be +backuped. The files can be transcoded to WAV, FLAC, MP3 and OGG including +the corresponding tags. + +Here are some cool functions: + + - XML generation for metadata tags of backuped WAV + - Audio marking from a given file or from tags thanks to the Festival + speech systhesis tool + - File corruption security with par2 recovery files + - Database synchronizing to remote servers (ssh+rsync) + - Modify metadata from XML or interactive shell + + +# 2. Requirements +# =============== + +python (>= 2.3.5-7), python-xml, python-central (>= 0.5), python-mutagen, +sox, vorbis-tools, flac, lame, normalize-audio, ecasound, festival, par2 + + +# 3. Installation +# =============== + +Telemaster is written in python. So it doesn't require any compilation step. + +On debian or Ubuntu just add these lines to your /etc/apt/sources-list: + + deb http://debian.parisson.org/ binary/ + deb-src http://debian.parisson.org/ source/ + +Then, + + sudo apt-get update + sudo apt-get install telemaster + +On other linux platforms, get the lastest tar.gz version on : + + http://debian.parisson.org/ + +and uncompress the archive. +You can also get the lastest develoment version with subversion: + + svn co http://svn.parisson.org/svn/telemaster/trunk telemaster --username=anonymous + +Then go into the created directory and just type this with your favorite shell : + + python install.py + +Just press 'enter' for the password. + +See INSTALL file for more informations. + + +# 4. Usage +# ======== + +In order to backup all original or transcoded files into a collection, +telemaster needs first to create his repository. Let's type : + + telemaster --create COLLECTION + +Replacing COLLECTION with the name of your collection. Answer to +the questions. A target directory is then created. All answers +are saved into YOUR_HOME/.telemaster/default_database.xml and +YOUR_HOME/.telemaster/COLLECTION.xml + +To backup a wav file, type : + + telemaster --backup COLLECTION FILE.WAV + +where you have to replace FILE.WAV by the local file of your choice you +want to add in the database. Then, answer to the questions. All answers +are saved into YOUR_HOME/.telemaster/default_tags.xml and will be use for +the next execution. The program will automatically transcode the wav (or +aiff) file to the types you have defined (for example FLAC, MP3 and/or OGG) +and place them into each directory of the repository (for example flac/, +mp3/ and/or ogg/). + +To backup an entire directory, type : + + telemaster --backup COLLECTION --album DIRECTORY + +where you have to replace DIRECTORY by the local directory containing all +the audio files you want to add in the database. + +Other options: + + --from-xml takes tags and opts in original xml source + --force forces file conversion (no audio test) + --par2 forces par2 file creation + --all-default chooses default argument for all question + --recover check an repair the backuped media with the previously + created "par2" security key + --rsync synchronizes database to a remote server (ssh+rsync) + --erase erases a collection (FLAC, OGG, MP3 only, never WAV !) + --help gives help page + +# 5. EXAMPLES +# =========== + + telemaster --create my_collection + telemaster --backup my_collection file.wav + telemaster --backup my_collection --album ./ + telemaster --backup my_collection --album --par2 --rsync ./ + telemaster --backup my_collection --album --par2 --rsync --force ./ \n + +# 6. TODO +# ======= + +- HTTP web interface (metadata adding, editing, uploading, searching) +- debug id3 editing +- add media types + +# 7. Feedback +# =========== + +Please give me some feedback. Tell me if Telemaster suits you or if you +would need some other interesting features. You are welcome to mail me +at + +# 8. Contact +# ========== + +Home page : http://svn.parisson.org/telemaster +E-mail : Guillaume Pellerin + diff --git a/audio_marking.py b/audio_marking.py new file mode 100644 index 0000000..b9ce93c --- /dev/null +++ b/audio_marking.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# *coding: utf-8* +# +# Copyright (c) 2006-2007 Guillaume Pellerin +# +# 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 Library 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import os, sys, re, string +import tag_tools +from audio_tools import * + +def make_auto_mark(dir_in,file_in): + media_in = dir_in+file_in + artist_no_ = string.replace(tag_tools.get_tag_value('ARTIST'),'_',' ') + title_no_ = string.replace(tag_tools.get_tag_value('TITLE'),'_',' ') + description_no_ = string.replace(tag_tools.get_tag_value('COMMENT'),'_',' ') + os.system('echo "This is: '+title_no_+'. By '+artist_no_+'. It is '+description_no_+'" | text2wave -f 44100 -o "'+media_in+'_mark.tmp"') + #os.system('normalize-audio "'+media_in+'_mark.tmp"') + os.system('sox "'+media_in+'_mark.tmp" -t wav -c2 "'+media_in+'_mark.wav" vol 10.0 dB compand 50,20 -80,-80,-25,-35,-15,-27,-5,-19,0,-15 15') + os.system('rm '+dir_in+'*.tmp') + +def mark_audio(dir_in,file_in,audio_marking_file,audio_marking_timeline): + media_in = dir_in+file_in + file_length_sec = audio_length_sec(media_in) + audio_mark_length_sec = audio_length_sec(audio_marking_file) + ecasound_phrase = '' + audio_gain = str(100+100*len(audio_marking_timeline)) + + for timeline in audio_marking_timeline: + audio_marking_ecasound_filename = file_in+'_'+timeline+'.ewf' + audio_marking_ecasound_path = dir_in+file_in+'_'+timeline+'.ewf' + audio_marking_ecasound_file=open(audio_marking_ecasound_path,'w') + audio_marking_ecasound_file.write('-- '+audio_marking_ecasound_filename+' --\n') + audio_marking_ecasound_file.write('source = '+audio_marking_file+'\n') + if timeline == 'b': + mark_offset = '0' + ecasound_phrase = '-a:2 -i:"'+audio_marking_ecasound_path+'" -ea:'+audio_gain+' ' + if timeline == 'm': + mark_offset = str(file_length_sec/2) + ecasound_phrase = ecasound_phrase+'-a:3 -i:"'+audio_marking_ecasound_path+'" -ea:'+audio_gain+' ' + if timeline == 'e': + mark_offset = str(file_length_sec-audio_mark_length_sec) + ecasound_phrase = ecasound_phrase+'-a:4 -i:"'+audio_marking_ecasound_path+'" -ea:'+audio_gain+' ' + audio_marking_ecasound_file.write('offset = '+mark_offset+'.0\n') + audio_marking_ecasound_file.write('start-position = 0.0\n') + audio_marking_ecasound_file.write('length = '+str(audio_mark_length_sec)+'.0\n') + audio_marking_ecasound_file.write('looping = false\n') + audio_marking_ecasound_file.write('--cut--\n') + audio_marking_ecasound_file.close() + os.system('ecasound -a:1 -i:"'+media_in+'" -ea:'+audio_gain+' '+ecasound_phrase+' -a:all -o "'+dir_in+'marked_'+file_in+'"') + diff --git a/audio_tools.py b/audio_tools.py new file mode 100644 index 0000000..37ac4ca --- /dev/null +++ b/audio_tools.py @@ -0,0 +1,180 @@ +#!/usr/bin/python +# *coding: utf-8* +# +# Copyright (c) 2006-2007 Guillaume Pellerin +# +# 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 Library 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import os, sys, re, string +import tag_tools +from audio_tools import * + +def encode(enc_type,dir_in,file_in,dir_out,file_out): + media_in = dir_in+file_in + media_out = dir_out+file_out + + if enc_type == 'flac' : + quality = tag_tools.get_opt_value(enc_type+'_quality') + os.system('flac -f -V -q '+quality+' -o "'+media_out+'" "'+media_in+'"') + + if enc_type == 'ogg': + bitrate = tag_tools.get_opt_value(enc_type+'_bitrate') + os.system('oggenc -b '+bitrate+' -o "'+media_out+'" "'+media_in+'"') + + if enc_type == 'mp3': + bitrate = tag_tools.get_opt_value(enc_type+'_bitrate') + tag='temp' + os.system('lame -b '+bitrate+' --ta "'+tag+'" --tt "'+tag+'" --tl "'+tag+'" --ty '+tag+' --tg "Other" --tc "'+tag+'" "'+media_in+'" "'+media_out+'"') + + if enc_type == 'wav': + if iswav16(media_in): + os.system('cp -a "'+media_in+'" "'+media_out+'"') + else: + os.system('sox "'+media_in+'" -w -r 44100 -t wav -c2 "'+media_out+'"') + +# if enc_type == 'ogg' and ismp3(media_in): +# os.system('mp32ogg --verbose "'+file_in+'" "'+file_out+'"') + +def decode(media_in,file_ext): + if ismp3(media_in) or file_ext == 'mp3': + os.system('mpg123 -q -s "'+media_in+'" -w "'+media_in+'.wav"') + if isogg(media_in) or file_ext == 'ogg': + os.system('oggdec -o "'+media_in+'.wav" "'+media_in+'"') + if isflac(media_in) or file_ext == 'flac': + os.system('flac -d "'+media_in+'"') + if iswav(media_in) or file_ext == 'wav': + os.system('sox "'+media_in+'" -w -r 44100 -t wav -c2 "'+media_in+'.wav"') + if isaiff(media_in) or file_ext == 'aiff': + os.system('sox "'+media_in+'" -w -r 44100 -t aiff -c2 "'+media_in+'.wav"') + +def normalize(media_in): + os.system('normalize-audio "'+media_in+'"') + +def create_md5_key(dir_in,file_in): + media_in = dir_in+file_in + os.system('md5sum -b "'+media_in+'" "'+media_in+'.md5"') + +def check_md5_key(dir_in,file_in): + media_in = dir_in+file_in + md5_log = os.popen4('md5sum -c "'+media_in+'" "'+media_in+'.md5"') + if 'OK' in md5_log.split(':'): + return True + else: + return False + +def compare_md5_key(file_in,file_out): + media_in = file_in + media_out = file_out + if not os.path.exists(media_in): + return False + else: + print 'Checking md5sums...' + file_in_in, file_in_out = os.popen4('md5sum -b "'+media_in+'"') + file_out_in, file_out_out = os.popen4('md5sum -b "'+media_out+'"') + for line in file_in_out.readlines(): + line = line.split('*') + line = line[0] + #print line + for file_out_out_line in file_out_out.readlines(): + file_out_out_line= file_out_out_line.split('*') + file_out_out_line= file_out_out_line[0] + #print file_out_out_line + if line == file_out_out_line: + print 'Files are equal...\n' + return True + exit + else: + print 'Files are different...\n' + return False + exit + +def create_par_key(dir_in,file_in): + media_in = dir_in+file_in + os.system('par2 c -n1 "'+media_in+'"') + +def recover_par_key(dir_in): + for file in os.listdir(dir_in): + media_in = dir_in+file + if iswav(media_in): + os.system('par2 r "'+media_in+'"') + +def verify_par_key(media_in): + os.system('par2 v "'+media_in+'.par2"') + +def clean_directory(dir_in,type_list): + for enc_type in type_list: + if os.path.exists(dir_in+enc_type): + print 'Removing '+dir_in+enc_type + os.system('rm -rf "'+dir_in+enc_type+'"') + +def audio_length_sec(file) : + file_in, file_out = os.popen4('wavinfo "'+file+'" | grep wavDataSize') + for line in file_out.readlines(): + line_split = line.split(':') + value = int(int(line_split[1])/(4*44100)) + return value + +def ext_is_audio(file): + file_name_woext, file_ext = tag_tools.filename_split(file) + return file_ext == "mp3" or file_ext == "ogg" or file_ext == "flac" or file_ext == "wav" or file_ext == "aif" or file_ext == "aiff" or file_ext == "WAV" or file_ext == "AIFF" or file_ext == "AIF" or file_ext == "MP3" or file_ext == "OGG" or file_ext == "FLAC" + +def isaudio(file) : + file_in, file_out = os.popen4('file "'+file+'"') + for line in file_out.readlines(): + line_split = line.split(' ') + return (iswav16(file) or iswav(file) or ismp3(file) or isogg(file) or isflac(file) or isaiff(file) or isaiff16(file)) + +def iswav(file) : + file_in, file_out = os.popen4('file "'+file+'"') + for line in file_out.readlines(): + line_split = line.split(' ') + return ('WAVE' in line_split) + +def iswav16(file) : + file_in, file_out = os.popen4('file "'+file+'"') + for line in file_out.readlines(): + line_split = line.split(' ') + return ('WAVE' in line_split) and ('16' in line_split) + +def isaiff(file) : + file_in, file_out = os.popen4('file "'+file+'"') + for line in file_out.readlines(): + line_split = line.split(' ') + return ('AIFF' in line_split) + +def isaiff16(file) : + file_in, file_out = os.popen4('file "'+file+'"') + for line in file_out.readlines(): + line_split = line.split(' ') + return ('AIFF' in line_split) and ('16' in line_split) + +def ismp3(file) : + file_in, file_out = os.popen4('file "'+file+'"') + for line in file_out.readlines(): + line_split_space = line.split(' ') + line_split_comma = line.split(',') + return (('MPEG' in line_split_space and ' layer III' in line_split_comma) or 'MP3' in line_split_space) + +def isogg(file) : + file_in, file_out = os.popen4('file "'+file+'"') + for line in file_out.readlines(): + line_split = line.split(',') + return (' Vorbis audio' in line_split) + +def isflac(file) : + file_in, file_out = os.popen4('file "'+file+'"') + for line in file_out.readlines(): + line_split = line.split(' ') + return ('FLAC' in line_split) diff --git a/collection.py b/collection.py new file mode 100644 index 0000000..2885ffd --- /dev/null +++ b/collection.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# *coding: utf-8* +# +# Copyright (c) 2006-2007 Guillaume Pellerin +# +# 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 Library 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import os, string + +class Collection : + + def __init__(self) : + self.collection_name = 'telemaster_default' + self.collection_dir = '/home/'+os.environ["USER"]+'/telemaster/' + self.user_dir = '/home/'+os.environ["USER"]+'/.telemaster/' + self.user_tag_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_tags.xml' + self.user_collection_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_collection.xml' + self.tag_table = 'ARTIST,TITLE,ALBUM,DATE,GENRE,SOURCE,ENCODER,COMMENT' + self.type_list = 'mp3,ogg,flac,wav,aiff' + self.net_backup_host = 'domain.com' + self.net_backup_dir = '/home/'+os.environ["USER"]+'/telemaster/' + +#option_table=['enc_types','flac_bitrate','ogg_bitrate','mp3_bitrate','audio_marking','auto_audio_marking','audio_marking_file','audio_marking_timeline'] + +#questions = ['Output formats','flac_bitrate','ogg_bitrate','mp3_bitrate','Audio marking (y/n)','Auto audio marking (y/n)','Audio marking file path','Audio marking timeline (b)eginning, (m)iddle, (e)nd'] \ No newline at end of file diff --git a/consts.py b/consts.py new file mode 100644 index 0000000..3b0a9e3 --- /dev/null +++ b/consts.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# *coding: utf-8* +# +# Copyright (c) 2006-2007 Guillaume Pellerin +# +# 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 Library 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import os, string + +class Collection : + + def __init__(self) : + self.collection_name = 'telemaster_default' + self.collection_dir = '/home/'+os.environ["USER"]+'/telemaster_default/' + self.user_dir = '/home/'+os.environ["USER"]+'/.telemaster/' + self.default_tag_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_tags.xml' + self.default_collection_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_collection.xml' + self.tag_table = 'ARTIST,TITLE,ALBUM,DATE,GENRE,SOURCE,ENCODER,COMMENT' + self.type_list = 'mp3,ogg,flac,wav,aiff' + self.net_backup_host = 'domain.com' + self.net_backup_dir = '/home/'+os.environ["USER"]+'/telemaster/' + +#option_table=['enc_types','flac_bitrate','ogg_bitrate','mp3_bitrate','audio_marking','auto_audio_marking','audio_marking_file','audio_marking_timeline'] + +#questions = ['Output formats','flac_bitrate','ogg_bitrate','mp3_bitrate','Audio marking (y/n)','Auto audio marking (y/n)','Audio marking file path','Audio marking timeline (b)eginning, (m)iddle, (e)nd'] \ No newline at end of file diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..cb94e3e --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,6 @@ +telemeta for Debian +--------------- + +Soon ! + + -- Guillaume Pellerin , Thu, 17 Aug 2006 22:42:14 +0200 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..7b32a3c --- /dev/null +++ b/debian/changelog @@ -0,0 +1,94 @@ +telemaster (0.2.9) unstable; urgency=low + + * Fix MP3 bitrate + + -- Guillaume Pellerin Fri, 12 Sep 2008 15:10:22 +0200 + +telemaster (0.2.8) unstable; urgency=low + + * Renamed + + -- Guillaume Pellerin Wed, 10 Jun 2008 10:57:13 +0100 + +telemeta (0.2.5-2) unstable; urgency=low + + * Fixed --help page + + -- Guillaume Pellerin Wed, 10 Jan 2007 12:01:13 +0100 + +telemeta (0.2.5-1) unstable; urgency=low + + * Fixed --create and --backup option behaviors, thanks to Olivier Guilyardi + * Created the Collection class and interface + * Fixed error messages + * Made the collection XML file saved in collection dir AND user default dir + + -- Guillaume Pellerin Mon, 8 Jan 2007 02:50:04 +0100 + +telemeta (0.2.4-3) unstable; urgency=low + + * Fixed README and INSTALL pages + + -- Guillaume Pellerin Thu, 4 Jan 2007 18:56:05 +0100 + +telemeta (0.2.4-2) unstable; urgency=low + + * Fixed --help menu and man page + + -- Guillaume Pellerin Wed, 3 Jan 2007 22:18:05 +0100 + +telemeta (0.2.4-1) unstable; urgency=low + + * Rewrited the whole main structure + * Defined a class and xml for consts + * Fixed --erase-media option + * Fixed --recover option + * Added --create option: creates a database repository and default database xml + * Added --backup option: backups a media to the database + * Added --album option: proccesses an entire directory (one shot album) + * Added --from-xml: takes tags and opts in original xml source + * Added --all-default: chooses default argument for all question + * Added --par2 : forces par2 file creation + * Added --rsync : synchronizes database to a remote server (ssh+rsync) + * Added --clean-strings : cleans input strings + + -- Guillaume Pellerin Wed, 3 Jan 2007 18:55:52 +0100 + +telemeta (0.2.3-3) unstable; urgency=low + + * Fixed --force mode bug + + -- Guillaume Pellerin Wed, 22 Nov 2006 12:33:52 +0100 + +telemeta (0.2.3-2) unstable; urgency=low + + * fixed non audio file detection with 'file' command + + -- Guillaume Pellerin Wed, 15 Nov 2006 15:30:10 +0100 + +telemeta (0.2.3-1) unstable; urgency=low + + * Added python-xml parser dependency : + xml tag files are now exported to user default directory and in dir_in. + * Added par2 dependency : creates secure recovery key file with the "par2" method + * Added python-mutagen dependency : new tagging functions + * Cleaned : audio functions + * Fixed : help page + * Debianized + + -- Guillaume Pellerin Tue, 01 Nov 2006 00:25:46 +0100 + +telemeta (0.2.2) unstable; urgency=low + + * Defined : the tag and option lists + * Created : main audio functions + * Created : main tags functions + + -- Guillaume Pellerin Tue, 14 Jul 2006 00:00:01 +0100 + +telemeta (0.1) unstable; urgency=low + + * Initial release + * Created : First flac, ogg, mp3 exporting, tagging with basic functions + + -- Guillaume Pellerin Tue, 01 May 2006 23:45:42 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..d4f18d0 --- /dev/null +++ b/debian/control @@ -0,0 +1,28 @@ +Source: telemaster +Section: sound +Priority: optional +Maintainer: Guillaume Pellerin +Uploaders: Paul Brossier +Build-Depends: debhelper (>= 5.0.0), docbook-to-man, python (>= 2.3.5-7), python-dev (>= 2.3.5-7), python-central (>= 0.5) +Standards-Version: 3.8.0 +XS-Python-Version: >= 2.3 + +Package: telemaster +Architecture: any +Depends: python (>= 2.3.5-7), python-xml, python-central (>= 0.5), python-mutagen, sox, vorbis-tools, flac, lame, normalize-audio, ecasound, festival, par2 +XB-Python-Version: ${python:Versions} +Description: backups, transcodes, tags and marks any audio content with metadata + Telemeta is an audio tool which creates audio transcoded databases fast from + fresh mastered files. It can be useful to backup digitalized audio media from + vinyls, old tapes or whatever. + Telemeta first creates a simple structure where original sounds will be + backuped. The files can be transcoded to WAV, FLAC, MP3 and OGG including + the corresponding tags. + Here are some cool functions: + - XML generation for metadata tags of backuped WAV. + - Audio marking from a given file or from tags thanks to the Festival speech + systhesis tool + - File corruption security with par2 recovery files. + - Database synchronizing to remote servers (ssh+rsync). + - Modify metadata from XML or interactive shell. + See http://svn.parisson.org/telemaster/ for more informations. \ No newline at end of file diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..abf55cc --- /dev/null +++ b/debian/copyright @@ -0,0 +1,23 @@ +This package was debianized by Guillaume Pellerin on +Thu, 17 Aug 2006 22:42:14 +0200. + +It was downloaded from http://svn.parisson.org/telemeta/ + +Upstream Author: Guillaume Pellerin + +Copyright: + + Copyright (C) 2006-2007 Guillaume Pellerin + +License: + + The code is released under the terms of the GNU General Public License: + + 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, or (at your option) any later version. + + The GPL may be found in /usr/share/common-licenses/GPL-2 on a Debian system. + +The Debian packaging is (C) 2006, Guillaume Pellerin and +is licensed under the GPL, see `/usr/share/common-licenses/GPL-2'. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..e772481 --- /dev/null +++ b/debian/dirs @@ -0,0 +1 @@ +usr/bin diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..e845566 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +README diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..7bc0fba --- /dev/null +++ b/debian/files @@ -0,0 +1 @@ +telemaster_0.2.9_i386.deb sound optional diff --git a/debian/pycompat b/debian/pycompat new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/debian/pycompat @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..8b42e31 --- /dev/null +++ b/debian/rules @@ -0,0 +1,68 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This has to be exported to make some magic below work. +export DH_OPTIONS + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +build-stamp: + dh_testdir + touch build-stamp + + +build: build-stamp + docbook-to-man debian/telemaster.sgml > debian/telemaster.1 + #db2html -o doc/html debian/telemaster.sgml + rm -rf debian/telemaster + cp debian/changelog ChangeLog + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + $(MAKE) clean + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) DESTDIR=$(CURDIR)/debian/telemaster prefix=/usr install + +binary-indep: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + #dh_installexamples + dh_installman + #dh_installmenu -i + dh_link usr/share/telemaster/telemaster.py /usr/bin/telemaster + dh_compress + dh_fixperms + chmod +x debian/telemaster/usr/share/telemaster/*.py + dh_pycentral + #dh_python usr/share/telemaster + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-arch: build install + +binary: binary-indep binary-arch + +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/debian/telemaster.1 b/debian/telemaster.1 new file mode 100644 index 0000000..4891292 --- /dev/null +++ b/debian/telemaster.1 @@ -0,0 +1,110 @@ +.TH "telemaster" "1" +.SH "NAME" +telemaster \(em backups, transcodes, tags and marks any audio content with metadata +.SH "SYNOPSIS" +.PP +\fBtelemaster\fR [\fB\fIOPTIONS\fR\fP] [\fICOLLECTION\fR] [\fB\fIOPTIONS\fR\fP] [\fB\fIMEDIA\fR\fP] +.SH "DESCRIPTION" +.PP +\fBtelemaster\fR is an audio tool which creates audio transcoded collections fast from fresh mastered files. It can be useful to backup digitalized audio media from vinyls, old tapes or whatever and include them in a database. +.PP +Telemeta first creates a simple file structure where the original sounds will be backuped. The files can be transcoded to WAV, FLAC, MP3 and OGG including the corresponding tags. +.PP +Here are some cool functions: +.IP "\fB\fP" 10 +\- XML generation for metadata tags of backuped WAV +.IP "" 10 +\- Audio marking from a given file or from tags thanks to the Festival speech systhesis tool +.IP "" 10 +\- File corruption security with par2 recovery files +.IP "" 10 +\- Collection synchronizing to remote servers (ssh+rsync) +.IP "" 10 +\- Modify metadata from XML or interactive shell +.SH "OPTIONS" +.PP +These programs follow the usual GNU command line syntax, +with long options starting with two dashes (`\-'). A summary of +options is included below. For a complete description, see the +\fBInfo\fP files. +.IP "\fB\-\-create\fP " 10 +creates a collection repository +.IP "\fB\-\-backup\fP " 10 +backups and transcodes wave files to a collection +.IP "\fB\-\-album\fP " 10 +proccesses an entire directory (one shot album) +.IP "\fB\-\-backup\fP " 10 +backups a media to the collection +.IP "\fB\-\-from-xml\fP " 10 +takes tags and opts in original xml source +.IP "\fB\-\-force\fP " 10 +forces file conversion (no audio test) +.IP "\fB\-\-par2\fP " 10 +forces par2 security file creation +.IP "\fB\-\-all-default\fP " 10 +chooses default argument for all question +.IP "\fB\-\-recover\fP " 10 +check an repair the backuped media with the previously created "par2" security files +.IP "\fB\-\-rsync\fP " 10 +synchronizes collection to a remote server (ssh+rsync) +.IP "\fB\-\-erase\fP " 10 +erases a collection (flac, ogg, mp3 only !) +.IP "\fB\-\-help\fP " 10 +Show summary of options. +.IP "\fB\-\-version\fP " 10 +Show version of program. +.SH "EXAMPLES" +.PP +\fBtelemaster \-\-create my_collection\fR +.PP +\fBtelemaster \-\-backup my_collection file.wav\fR +.PP +\fBtelemaster \-\-backup my_collection \-\-album /path/to/directory/\fR +.PP +\fBtelemaster \-\-backup my_collection \-\-album \-\-par2 \-\-rsync /path/to/directory/\fR +.PP +\fBtelemaster \-\-backup my_collection \-\-album \-\-par2 \-\-rsync \-\-force /path/to/directory/\fR +.SH "DOWNLOAD" +.PP +Telemeta is written in python. So it doesn't require any compilation step. +.PP +On Debian or Ubuntu just add these lines to your /etc/apt/sources-list: +.PP +\fBdeb http://debian.parisson.org/ binary/\fR +.PP +\fBdeb-src http://debian.parisson.org/ source/\fR +.PP +Then, +.PP +\fBsudo apt-get update\fR +.PP +\fBsudo apt-get install telemaster\fR +.PP +On other linux platforms, \fIdownload (link to URL http://debian.parisson.org/) \fR the lastest tar.gz archive, uncompress it, go into the created directory and just type this with your favorite shell : +.PP +\fBpython install.py\fR +.PP +See README and INSTALL file for more informations. +.PP +You can also get the lastest version of Telemeta with subversion (just type 'enter' for the password: +.PP +svn co http://svn.parisson.org/svn/telemaster/trunk telemaster \-\-username=anonymous +.SH "DEPENDS" +.PP +python (>= 2.3.5-7), python-xml, python-central (>= 0.5), python-mutagen, sox, vorbis-tools, flac, lame, normalize-audio, ecasound, festival, par2 +.SH "SEE ALSO" +.PP +The program is documented fully by Guillaume Pellerin. More info at \fI\fIhttp://svn.parisson.org/telemaster/ (link to URL http://svn.parisson.org/telemaster/) \fR\fP. +.SH "AUTHOR" +.PP +This manual page was written by Guillaume Pellerin for +the \fBDebian\fP system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GNU General Public License, Version 2 any +later version published by the Free Software Foundation. + +.PP +On Debian systems, the complete text of the GNU General Public +License can be found in /usr/share/common-licenses/GPL. + +.\" created by instant / docbook-to-man, Fri 12 Sep 2008, 15:10 diff --git a/debian/telemaster.debhelper.log b/debian/telemaster.debhelper.log new file mode 100644 index 0000000..2678259 --- /dev/null +++ b/debian/telemaster.debhelper.log @@ -0,0 +1,12 @@ +dh_installdirs +dh_installchangelogs +dh_installdocs +dh_installman +dh_link +dh_compress +dh_fixperms +dh_pycentral +dh_installdeb +dh_gencontrol +dh_md5sums +dh_builddeb diff --git a/debian/telemaster.postinst.debhelper b/debian/telemaster.postinst.debhelper new file mode 100644 index 0000000..70b9042 --- /dev/null +++ b/debian/telemaster.postinst.debhelper @@ -0,0 +1,8 @@ +# Automatically added by dh_pycentral +if which pycentral >/dev/null 2>&1; then + pycentral pkginstall telemaster + if grep -qs '^telemaster$' /var/lib/pycentral/delayed-pkgs; then + sed -i '/^telemaster$/d' /var/lib/pycentral/delayed-pkgs + fi +fi +# End automatically added section diff --git a/debian/telemaster.preinst.debhelper b/debian/telemaster.preinst.debhelper new file mode 100644 index 0000000..c5c2229 --- /dev/null +++ b/debian/telemaster.preinst.debhelper @@ -0,0 +1,25 @@ +# Automatically added by dh_pycentral +if which pycentral >/dev/null 2>&1 && pycentral --help 2>/dev/null | grep -q '^ *version'; then + pycentral pkgprepare telemaster <= 2.3 +[pycentral] +version = 0.6.7 +[files] +/usr/share/telemaster/audio_marking.py=f +/usr/share/telemaster/audio_tools.py=f +/usr/share/telemaster/collection.py=f +/usr/share/telemaster/consts.py=f +/usr/share/telemaster/default_options.py=f +/usr/share/telemaster/default_tags.py=f +/usr/share/telemaster/install.py=f +/usr/share/telemaster/tag_tools.py=f +/usr/share/telemaster/telemaster.py=f +/usr/share/telemaster/typeToolBox.py=f +PYEOF +else + mkdir -p /var/lib/pycentral + echo telemaster >> /var/lib/pycentral/delayed-pkgs +fi +# End automatically added section diff --git a/debian/telemaster.prerm.debhelper b/debian/telemaster.prerm.debhelper new file mode 100644 index 0000000..6576ea7 --- /dev/null +++ b/debian/telemaster.prerm.debhelper @@ -0,0 +1,45 @@ +# Automatically added by dh_pycentral +case "$1" in remove|upgrade) + pkgremove=y +esac +if [ -f /var/lib/pycentral/telemaster.pkgremove ] || [ -f /var/lib/pycentral/pkgremove ]; then + pkgremove=y +fi +if [ "$pkgremove" = y ]; then +if which python >/dev/null 2>&1 && which pycentral >/dev/null 2>&1; then + pycentral pkgremove telemaster +else + flist=$(tempfile) + slist=$(tempfile) + dpkg -L telemaster | tee $flist | \ + while read n; do + case "$n" in + /usr/share/pyshared/*) + n2=${n#/usr/share/pyshared/*} + case "$n" in + *.py) echo "p $n";; + *) [ -d "$n" ] && echo "d $n2" || echo "f $n2" + esac + ;; + *) continue + esac + done > $slist + if [ -s $slist ]; then + for d in /usr/lib/python[0-9].[0-9]/????-packages; do + case "$d" in */python2.1/*|*/python2.2/*) continue; esac + while read t n; do + case "$t" in + p) rm -f $d/$n $d/${n}[co];; + d) rmdir $d/$n 2>/dev/null || true;; + *) rm -f $d/$n + esac + done < $slist + done + fi + awk '/\/usr\/share\/pyshared/ {next} /\.py$/ {print $0"c\n" $0"o"}' $flist \ + | xargs -r rm -f >&2 + rm -f $flist $slist +fi +rm -f /var/lib/pycentral/telemaster.pkgremove +fi +# End automatically added section diff --git a/debian/telemaster.sgml b/debian/telemaster.sgml new file mode 100644 index 0000000..1bdb31f --- /dev/null +++ b/debian/telemaster.sgml @@ -0,0 +1,271 @@ + manpage.1'. You may view + the manual page with: `docbook-to-man manpage.sgml | nroff -man | + less'. A typical entry in a Makefile or Makefile.am is: + +manpage.1: manpage.sgml + docbook-to-man $< > $@ + + + The docbook-to-man binary is found in the docbook-to-man package. + Please remember that if you create the nroff version in one of the + debian/rules file targets (such as build), you will need to include + docbook-to-man in your Build-Depends control field. + + --> + + + Guillaume"> + Pellerin"> + + August 17, 2006"> + + 1"> + yomguy@altern.org"> + + telemaster"> + + + Debian"> + GNU"> + GPL"> +]> + + + +
+ &dhemail; +
+ + &dhfirstname; + &dhsurname; + + + 2006-2007 + &dhusername; + + &dhdate; +
+ + &dhucpackage; + + &dhsection; + + + &dhpackage; + + backups, transcodes, tags and marks any audio content with metadata + + + + &dhpackage; + + COLLECTION + + + + + + DESCRIPTION + + &dhpackage; is an audio tool which creates audio transcoded collections fast from fresh mastered files. It can be useful to backup digitalized audio media from vinyls, old tapes or whatever and include them in a database. + Telemeta first creates a simple file structure where the original sounds will be backuped. The files can be transcoded to WAV, FLAC, MP3 and OGG including the corresponding tags. + Here are some cool functions: + + + + + - XML generation for metadata tags of backuped WAV + - Audio marking from a given file or from tags thanks to the Festival speech systhesis tool + - File corruption security with par2 recovery files + - Collection synchronizing to remote servers (ssh+rsync) + - Modify metadata from XML or interactive shell + + + + + + OPTIONS + + These programs follow the usual &gnu; command line syntax, + with long options starting with two dashes (`-'). A summary of + options is included below. For a complete description, see the + Info files. + + + + + + + creates a collection repository + + + + + + + backups and transcodes wave files to a collection + + + + + + + proccesses an entire directory (one shot album) + + + + + + + backups a media to the collection + + + + + + + takes tags and opts in original xml source + + + + + + + forces file conversion (no audio test) + + + + + + + forces par2 security file creation + + + + + + + chooses default argument for all question + + + + + + + check an repair the backuped media with the previously created "par2" security files + + + + + + + synchronizes collection to a remote server (ssh+rsync) + + + + + + + erases a collection (flac, ogg, mp3 only !) + + + + + + + Show summary of options. + + + + + + + Show version of program. + + + + + + + EXAMPLES + telemaster --create my_collection + telemaster --backup my_collection file.wav + telemaster --backup my_collection --album /path/to/directory/ + telemaster --backup my_collection --album --par2 --rsync /path/to/directory/ + telemaster --backup my_collection --album --par2 --rsync --force /path/to/directory/ + + + + DOWNLOAD + Telemeta is written in python. So it doesn't require any compilation step. + On Debian or Ubuntu just add these lines to your /etc/apt/sources-list: + + deb http://debian.parisson.org/ binary/ + deb-src http://debian.parisson.org/ source/ + + Then, + + sudo apt-get update + sudo apt-get install telemaster + + On other linux platforms, download the lastest tar.gz archive, uncompress it, go into the created directory and just type this with your favorite shell : + + python install.py + + See README and INSTALL file for more informations. + You can also get the lastest version of Telemeta with subversion (just type 'enter' for the password: + svn co http://svn.parisson.org/svn/telemaster/trunk telemaster --username=anonymous + + + + + DEPENDS + + python (>= 2.3.5-7), python-xml, python-central (>= 0.5), python-mutagen, sox, vorbis-tools, flac, lame, normalize-audio, ecasound, festival, par2 + + + + SEE ALSO + + The program is documented fully by Guillaume Pellerin. More info at http://svn.parisson.org/telemaster/. + + + + AUTHOR + + This manual page was written by &dhusername; <&dhemail;> for + the &debian; system (but may be used by others). Permission is + granted to copy, distribute and/or modify this document under + the terms of the &gnu; General Public License, Version 2 any + later version published by the Free Software Foundation. + + + On Debian systems, the complete text of the GNU General Public + License can be found in /usr/share/common-licenses/GPL. + + + +
+ + + + diff --git a/debian/telemaster.substvars b/debian/telemaster.substvars new file mode 100644 index 0000000..4513bc7 --- /dev/null +++ b/debian/telemaster.substvars @@ -0,0 +1,2 @@ +python:Versions=>= 2.3 +python:Depends=python (>= 2.3), python-central (>= 0.6.7) diff --git a/default_options.py b/default_options.py new file mode 100644 index 0000000..065e97b --- /dev/null +++ b/default_options.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# *coding: utf-8* +# +# Copyright (c) 2006-2007 Guillaume Pellerin +# +# 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 Library 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +class Options : + + def __init__(self) : + self.collection = 'Unknown' + self.enc_types = 'flac, ogg, mp3' + self.ogg_bitrate ='192' + self.mp3_bitrate = '192' + self.flac_quality = '5' + self.audio_marking = False + self.auto_audio_marking = True + self.audio_marking_file = '/path/to/file' + self.audio_marking_timeline = 'b, m, e' + self.par_key = True + self.normalize = False diff --git a/default_tags.py b/default_tags.py new file mode 100644 index 0000000..a03c620 --- /dev/null +++ b/default_tags.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# *coding: utf-8* +# +# Copyright (c) 2006-2007 Guillaume Pellerin +# +# 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 Library 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +class Tags : + + def __init__(self) : + self.COLLECTION = 'Unknown' + self.ARTIST = 'Unknown' + self.TITLE = 'Unknown' + self.ALBUM = 'Unknown' + self.GENRE = 'Other' + self.DATE = '1900' + self.SOURCE = 'Here' + self.ENCODER = 'me@domain.com' + self.COMMENT = 'No comment' + self.ORIGINAL_MEDIA = '1/4" tape' + diff --git a/install.py b/install.py new file mode 100755 index 0000000..0bfba58 --- /dev/null +++ b/install.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +# *coding: utf-8* +# +# Copyright (c) 2006-2007 Guillaume Pellerin +# +# 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 Library 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ONLY FOR LINUX + +import os, sys + +if len(sys.argv) == 1: + install_dir = '/usr/share/telemaster/' +elif len(sys.argv) > 2: + sys.exit('Give just one directory to install Telemeta, or none.') +else: + install_dir = sys.argv[1] + +if not os.path.exists(install_dir): + os.mkdir(install_dir) + +os.system('cp -ra ./* '+install_dir+os.sep) +os.system('rm -rf '+install_dir+os.sep+'debian') + +if os.path.exists('/usr/bin/telemaster'): + os.system('rm -r /usr/bin/telemaster') + +os.system('ln -s '+install_dir+os.sep+'telemaster.py '+'/usr/bin/telemaster') + +print "Installation successfull ! Type 'telemaster' now..." + diff --git a/tag_tools.py b/tag_tools.py new file mode 100644 index 0000000..25733d7 --- /dev/null +++ b/tag_tools.py @@ -0,0 +1,309 @@ +#!/usr/bin/python +# *coding: utf-8* +# +# Copyright (c) 2006-2007 Guillaume Pellerin +# +# 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 Library 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAA + +import os, sys, re, string +import default_tags +import default_options +import consts +import typeToolBox +import xml.dom.minidom +import xml.dom.ext +from audio_tools import * +from mutagen.flac import FLAC +from mutagen.oggvorbis import OggVorbis +from mutagen.id3 import ID3, TIT2, TP1, TAL, TDA, TCO, COM + +# Default values are used at first +tags = default_tags.Tags() +options = default_options.Options() +collection = consts.Collection() + +# Collection +# ============ + +def write_collection_consts(fic): + doc = xml.dom.minidom.Document() + root = doc.createElement('telemaster') + doc.appendChild(root) + for data in collection.__dict__.keys() : + value = collection.__dict__[data] + node = doc.createElement('data') + node.setAttribute('name', data) + node.setAttribute('value', str(value)) + node.setAttribute('type', typeToolBox.getType(value)) + root.appendChild(node) + file_object = open(fic, "w") + xml.dom.ext.PrettyPrint(doc, file_object) + file_object.close() + +def get_collection_consts(doc): + for data in doc.documentElement.getElementsByTagName('data') : + name = data.getAttribute('name') + value = typeToolBox.cast(data.getAttribute('value'), data.getAttribute('type')) + collection.__dict__[name] = value + +def ask_write_collection(name): + global collection + for data in collection.__dict__.keys() : + if data == 'collection_name' : + def_value = name + type_def_value = typeToolBox.getType(def_value) + value = raw_input(data+' ? ['+str(def_value)+']: ') + elif data == 'default_collection_xml' : + collection_xml = '/home/'+os.environ["USER"]+'/.telemaster/'+name+'.xml' + type_def_collection = typeToolBox.getType(collection_xml) + collection_tmp = typeToolBox.cast(collection_xml,type_def_collection) + collection.__dict__[data] = collection_tmp + value = collection.__dict__[data] + elif data == 'collection_dir' : + collection_dir = '/home/'+os.environ["USER"]+'/'+name + type_def_collection_dir = typeToolBox.getType(collection_dir) + collection_tmp = typeToolBox.cast(collection_dir,type_def_collection_dir) + collection.__dict__[data] = collection_tmp + def_value = collection.__dict__[data] + value = raw_input(data+' ? ['+str(def_value)+']: ') + elif data == 'user_dir' : + def_value = '/home/'+os.environ["USER"]+'/.telemaster/' + type_def_value = typeToolBox.getType(def_value) + value = def_value + elif data == 'default_tag_xml' : + def_value = '/home/'+os.environ["USER"]+'/.telemaster/default_tags.xml' + type_def_value = typeToolBox.getType(def_value) + value = def_value + else : + def_value = collection.__dict__[data] + type_def_value = typeToolBox.getType(def_value) + value = raw_input(data+' ? ['+str(def_value)+']: ') + if not value == '' : + value = typeToolBox.cast(value,type_def_value) + #value = string.replace(in_float,' ','') + collection.__dict__[data] = value + +def get_consts_value(data): + value = collection.__dict__[data] + type_value = typeToolBox.getType(value) + return value + +# TAGS +# ===== + +def write_tags(enc_type,dir_out,file_out): + media_out = dir_out+file_out + + if enc_type == 'flac': + audio = FLAC(media_out) + for tag in tags.__dict__.keys(): + if tag == 'COMMENT': + audio['DESCRIPTION'] = tags.__dict__[tag] + else: + audio[tag] = tags.__dict__[tag] + audio.save() + + if enc_type == 'ogg': + audio = OggVorbis(media_out) + for tag in tags.__dict__.keys(): + audio[tag] = tags.__dict__[tag] + audio.save() + + if enc_type == 'mp3': + audio = ID3(media_out) + #tags = ['ALBUM','DATE','GENRE','SOURCE','ENCODER','COMMENT'] + tag = tags.__dict__['TITLE'] + audio.add(TIT2(encoding=3, text=tag)) + tag = tags.__dict__['ARTIST'] + audio.add(TP1(encoding=3, text=tag)) + tag = tags.__dict__['ALBUM'] + audio.add(TAL(encoding=3, text=tag)) + tag = tags.__dict__['DATE'] + audio.add(TDA(encoding=3, text=tag)) + tag = tags.__dict__['GENRE'] + audio.add(TCO(encoding=3, text=tag)) + tag = tags.__dict__['COMMENT'] + audio.add(COM(encoding=3, text=tag)) + audio.save() + +def write_def_tags(fic): + doc = xml.dom.minidom.Document() + root = doc.createElement('telemaster') + doc.appendChild(root) + for tag in tags.__dict__.keys() : + value = tags.__dict__[tag] + node = doc.createElement('tag') + node.setAttribute('name', tag) + node.setAttribute('value', str(value)) + node.setAttribute('type', typeToolBox.getType(value)) + root.appendChild(node) + for opt in options.__dict__.keys() : + value = options.__dict__[opt] + node = doc.createElement('opt') + node.setAttribute('name', opt) + node.setAttribute('value', str(value)) + node.setAttribute('type', typeToolBox.getType(value)) + root.appendChild(node) + file_object = open(fic, "w") + xml.dom.ext.PrettyPrint(doc, file_object) + file_object.close() + +def ask_write_tag(): + global tags + global options + for tag in tags.__dict__.keys() : + def_value = tags.__dict__[tag] + type_def_value = typeToolBox.getType(def_value) + value = raw_input(tag+' ? ['+str(def_value)+']: ') + if not value == '' : + value = typeToolBox.cast(value,type_def_value) + #value = string.replace(in_float,' ','') + tags.__dict__[tag] = value + for opt in options.__dict__.keys() : + def_value = options.__dict__[opt] + type_def_value = typeToolBox.getType(def_value) + value = raw_input(opt+' ? ['+str(def_value)+']: ') + if not value == '' : + value = typeToolBox.cast(value,type_def_value) + #value = string.replace(in_float,' ','') + options.__dict__[opt] = value + +def get_def_tags(doc): + for tag in doc.documentElement.getElementsByTagName('tag') : + name = tag.getAttribute('name') + value = typeToolBox.cast(tag.getAttribute('value'), tag.getAttribute('type')) + tags.__dict__[name] = value + for opt in doc.documentElement.getElementsByTagName('opt') : + name = opt.getAttribute('name') + value = typeToolBox.cast(opt.getAttribute('value'), opt.getAttribute('type')) + options.__dict__[name] = value + +def rename_tag(old_tag,new_tag): + tag_list = tags.__dict__.keys() + if old_tag in tag_list: + tag_index = tag_list.index(old_tag) + tag_list.remove(old_tag) + tag_list.insert(tag_index,new_tag) + +def get_tag_value(tag): + value = tags.__dict__[tag] + type_value = typeToolBox.getType(value) + return value + +def get_opt_value(opt): + value = options.__dict__[opt] + type_value = typeToolBox.getType(value) + return value + +def add_tag(tag,value): + tag_list = tags.__dict__.keys() + tag_list.insert(0,tag) + tags.__dict__[tag] = value + +def add_opt(opt,value): + opt_list = options.__dict__.keys() + opt_list.insert(0,opt) + options.__dict__[opt] = value + +def rename_file(src_dir,file,file_name): + if (file_name != "" and file_name != file): + print "Renaming: %s -> %s\n" % (file,file_name) + os.rename(src_dir+file, src_dir+file_name) + +def filename_split(file_name): + filename_split = file_name.split('.') + if len(filename_split) > 0: + file_ext = filename_split[len(filename_split)-1] + else: + file_ext = '' + file_name_woext = '.'.join(filename_split[:-1]) + return file_name_woext, file_ext + +#def check_ext(): + #if not ext_is_audio(file): + #file_name_woext = file_name + #if iswav(src_dir+file) : + #file_ext = "wav" + #if isaiff(src_dir+file) : + #file_ext = "aiff" + #if ismp3(src_dir+file) : + #file_ext = "mp3" + #if isogg(src_dir+file) : + #file_ext = "ogg" + #if isflac(src_dir+file) : + #file_ext = "flac" + +def clean_filename(file_name) : + file_name = re.sub("^[^\w]+","",filename) #trim the beginning + file_name = re.sub("[^\w]+$","",file_name) #trim the end + file_name = string.replace(file_name,' ','_') + file_name = re.sub("_+","_",file_name) #squeeze continuous _ to one _ + file_name = re.sub("^[^\w]+","",file_name) #trim the beginning _ + #file_name = string.capitalize(file_name) + return file_name + +def name2tag(src_dir,file_name_woext,file_ext): + # get main tag + tag_list = file_name_woext.split('-') + tag_list_new = range(len(tag_list)) + + #for num_t in tag_list[0]: + # if num_t == str(int(num_t)): + # i_t = 1 + # else: + + # computing main tags if many tags + if len(tag_list) > 1 : + i_t = 0 + artist_tmp = string.replace(tag_list[i_t],' ','_') + artist_tmp = artist_tmp.split('_') + i = 0 + for artist_word in artist_tmp : + artist_tmp[i] = string.capitalize(artist_word) + i = i+1 + artist = '_'.join(artist_tmp[:]) + artist = re.sub("[\_]+$","",artist) #trim the end + tag_list_new[i_t] = artist + artist = string.replace(artist,'_',' ') + + i_t = i_t + 1 + title = string.replace(tag_list[i_t],' ','_') + title = re.sub("^[\_]+","",title) #trim the beginning + title = re.sub("[\_]+$","",title) #trim the end + title_tmp = title.split('_') + title_tmp[0] = string.capitalize(title_tmp[0]) + title = '_'.join(title_tmp[:]) + tag_list_new[i_t] = title + title = string.replace(title,'_',' ') + + # computing main tag if only one tag + if len(tag_list) == 1 : + artist = get_tag_value('ARTIST') + i_t = 0 + title = string.replace(tag_list[i_t],' ','_') + title = re.sub("^[\_]+","",title) #trim the beginning + title = re.sub("[\_]+$","",title) #trim the end + title_tmp = title.split('_') + title_tmp[0] = string.capitalize(title_tmp[0]) + title = '_'.join(title_tmp[:]) + tag_list_new[i_t] = title + title = string.replace(title,'_',' ') + + file_name_new = '-'.join(tag_list_new[:]) + + # renaming main source file + file_name = file_name_new+'.'+file_ext + + return title,artist,file_name_new diff --git a/telemaster.py b/telemaster.py new file mode 100755 index 0000000..2bd4da0 --- /dev/null +++ b/telemaster.py @@ -0,0 +1,461 @@ +#!/usr/bin/python +# *-* coding: utf-8 *-* +""" + telemaster + + Copyright (c) 2006-2007 Guillaume Pellerin + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +""" + +# Version +# ======= +version = '0.2.8' + +# Modules and error routines +# ========================== +import os, sys, re, string, shutil +import xml.dom.minidom +import xml.dom.ext +import consts +import audio_marking +import tag_tools +import audio_tools +import default_tags +import default_options +import typeToolBox +from audio_tools import * + + +# Info, error +# =========== +if len(sys.argv) == 1 : + print "telemaster v"+str(version)+" (c) 2006-2008 Guillaume Pellerin >" + print "version: "+str(version) + print "depends: python, python-xml, python-mutagen, sox, oggenc, flac, lame, normalize-audio, ecasound, wavbreaker, festival" + print "distributed under the terms of the GNU Public License v2.\n" + print """ 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.\n""" + sys.exit('Type telemaster --help for help !\n') + +elif sys.argv[1] == '--help': + print "TELEMETA:" + print " backups, transcodes, tags and marks any audio content with metadata\n" + print "VERSION:" + print " "+str(version)+'\n' + print "DEPENDS:" + print " python, python-xml, python-mutagen, sox, oggenc, flac, lame, normalize-audio, ecasound, wavbreaker, festival\n" + print "COPYRIGHT:" + print " Copyright (c) 2006-2008 Guillaume Pellerin \n" + print "LICENSE:" + print " distributed under the terms of the GNU Public License v2.\n" + print "USAGE:" + print " telemaster [OPTIONS] COLLECTION [OPTIONS] [MEDIA] \n" + print "COLLECTION:" + print " - the name of collection you want to create" + print " - the name of collection you want to backup or process into\n" + print "MEDIA:" + print " - an audio file" + print " - a directory when the --album option is given\n" + print "OPTIONS:" + print " --create creates a collection repository" + print " --backup backups and transcodes wave files to a collection" + print " --album proccesses an entire directory (one shot album)" + print " --from-xml takes tags and opts in original xml source" + print " --force forces file conversion" + print " --add-tag add a tag to a collection" + print ' --par2 forces security "par2" key creation' + print " --all-default chooses default argument for all question" + print ' --recover check an repair the backuped media with the previously created "par2" security key' + print " --rsync synchronizes a collection with a remote server repository (ssh+rsync)" + print " --erase erases a collection (flac, ogg, mp3 only !)" + print " --version gives the program version" + print " --help gives help page\n" + print "EXAMPLES:" + print " telemaster --create my_collection" + print " telemaster --backup my_collection file.wav" + print " telemaster --backup my_collection --album /path/to/directory/" + print " telemaster --backup my_collection --album --par2 --rsync /path/to/directory/" + print " telemaster --backup my_collection --album --par2 --rsync --force /path/to/directory/\n" + print "AUTHOR:" + print " Guillaume Pellerin \n" + print "URL:" + print " http://svn.parisson.org/telemaster\n" + print 'IMPORTANT:' + print " With the '--album' option, it supposed that all your wav files in the directory are named respectively to this scheme :" + print " artist-title[-album-date-genre-description][.wav]" + print " where the 'artist' and 'title' tags are necessary needed." + print " Tags between [] are optional main tags.\n" + print "FOR MORE INFORMATIONS :" + print " - read the README file" + print " - go to http://svn.parisson.org/telemaster" + sys.exit(' - email me !\n') + +elif sys.argv[1] == '--version': + sys.exit('Version: '+str(version)) + +else : + print "telemaster v"+str(version)+" (c) 2006-2007 Guillaume Pellerin " + print """ 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.\n""" + + +# Initialisation +# =============== + +argv = sys.argv +len_argv = len(argv) + +# Get collection consts +collection = consts.Collection() + +# Get arguments +if '--recover' in argv : + index = argv.index('--recover') + audio_tools.recover_par_key(argv[index+1]+os.sep) + sys.exit('Directory successfully recovered !') + +if '--erase' in argv : + type_list = tag_tools.get_consts_value('type_list') + type_list = type_list.split(',') + index = argv.index('--erase') + audio_tools.clean_directory(argv[index+1],type_list) + sys.exit('Media directories successfully cleaned !') + +if '--force' in argv : + print 'Warning: forcing file transfert and conversion (no audio test) !\n' + mode_force = True +else : + mode_force = False + +if '--album' in argv : + print 'Warning: album (recusive) mode...\n' + mode_album = True +else : + mode_album = False + +if '--backup' in argv : + print 'Warning: backup mode...\n' + mode_backup = True +else : + mode_backup = False + +if '--tags' in argv : + print 'Warning: making tags...\n' + mode_tags = True +else : + mode_tags = False + +if '--add-tag' in argv : + print 'Warning: adding tags...\n' + mode_add_tag = True +else : + mode_add_tag = False + +if '--from-xml' in argv : + print 'Warning: processing from XML...\n' + mode_from_xml = True +else : + mode_from_xml = False + +if '--clean-strings' in argv : + print 'Warning: Cleaning strings...\n' + mode_clean = True +else : + mode_clean = False + +if '--all-default' in argv : + print 'Warning: default mode enabled...\n' + mode_default = True +else : + mode_default = False + +if '--par2' in argv : + print 'Warning: creates par2 security keys...\n' + mode_par2 = True +else : + mode_par2 = False + +if '--rsync' in argv : + print 'Warning: synchronize with remote host...\n' + mode_rsync = True +else : + mode_rsync = False + +if '--create' in argv : + print 'Warning: creating a telemaster collection...\n' + mode_create = True +else : + mode_create = False + +# Creates user default dir +user_dir = tag_tools.get_consts_value('user_dir') +if not os.path.exists(user_dir): + os.mkdir(user_dir) + +# Create or check the databse config +default_collection_xml = tag_tools.get_consts_value('default_collection_xml') +if not os.access(default_collection_xml, os.F_OK) : + tag_tools.write_collection_consts(default_collection_xml) + +# Create the collection +if mode_create : + if len(argv) == 3 : + index = argv.index('--create') + collection_name = argv[index+1] + tag_tools.ask_write_collection(collection_name) + default_collection_xml = tag_tools.get_consts_value('default_collection_xml') + collection_dir = tag_tools.get_consts_value('collection_dir') + if not os.path.exists(collection_dir): + os.mkdir(collection_dir) + else : + sys.exit('ERROR: the collection '+collection_name+' already exists') + tag_tools.write_collection_consts(default_collection_xml) + tag_tools.write_collection_consts(collection_dir+os.sep+collection_name+'.xml') + # Parses collection data + sys.exit("\nCollection created ! You can now --backup media in it...") + else : + sys.exit("ERROR: no collection name given... : give a name for your collection.") +# Backup into the collection +elif mode_backup : + # Check syntax + if not os.path.exists(sys.argv[len(sys.argv)-1]) : + sys.exit("ERROR: no such media... : give a directory or a file as last argument.") + index = argv.index('--backup') + collection_name = argv[index+1] + collection_xml = user_dir+os.sep+collection_name+'.xml' + if not os.path.exists(collection_xml) : + sys.exit("This collection doesn't exists. Create it first ! (--create)") + else : + doc = xml.dom.minidom.parse(user_dir+os.sep+collection_name+'.xml') + print "Parsing collection XML file..." + tag_tools.get_collection_consts(doc) + collection_dir = tag_tools.get_consts_value('collection_dir') + print "OK\n" + + +# Creates source dir +src_dir = collection_dir+os.sep+'src'+os.sep +if not os.path.exists(src_dir) : + os.mkdir(src_dir) + +# Creates user default tag/opt file and parse it +default_tag_xml = tag_tools.get_consts_value('default_tag_xml') +if not os.access(default_tag_xml, os.F_OK) : + tag_tools.write_def_tags(default_tag_xml) + +# Parses tag data +doc = xml.dom.minidom.parse(default_tag_xml) +tag_tools.get_def_tags(doc) + +# Initializes master file list +file_master_list = range(1) + +# File listing for album mode +if mode_album : + master_dir = argv[len_argv-1]+os.sep + if os.path.isdir(master_dir): + file_master_list = os.listdir(master_dir) + else: + sys.exit('Please give a directory path for the last argument (album mode)...') +# File listing in normal mode +else : + master_dir = argv[len_argv-1] + if os.path.isdir(master_dir): + file_master_list = os.listdir(master_dir) + elif os.path.isfile(master_dir): + master_dir = os.getcwd()+os.sep + file_master_list[0] = str(argv[len_argv-1]) + else: + sys.exit('Please give a directory or a file path for the last argument...') + +# Asks tags if mode album +if mode_album and not mode_from_xml : + tag_tools.ask_write_tag() + tag_tools.write_def_tags(default_tag_xml) + + +# Main loop +# ========= + +for file in file_master_list : + if isaudio(master_dir+os.sep+file) or (mode_force and ext_is_audio(master_dir+os.sep+file)): + print '\n' + print '+------------------------------------------------------------------------------------' + print '| Processing '+master_dir+file + print '+------------------------------------------------------------------------------------' + + # Init + file_name = file + file_in = file + dir_in = src_dir + + # Backup mode + if mode_backup : + album_dir_tmp = tag_tools.get_tag_value('ALBUM') + album_dir = collection_dir+os.sep+'src'+os.sep+album_dir_tmp+os.sep + if not os.path.exists(album_dir) : + os.mkdir(album_dir) + if isaudio(master_dir+file) and ( not audio_tools.compare_md5_key(master_dir+file,album_dir+file) or mode_force ) : + print 'Copying files into: '+album_dir+'' + os.system('cp -ra "'+master_dir+file+'" '+album_dir) + print 'OK\n' + #else: + # sys.exit(master_dir+file+' is not an audio file...') + src_dir = album_dir + dir_in = src_dir + else : + dir_in = master_dir + + # Creating par2 key + par_key_value = tag_tools.get_opt_value('par_key') + if mode_par2 and par_key_value : + # Creating "par2" security keys + print 'Creating "par2" security keys...' + audio_tools.create_par_key(dir_in,file) + + # Name, extension + file_name_woext, file_ext = tag_tools.filename_split(file) + tag_tools.add_tag('ORIGINAL_FILENAME',file) + tag_tools.add_tag('ORIGINAL_TYPE',file_ext) + + # Get original XML + if mode_from_xml : + doc = xml.dom.minidom.parse(dir_in+file_name+'.xml') + tag_tools.get_def_tags(doc) + + # Album mode + if mode_album : + # Getting file main tags + title,artist,file_name_new = tag_tools.name2tag(dir_in,file_name_woext,file_ext) + tag_tools.add_tag('ARTIST',artist) + tag_tools.add_tag('TITLE',title) + print "Artist: "+artist + print "Title: "+title+'\n' + #tag_tools.write_def_tags(default_tag_xml) + + # Asks for new metadata and write default user tags/options + if not mode_default and not mode_from_xml and not mode_album: + tag_tools.ask_write_tag() + tag_tools.write_def_tags(default_tag_xml) + + + + # Clean mode + if mode_clean : + file_name = tag_tools.clean_filename(file_name) + # Renaming backup source file + tag_tools.rename_file(dir_in,dir_out,file,file_name) + + # Writing xml data + if not mode_from_xml : + print 'Writing xml data...' + tag_tools.write_def_tags(dir_in+file_name+'.xml') + + # Getting encoding types + enc_types = tag_tools.get_opt_value('enc_types') + enc_types = string.replace(enc_types,' ','').split(',') + + # Checking existing file + for enc_type in enc_types: + dir_out = master_dir+enc_type+os.sep + file_out = file_name_woext+'.'+enc_type + if not os.path.exists(dir_out+file_out): + new_track = True + else : + new_track = False + + # Decoding to a new 16 bits wav file if needed + if not iswav16(dir_in+file_in) and new_track: + print "Decoding to wav 16 bits..." + audio_tools.decode(dir_in+file_in,file_ext) + # Important ! + type_list = tag_tools.get_consts_value('type_list') + type_list = type_list.split(',') + if not file_ext in type_list : + file_in=file_in+'.wav' + + # Normalize file if needed + normalize_value = tag_tools.get_opt_value('normalize') + if normalize_value: + print 'Normalizing...' + audio_tools.normalize(dir_in+file_in) + + # Marking + audio_marking_value = tag_tools.get_opt_value('audio_marking') + auto_audio_marking = tag_tools.get_opt_value('auto_audio_marking') + audio_marking_file = tag_tools.get_opt_value('audio_marking_file') + audio_marking_timeline = tag_tools.get_opt_value('audio_marking_timeline') + audio_marking_timeline = string.replace(audio_marking_timeline,' ','').split(',') + if audio_marking_value and new_track: + if auto_audio_marking: + print 'Creating track audio mark...' + audio_marking.make_auto_mark(dir_in,file_in) + audio_marking_file = dir_in+file_in+'_mark.wav' + print 'Marking '+file_in+' with '+audio_marking_file+'...' + audio_marking.mark_audio(dir_in,file_in,audio_marking_file,audio_marking_timeline) + file_in = 'marked_'+file_in + + # Encoding loop + for enc_type in enc_types: + dir_out = collection_dir+os.sep+enc_type+os.sep + if not os.path.exists(dir_out): + os.mkdir(dir_out) + album = tag_tools.get_tag_value('ALBUM') + dir_out = collection_dir+os.sep+enc_type+os.sep+album+os.sep + if not os.path.exists(dir_out): + os.mkdir(dir_out) + file_out = file_name_woext+'.'+enc_type + + if not os.path.exists(dir_out+file_out) or mode_force : + print 'Converting '+dir_in+file_name+' to '+enc_type+'...' + # Encoding + print 'Encoding file...' + audio_tools.encode(enc_type,dir_in,file_in,dir_out,file_out) + print 'Writing tags to encoded file...' + tag_tools.write_tags(enc_type,dir_out,file_out) + + else : + print dir_out+file_out+' already exists !' + if mode_tags : + print 'But writing tags to encoded file...' + tag_tools.write_tags(enc_type,dir_out,file_out) + + # Remove tmp files + file_list = os.listdir(src_dir) + for file in file_list: + if 'marked_' in file or '.ewf' in file or '_mark.wav' in file or file_ext+'.wav' in file: + os.system('rm "'+dir_in+file+'"') + + else : + print file+" is not an audio file !" + +# Sync to the remote server +if mode_rsync : + net_backup_host = tag_tools.get_consts_value('net_backup_host') + net_backup_dir = tag_tools.get_consts_value('net_backup_dir') + print '+------------------------------------------------------------------------------------' + print '| Synchronizing with '+net_backup_host + print '+------------------------------------------------------------------------------------' + os.system('rsync -avzLp --delete --rsh="ssh -l '+os.environ["USER"]+'" '+collection_dir+' '+os.environ["USER"]+'@'+net_backup_host+':'+net_backup_dir) + print "Collection Synchronized !" + + +# End +# === diff --git a/typeToolBox.py b/typeToolBox.py new file mode 100644 index 0000000..a6f2cb2 --- /dev/null +++ b/typeToolBox.py @@ -0,0 +1,41 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Author: Ingelrest François (Athropos@gmail.com) +# +# 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 Library 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Supported types +# 'bool' type must be placed *before* 'int' type, otherwise booleans are detected as integers +types = {bool : 'bool', int : 'int', str : 'str'} + +# Return a String with the type of value +def getType(value) : + for type in types.keys() : + if isinstance(value, type) : + return types[type] + raise TypeError, str(value) + ' has an unsupported type' + +# Return value, casted into type +def cast(value, type) : + if type == 'bool' : + if value == 'True' : + return True + return False + elif type == 'int' : + return int(value) + elif type == 'str' : + return str(value) + raise TypeError, type + ' is an unsupported type' -- 2.39.5