diff --git a/ChangeLog b/ChangeLog index 37db8ea..89d08d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-04-13 Thomas Vander Stichele + + * morituri/image/image.py: + Also look for audio file basename relative to cue file. + 2009-04-13 Thomas Vander Stichele * examples/ARcue.py: diff --git a/morituri/image/image.py b/morituri/image/image.py index bdd36e8..fb3f3cd 100644 --- a/morituri/image/image.py +++ b/morituri/image/image.py @@ -52,15 +52,25 @@ class Image: # .cue FILE statements have Windows-style path separators, so convert tpath = os.path.join(*path.split('\\')) - # if the path is relative, make it absolute relative to the cue file - if tpath != os.path.abspath(tpath): - tpath = os.path.join(os.path.dirname(self._path), tpath) + candidatePaths = [] - noext, _ = os.path.splitext(tpath) - for ext in ['wav', 'flac']: - cpath = '%s.%s' % (noext, ext) - if os.path.exists(cpath): - return cpath + # if the path is relative: + # - check relatively to the cue file + # - check only the filename part relative to the cue file + if tpath == os.path.abspath(tpath): + candidatePaths.append(tPath) + else: + candidatePaths.append(os.path.join( + os.path.dirname(self._path), tpath)) + candidatePaths.append(os.path.join( + os.path.dirname(self._path), os.path.basename(tpath))) + + for candidate in candidatePaths: + noext, _ = os.path.splitext(candidate) + for ext in ['wav', 'flac']: + cpath = '%s.%s' % (noext, ext) + if os.path.exists(cpath): + return cpath raise KeyError, "Cannot find file for %s" % path