diff --git a/AUTHORS b/AUTHORS index b0470bff..522983ec 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,7 +13,7 @@ Thanks to all the other patch writers: Stylianos Papanastasiou (patch for "downloaded move") Ortwin Forster (patch for saxutils.escape in localdb) Camille Moncelier (patch for iPod video device support) - Nick (many patches for iPod 5G support) + Nick (many patches for iPod 5G support + mplayer-length) Seth Remington (several important bugfixes) diff --git a/ChangeLog b/ChangeLog index baa88f05..4227d29a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu, 28 Dec 2006 14:39:06 +0100 + * src/gpodder/libipodsync.py: Add support for non-mp3 file + length detection using mplayer if available (thanks to + Nick for the patch) + * bin/gpodder: bumped version + release date + Wed, 20 Dec 2006 20:43:02 +0100 * src/gpodder/gpodder.py: Added modified patch from Seth Remington to add support for a "download new episodes from diff --git a/bin/gpodder b/bin/gpodder index 93cc71c7..584dfd25 100755 --- a/bin/gpodder +++ b/bin/gpodder @@ -26,8 +26,8 @@ # PLEASE DO NOT CHANGE FORMAT OF __version__ LINE (setup.py reads this) __author__ = "Thomas Perl " -__version__ = "0.8.0+svn20061220" -__date__ = "2006-12-20" +__version__ = "0.8.0+svn20061228" +__date__ = "2006-12-28" __copyright__ = "Copyright (c) 2005-2006 %s. All rights reserved." % __author__ __licence__ = "GPL" diff --git a/src/gpodder/libipodsync.py b/src/gpodder/libipodsync.py index f359cf19..09e31ca6 100644 --- a/src/gpodder/libipodsync.py +++ b/src/gpodder/libipodsync.py @@ -34,6 +34,12 @@ enable_ipod_functions = True MAD = 1 EYED3 = 2 +# default length (our "educated guess") is 60 minutes +DEFAULT_LENGTH = 60*60*1000 + +# command line for mplayer +MPLAYER_COMMAND = 'mplayer -msglevel all=-1 -identify -vo null -ao null -frames 0 "%s" 2>/dev/null' + # which detection mechanism are we going to use? use_mechanism = 0 @@ -88,6 +94,13 @@ def ipod_supported(): # file extensions that are handled as video video_extensions = [ "mov", "mp4", "m4v" ] +# is mplayer available for finding track length? +use_mplayer = False +if not os.system("which mplayer > /dev/null 2>&1"): + use_mplayer = True + log('(ipodsync) Found mplayer, using it to find track length of video files') +else: + log('(ipodsync) mplayer not found - length of video files will be guessed') class gPodderSyncMethod: def __init__( self, callback_progress = None, callback_status = None, callback_done = None): @@ -283,6 +296,9 @@ class gPodder_iPodSync( gPodderSyncMethod): return self.set_channel_art( track, local_filename) def add_episode_from_channel( self, channel, episode): + global DEFAULT_LENGTH + global MPLAYER_COMMAND + if not ipod_supported(): return False @@ -293,6 +309,10 @@ class gPodder_iPodSync( gPodderSyncMethod): log( '(ipodsync) Adding item: %s from %s', episode.title, channel.title) local_filename = str(channel.getPodcastFilename( episode.url)) + + # if we cannot get the track length, make an educated guess (default value) + track_length = DEFAULT_LENGTH + try: if use_mechanism == MAD: log( '(ipodsync) Using pymad to get file length') @@ -302,10 +322,17 @@ class gPodder_iPodSync( gPodderSyncMethod): log( '(ipodsync) Using eyeD3 to get file length') eyed3_info = eyeD3.Mp3AudioFile( local_filename) track_length = eyed3_info.getPlayTime() * 1000 - # TODO: how to get length of video (mov, mp4, m4v) files?? + # TODO: Find python module to get length of video (mov, mp4, m4v) files, instead of using mplayer. except: - print '(ipodsync) Warning: cannot get length for %s, will use 1 hour' % episode.title - track_length = 20*60*1000 # hmm.. (20m so we can skip on video/audio with unknown length) + if use_mplayer: + try: + log('(ipodsync) eyeD3 failed, using mplayer to get track length') + mplayer_output = os.popen( MPLAYER_COMMAND % local_filename).read() + track_length = int(float(mplayer_output[mplayer_output.index('ID_LENGTH'):].splitlines()[0][10:]) * 1000) + except: + log('(ipodsync) Warning: cannot get length for %s', episode.title) + else: + log('(ipodsync) Warning: cannot get length for %s; try installing mplayer', episode.title) track = gpod.itdb_track_new() @@ -339,7 +366,12 @@ class gPodder_iPodSync( gPodderSyncMethod): # dirty hack to get video working, seems to work for ext in video_extensions: if local_filename.lower().endswith( '.%s' % ext): - track.unk208 = 0x00000002 # documented on http://ipodlinux.org/ITunesDB + try: + # documented on http://ipodlinux.org/ITunesDB + track.mediatype = 0x00000002 + except: + # for old libgpod versions, "mediatype" is "unk208" + track.unk208 = 0x00000002 # if it's a music channel, also sync to master playlist if channel.is_music_channel: