Hello, Götz and Nick!

On Thu, 2007-08-09 at 07:02 -0400, nikosapi wrote:
> On August 9, 2007 02:42:31 Götz Waschk wrote:
> > On 8/9/07, nikosapi <[EMAIL PROTECTED]> wrote:
> > > I fully agree, the podcaster should get his act together. I tested the
> > > file with the mp3val tool and it did find errors, here's a bit of the
> > > output: WARNING: (offset 0x6dbda): MPEG stream error, resynchronized
> > > successfully WARNING: Wrong number of MPEG data bytes specified in Xing
> > > header (17958326 instead of 17958144)
> >
> > this is an error that mp3val should be able to fix with the -f option.
> 
> I should have said that yes, I tried fixing it with mp3val -f but sadly it 
> didn't fix the reported file length issue :(

I would have proposed to add "mp3val -f" support in gPodder, but as this
would (a) add unnecessary complexity and (b) not fix our initial issue
of track length, I will leave the problem to the podcast authors. After
all, _they_ should fix their files (and sometimes even feeds ;).

I'd add some kind of graphical notification, but it seems like gPodder
can't detect if there is an error or not, so I'll completely ignore the
patch we're been developing and revert to current svn trunk head.

The patch which I will NOT apply to gPodder is attached here in case
anyone wants to do further work on it.

Thomas

Index: src/gpodder/util.py
===================================================================
--- src/gpodder/util.py	(revision 363)
+++ src/gpodder/util.py	(working copy)
@@ -195,3 +195,15 @@
     return stripstr
 
 
+def file_has_extension( filename, ext):
+    """
+    Checks if the supplied file name has the corresponding
+    file name extension, ignoring case. Returns True if the 
+    file's extension is the same as the supplied extension,
+    False otherwise.
+    """
+    (filename, extension) = os.path.splitext( filename)
+    
+    return extension.lower() == ext.lower()
+
+
Index: src/gpodder/libipodsync.py
===================================================================
--- src/gpodder/libipodsync.py	(revision 363)
+++ src/gpodder/libipodsync.py	(working copy)
@@ -31,8 +31,8 @@
 enable_ipod_functions = True
 
 # possible mp3 length detection mechanisms
-MAD = 1
-EYED3 = 2
+use_mad = False
+use_eyed3 = False
 
 # default length (our "educated guess") is 60 minutes
 DEFAULT_LENGTH = 60*60*1000
@@ -54,12 +54,14 @@
 try:
     import mad
     log( '(ipodsync) Found pymad')
+    use_mad = True
 except:
     log( '(ipodsync) Could not find pymad.')
 
 try:
     import eyeD3
     log( '(ipodsync) Found eyeD3')
+    use_eyed3 = True
 except:
     log( '(ipodsync) Coulld not find eyeD3.')
 
@@ -397,8 +399,7 @@
                 log('(ipodsync) Error while converting file %s', original_filename)
                 return False
 
-        # if we cannot get the track length, make an educated guess (default value)
-        track_length = DEFAULT_LENGTH
+        track_length = 0
         track_length_found = False
 
         if use_mplayer:
@@ -412,16 +413,17 @@
         else:
             log( 'Please try installing the "mplayer" package for track length detection.', sender = self)
 
-        if not track_length_found:
+        if use_mad and util.file_has_extension( local_filename, 'mp3'):
             try:
                 log( 'Using pymad to get file length', sender = self)
                 mad_info = mad.MadFile( local_filename)
-                track_length = mad_info.total_time()
+                # go for the longest reported time
+                track_length = max( track_length, mad_info.total_time())
                 track_length_found = True
             except:
                 log( 'Warning: cannot get length for %s', episode.title, sender = self)
-        
-        if not track_length_found:
+
+        if use_eyed3 and not track_length_found and util.file_has_extension( local_filename, 'mp3'):
             try:
                 log( 'Using eyeD3 to get file length', sender = self)
                 eyed3_info = eyeD3.Mp3AudioFile( local_filename)
@@ -431,6 +433,7 @@
                 log( 'Warning: cannot get length for %s', episode.title, sender = self)
 
         if not track_length_found:
+            track_length = DEFAULT_LENGTH
             log( 'I was not able to find a correct track length, defaulting to %d', track_length, sender = self)
         
         track = gpod.itdb_track_new()
_______________________________________________
gpodder-devel mailing list
gpodder-devel@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/gpodder-devel

Reply via email to