Hello!

I found a really cool python library called mutagen than can edit the metadata 
of almost any filetype! The best part is that it appends to the tags, you 
don't have to completely erase them to write new tags (this is much more 
useful than vorbiscomment).

I've re-written libtagupdate.py using mutagen and it seems to work quite well. 
As a consequence it removes the need for the vorbis-tools and eyeD3 
dependencies.

I also quickly implemented it in libipodsync.py to detect filelengths, the 
only filetype I've found so far that it can't detect is avi but that's not 
playable on the iPod anyway. I think it might also be possible to do cover 
art extraction with this tool so that would potentially eliminate the need 
for pymad and of-course, mplayer as well.

This seemed (at least to me) too good to be true and sadly it might be... The 
problem is that it's licensed under the GPLv2. I've spoken with the lead 
developer and he's not too fond of the GPLv3. Here's what he had to say:

<piman> You can use Mutagen in a program licensed under "GPLv2 or later", but 
then only under the terms of GPLv2. We don't have plans to switch to GPLv3.

Attached is the new libtagupdate.py and the patch for libipodsync, I hope you 
guys like it!

nick

P.S. mutagen is available as python-mutagen under debian, fedora and ubuntu.

Attachment: libtagupdate.py
Description: application/python

--- libipodsync.py	2007-09-23 01:06:30.000000000 -0400
+++ libipodsync.py	2007-09-23 00:48:31.000000000 -0400
@@ -58,8 +58,15 @@
     import eyeD3
     log( '(ipodsync) Found eyeD3')
 except:
-    log( '(ipodsync) Coulld not find eyeD3.')
+    log( '(ipodsync) Could not find eyeD3.')
 
+try:
+    import mutagen
+    log( '(ipodsync) Found mutagen')
+    use_mutagen = True
+except:
+    log( '(ipodsync) Could not find mutagen.')
+    use_mutagen = False
 
 # are we going to use python-id3 for cover art extraction?
 use_pyid3 = False
@@ -396,8 +403,16 @@
         # if we cannot get the track length, make an educated guess (default value)
         track_length = DEFAULT_LENGTH
         track_length_found = False
+        
+        if use_mutagen:
+            try:
+                log( 'Using mutagen to get file length', sender = self)
+                track_length = int(float(mutagen.File(local_filename).info.length) * 1000)
+                track_length_found = True
+            except:
+                log( 'Warning: cannot get length for %s using mutagen', episode.title, sender = self)
 
-        if use_mplayer:
+        if use_mplayer and not track_length_found:
             try:
                 log( 'Using mplayer to get file length', sender = self)
                 mplayer_output = os.popen( MPLAYER_COMMAND % local_filename).read()
@@ -405,8 +420,8 @@
                 track_length_found = True
             except:
                 log( 'Warning: cannot get length for %s', episode.title, sender = self)
-        else:
-            log( 'Please try installing the "mplayer" package for track length detection.', sender = self)
+#        else:
+#            log( 'Please try installing the "mplayer" package for track length detection.', sender = self)
 
         if not track_length_found:
             try:
_______________________________________________
gpodder-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/gpodder-devel

Reply via email to