add support for pymad, will be used in favor of eyeD3; fallback to eyeD3 still possible if pymad not found

git-svn-id: svn://svn.berlios.de/gpodder/trunk@182 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
Thomas Perl 2006-11-22 16:05:15 +00:00
parent e335823874
commit 02eebaf960
4 changed files with 55 additions and 11 deletions

View File

@ -1,3 +1,12 @@
Wed, 22 Nov 2006 17:02:23 +0100 <thp@perli.net>
* src/gpodder/libipodsync.py: Add support for pymad, because
it gives more correct track length of MP3 files for me;
if pymad is not installed, gPodder will fallback to eyeD3;
if you only installed eyeD3 for gPodder, you can remove it
now and install pymad instead
* README: Note pymad dependency (and now-optional eyeD3)
* doc/dev/ipod-sync.txt: State that pymad is now preferred
Wed, 22 Nov 2006 16:13:33 +0100 <thp@perli.net>
* src/gpodder/libpodcasts.py: Small bugfix for description in
podcast item (80 instead of 20 chars is what we want ;)

4
README
View File

@ -66,7 +66,9 @@
If you want to have iPod synchronization support, you will also
have to install the following OPTIONAL packages:
* python-eyed3 (eyeD3 Python bindings)
* One of the following metadata libraries:
* python-pymad (preferred; MAD MP3 decoder Python bindings)
* python-eyed3 (alternative to pymad; eyeD3 Python bindings)
* python-gpod (libgpod's Python bindings)
Other users: Please install the above packages somehow ;)

View File

@ -7,10 +7,11 @@ This file sums up the current status of iPod sync support.
Added libipodsync.py that depends on two new libraries: eyeD3 and gpod.
gPodder_iPodSync support should be OPTIONAL, and gPodder should work without
gpod and eyeD3 installed (but disable iPod sync - related functions).
gpod and pymad (or eyed3) installed (but disable iPod sync - related functions).
-- Thomas Perl <thp@perli.net>, Thu, 06 Apr 2006 15:54:22 +0200
Update: Wed, 22 Nov 2006 17:01:23 +0100 (pymad is now preferred)
@ -33,13 +34,23 @@ gpod and eyeD3 installed (but disable iPod sync - related functions).
package.
*** eyeD3 + python bindings ***
*** pymad ***
-> pymad is now preferred over eyed3, because it detects the mp3 length
better than eyed3 (at least for me).
Install it using:
apt-get install python-pymad
If you don't have pymad available or if you somehow can't use it, you can
still install eyeD3 - it will be used if gpodder doesn't find pymad.
*** eyeD3 + python bindings (ONLY IF PYMAD IS NOT AVAILABLE) ***
This is rather simple to install:
apt-get install python-eyed3
This dependency is only added because we need to get the track length in
milliseconds of a mp3 file when syncing to iPod.

View File

@ -30,11 +30,29 @@
# variable tells if ipod functions are to be enabled
enable_ipod_functions = True
# possible mp3 length detection mechanisms
MAD = 1
EYED3 = 2
# which detection mechanism are we going to use?
use_mechanism = 0
from liblogger import log
try:
import gpod
import eyeD3
try:
# prefer pymad
import mad
use_mechanism = MAD
log( '(ipodsync) Found pymad')
except:
# fallback to eyeD3
import eyeD3
use_mechanism = EYED3
log( '(ipodsync) Found eyeD3')
except:
log( '(ipodsync) gpod and/or (mad|eyeD3) not found')
enable_ipod_functions = False
import os
@ -42,8 +60,6 @@ import sys
import time
import email.Utils
from liblogger import log
import liblocaldb
import libpodcasts
@ -212,8 +228,14 @@ class gPodder_iPodSync(object):
log( '(ipodsync) Adding item: %s from %s', episode.title, channel.title)
local_filename = str(channel.getPodcastFilename( episode.url))
try:
eyed3_info = eyeD3.Mp3AudioFile( local_filename)
track_length = eyed3_info.getPlayTime() * 1000 # in milliseconds
if use_mechanism == MAD:
log( '(ipodsync) Using pymad to get file length')
mad_info = mad.MadFile( local_filename)
track_length = mad_info.total_time()
elif use_mechanism == EYED3:
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??
except:
print '(ipodsync) Warning: cannot get length for %s, will use 1 hour' % episode.title