summaryrefslogtreecommitdiff
path: root/movietool/__init__.py
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-01-01 17:24:37 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-01-01 17:24:37 +0100
commit69a121948f67b88694ded3e94cf6f7ca2409e510 (patch)
treed93e017efa53331a8bd5f72ab84b719d0df12057 /movietool/__init__.py
parent8ac2b057fd60ed7905bee62c8be7f4f38297f109 (diff)
downloadmovietool-69a121948f67b88694ded3e94cf6f7ca2409e510.tar.gz
movietool-69a121948f67b88694ded3e94cf6f7ca2409e510.zip
use also original title in filename
Diffstat (limited to 'movietool/__init__.py')
-rwxr-xr-xmovietool/__init__.py18
1 files changed, 15 insertions, 3 deletions
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):