From 3e657b09c0042b026b4541f2fd0bdd826dfbdf38 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 16 Aug 2012 16:31:58 +0200 Subject: [PATCH] movie.py: correctly handle subdirectories --- ox/movie.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ox/movie.py b/ox/movie.py index f4c1b72..fe50325 100644 --- a/ox/movie.py +++ b/ox/movie.py @@ -25,11 +25,10 @@ def format_path(data, has_director_directory=True): director = data['seriesDirectorSort' if data['isEpisode'] else 'directorSort'] or ['Unknown Director'] title = data['seriesTitle' if data['isEpisode'] else 'title'] or 'Untitled' year = data['seriesYear' if data['isEpisode'] else 'year'] - return '/'.join(map(format_underscores, filter(lambda x: x != None, [ + parts = map(format_underscores, filter(lambda x: x != None, [ data['directory'] or director[0][0] if has_director_directory else title[0], '; '.join(director) if has_director_directory else None, '%s%s' % (title, ' (%s)' % year if year else ''), - data['subdirectory'], '%s%s%s%s%s%s' % ( data['title'] or 'Untitled', '.%s' % data['version'] if data['version'] else '', @@ -38,7 +37,10 @@ def format_path(data, has_director_directory=True): '.%s' % data['language'].replace('/', '.') if not data['language'] in [None, 'en'] else '', '.%s' % data['extension'] if data['extension'] else '' ) - ]))) + ])) + if data['subdirectory']: + parts.insert(-1, data['subdirectory']) + return '/'.join(parts) def parse_path(path): ''' @@ -87,7 +89,7 @@ def parse_path(path): parts = map(parse_underscores, path.split('/')) # subdirectory if len(parts) > 4: - data['subdirectory'] = parts[3:-1] + data['subdirectory'] = '/'.join(parts[3:-1]) parts = parts[:3] + parts[-1:] else: data['subdirectory'] = None