filenames

This commit is contained in:
j 2012-01-31 05:58:58 +05:30
parent ca7bfd06d5
commit a7613f92ef

View file

@ -38,8 +38,10 @@ def parse_movie_path(path):
#title/year #title/year
if len(parts) == 4: if len(parts) == 4:
title = parts[2] title = parts[2]
else: elif len(parts) > 1:
title = parts[1] title = parts[1]
else:
title = parts[0]
title = title.replace('_ ', ': ') title = title.replace('_ ', ': ')
year = findRe(title, '(\(\d{4}\))') year = findRe(title, '(\(\d{4}\))')
@ -64,9 +66,9 @@ def parse_movie_path(path):
#extension/language #extension/language
fileparts = [x.replace('||', '. ') for x in parts[-1].replace('. ', '||').split('.')] 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] language = fileparts[-2]
else: else:
language = '' language = ''
@ -152,6 +154,7 @@ def create_movie_path(title, director, year,
filename += ['Part %s' % part] filename += ['Part %s' % part]
if partTitle: if partTitle:
filename += [partTitle] filename += [partTitle]
if extension:
filename += [extension] filename += [extension]
filename = '.'.join(filename) filename = '.'.join(filename)
path = os.path.join(director[0], director, '%s (%s)' % (title, year), filename) path = os.path.join(director[0], director, '%s (%s)' % (title, year), filename)