From: Simeon Veldstra Date: Mon, 5 Feb 2007 01:01:02 +0000 (-0800) Subject: Merge with bugfix-0.5 X-Git-Tag: v0.5.10 X-Git-Url: http://puddle.ca/cgi-bin/gitweb.cgi?p=mp3togo;a=commitdiff;h=31d2f7b566446d162c43366800042d14ac0fac39 Merge with bugfix-0.5 --- --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mp3togo (0.5.9) unstable; urgency=low + + * Added -u update switch for conditional --force. Thanks Mark J. Hewitt. + + -- Simeon Veldstra Sun, 4 Feb 2007 16:38:54 -0800 + mp3togo (0.5.8) unstable; urgency=low * Fixed failure when converting flac with no GENRE tag --- a/debian/mp3togo.1 +++ b/debian/mp3togo.1 @@ -134,4 +134,4 @@ License can be found in /usr/share/commo .PP mp3togo can be found online at http://puddle.ca/mp3togo -.\" created by instant / docbook-to-man, Sun 05 Nov 2006, 16:36 +.\" created by instant / docbook-to-man, Sun 04 Feb 2007, 16:42 --- a/mp3togo/conf.py +++ b/mp3togo/conf.py @@ -101,6 +101,8 @@ class Options(options.Options): ('maxtempsize', '', '', 0L, None, ''), ('force', 'F', 'force', False, None, '''Overwrite files if they already exist.'''), + ('update', 'u', 'update', False, None, + '''Overwrite files if they already exist only if they are older than the source file.'''), ('encoder', 'C', 'encoder', 'lame', None, '''The encoder to use to create the output files. Options are wav, lame or oggenc.'''), ('encopts', 'E', 'encoder-options', '', None, --- a/mp3togo/tags.py +++ b/mp3togo/tags.py @@ -101,7 +101,10 @@ class Tags(UserDict.DictMixin): self._tags['ARTIST'] = [eye.getArtist() or ''] self._tags['ALBUM'] = [eye.getAlbum() or ''] self._tags['TITLE'] = [eye.getTitle() or ''] - self._tags['GENRE'] = [getattr(eye.getGenre(), 'name', 'Other')] + try: + self._tags['GENRE'] = [getattr(eye.getGenre(), 'name', 'Other')] + except eyeD3.tag.GenreException: + self._tags['GENRE'] = 'Other' del eye elif HAVE_ID3: info = ID3.ID3(self._file, as_tuple=1).as_dict() --- a/mp3togo/track.py +++ b/mp3togo/track.py @@ -255,16 +255,42 @@ class Track: tasks.append(job) del job - # Consider the track done if the output file exists: - if os.path.exists(self._outname) and not opts['force']: - opts.log(1, "Skipping existing file: %s\n" % self._outname) - self._queue = tuple(tasks) - if self._hash and self._cache: - self._cache.release(self._hash) - for tsk in self._queue: - tsk._status = task.DONE - self._state = DONE - return + ## Consider the track done if the output file exists: + #if os.path.exists(self._outname) and not opts['force']: + # opts.log(1, "Skipping existing file: %s\n" % self._outname) + # self._queue = tuple(tasks) + # if self._hash and self._cache: + # self._cache.release(self._hash) + # for tsk in self._queue: + # tsk._status = task.DONE + # self._state = DONE + # return + if not opts['force']: + if os.path.exists(self._outname): + # In update mode, consider the track done if an existing file is older than the source + if opts['update']: + sourceinfo = os.stat(self._filename) + targetinfo = os.stat(self._outname) + if targetinfo.st_mtime >= sourceinfo.st_mtime: + opts.log(1, "Skipping up to date file: %s\n" % self._outname) + self._queue = tuple(tasks) + if self._hash and self._cache: + self._cache.release(self._hash) + for tsk in self._queue: + tsk._status = task.DONE + self._state = DONE + return + else: + opts.log(1, "Replacing out of date file: %s\n" % self._outname) + else: # Consider the track done if the output file exists: + opts.log(1, "Skipping existing file: %s\n" % self._outname) + self._queue = tuple(tasks) + if self._hash and self._cache: + self._cache.release(self._hash) + for tsk in self._queue: + tsk._status = task.DONE + self._state = DONE + return # Ready to go self._queue = tuple(tasks) @@ -288,4 +314,3 @@ class Track: child._parent = None self._queue = () -