From 69a121948f67b88694ded3e94cf6f7ca2409e510 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Fri, 1 Jan 2016 17:24:37 +0100 Subject: use also original title in filename --- movietool/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'movietool') diff --git a/movietool/__init__.py b/movietool/__init__.py index 6084c70..f90d8e3 100755 --- a/movietool/__init__.py +++ b/movietool/__init__.py @@ -448,7 +448,17 @@ def do_rename(args): def substitute_filename(filename): """remove potentially harmful characters from filename""" return re.sub(u"[^a-zA-Z0-9()\- _#]", u"_", filename) - + + def make_filename(result): + main_title = result["alternative_title"] + orig_title = result["original_title"] + + filename = "{main_title} ({result[year]})".format(**locals()) + if main_title != orig_title: + filename += " #{orig_title}".format(**locals()) + filename += " #{result[imdb_id]}".format(**locals()) + return filename + for input_file in args.file: countrycode = locale.getdefaultlocale()[0][3:5] db = Protector(TMDBCache()) @@ -464,7 +474,9 @@ def do_rename(args): for (i, result) in zip(range(len(results)), results): result["i"] = i+1 result["year"] = result["release_date"].split("-")[0] - print("{i} {title} ({year}) - check: http://www.imdb.com/title/{imdb_id}".format(**result)) + print("{i} {title} ({year})" + " (orig.: {original_title}) - check: " + "http://www.imdb.com/title/{imdb_id}".format(**result)) result["alternative_title"] = db.alternative_title(result["imdb_id"], locale=countrycode) if result["alternative_title"] != result["title"]: print(" a.k.a.: {}".format(result["alternative_title"])) @@ -482,7 +494,7 @@ def do_rename(args): print("Skip {}".format(input_file)) continue - filename = "{alternative_title} ({year}) #{imdb_id}".format(**results[select-1]) + filename = make_filename(results[select-1]) filename = substitute_filename(filename) if os.path.exists(input_file): -- cgit v1.2.1