From 07cd391009058a1a12b8f4d8459108626e070afa Mon Sep 17 00:00:00 2001 From: Nicholas Piper Date: Sat, 10 Feb 2007 13:23:10 +0000 Subject: Cope with invalid/not available mp3 tags git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1392 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- bindings/python/ipod.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/bindings/python/ipod.py b/bindings/python/ipod.py index 1d02f69..3917e2c 100644 --- a/bindings/python/ipod.py +++ b/bindings/python/ipod.py @@ -315,23 +315,34 @@ class Track: ('getBPM','BPM'), ('getPlayCount','playcount'), ('getAlbum','album')): - value = getattr(tag,func)() - if value: - self[attrib] = value + try: + value = getattr(tag,func)() + if value: + self[attrib] = value + except AttributeError: + pass + if self['title'] is None: + self['title'] = filename try: self['genre'] = tag.getGenre().name except AttributeError: pass - disc, of = tag.getDiscNum() - if disc is not None: - self['cd_nr'] = disc - if of is not None: - self['cds'] = of - n, of = tag.getTrackNum() - if n is not None: - self['track_nr'] = n - if of is not None: - self['tracks'] = of + try: + disc, of = tag.getDiscNum() + if disc is not None: + self['cd_nr'] = disc + if of is not None: + self['cds'] = of + except AttributeError: + pass + try: + n, of = tag.getTrackNum() + if n is not None: + self['track_nr'] = n + if of is not None: + self['tracks'] = of + except AttributeError: + pass self['tracklen'] = audiofile.getPlayTime() * 1000 self.set_podcast(podcast) elif proxied_track: -- cgit