From a7613f92ef41984c7fb38c6bf0e5ec048809d8c0 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 31 Jan 2012 05:58:58 +0530 Subject: [PATCH] filenames --- ox/movie.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ox/movie.py b/ox/movie.py index ecf56e0..e70620a 100644 --- a/ox/movie.py +++ b/ox/movie.py @@ -38,8 +38,10 @@ def parse_movie_path(path): #title/year if len(parts) == 4: title = parts[2] - else: + elif len(parts) > 1: title = parts[1] + else: + title = parts[0] title = title.replace('_ ', ': ') year = findRe(title, '(\(\d{4}\))') @@ -64,9 +66,9 @@ def parse_movie_path(path): #extension/language fileparts = [x.replace('||', '. ') for x in parts[-1].replace('. ', '||').split('.')] - extension = fileparts[-1] + extension = len(fileparts) > 1 and fileparts[-1] or '' - if len(fileparts[-2]) == 2: + if len(fileparts) > 1 and len(fileparts[-2]) == 2: language = fileparts[-2] else: language = '' @@ -152,7 +154,8 @@ def create_movie_path(title, director, year, filename += ['Part %s' % part] if partTitle: filename += [partTitle] - filename += [extension] + if extension: + filename += [extension] filename = '.'.join(filename) path = os.path.join(director[0], director, '%s (%s)' % (title, year), filename) return path