summaryrefslogtreecommitdiff
path: root/bin/movietool
diff options
context:
space:
mode:
Diffstat (limited to 'bin/movietool')
-rwxr-xr-xbin/movietool79
1 files changed, 79 insertions, 0 deletions
diff --git a/bin/movietool b/bin/movietool
new file mode 100755
index 0000000..ce16861
--- /dev/null
+++ b/bin/movietool
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+# coding: utf-8
+# python3 works as well
+from movietool import *
+
+if __name__ == "__main__":
+ tmdb.API_KEY = read_key()
+
+ parser = argparse.ArgumentParser(add_help=False)
+ parser.add_argument("--help", action=HelpAction, help="Display full help")
+ parser.add_argument("--log-level", action='store', type=int,
+ help="Set log level (CRITICAL=50," +
+ "ERROR=40,WARNING=30,INFO=20,DEBUG=10,NOTSET=0")
+ parser.add_argument("-h", action=argparse._HelpAction,
+ help="Display short help")
+
+ subparsers = parser.add_subparsers()
+ parser_aka = subparsers.add_parser("aka", add_help=False,
+ help="Print alternative titles")
+ parser_aka.add_argument("--lang", help="Language code (default 'DE')")
+ parser_aka.set_defaults(func=do_aka)
+ parser_aka.add_argument("files", action="append", nargs="+",
+ help="Files containing distinct movie-ids")
+
+ parser_data = subparsers.add_parser("data", add_help=False,
+ help="Print all available data")
+ parser_data.set_defaults(func=do_data)
+ parser_data.add_argument("files", action="append", nargs="+",
+ help="Files containing distinct movie-ids")
+
+ parser_year = subparsers.add_parser("year", add_help=False,
+ help="Print only the release year")
+ parser_year.set_defaults(func=do_year)
+ parser_year.add_argument("files", action="append", nargs="+",
+ help="Files containing distinct movie-ids")
+
+ parser_prune = subparsers.add_parser("prune", add_help=False,
+ help="Delete cache entries")
+ parser_prune.set_defaults(func=do_prune)
+ parser_prune.add_argument("files", action="append", nargs="+",
+ help="Files containing distinct movie-ids")
+
+ parser_rating = subparsers.add_parser("rating", add_help=False,
+ help="Print movie ratings")
+ parser_rating.set_defaults(func=do_rating)
+ parser_rating.add_argument("files", action="append", nargs="+",
+ help="Files containing distinct movie-ids")
+
+ parser_index = subparsers.add_parser("index", add_help=False,
+ help="Generate index.html file")
+ parser_index.set_defaults(func=do_index)
+ parser_index.add_argument("files", action="append", nargs="+",
+ help="Files containing distinct movie-ids")
+
+ parser_rename = subparsers.add_parser("rename", add_help=False,
+ help="Search supported rename")
+ parser_rename.set_defaults(func=do_rename)
+ parser_rename.add_argument("file", metavar="PATH", nargs="*",
+ help="File or folder to rename into tagged-imdb format")
+
+ parser_test = subparsers.add_parser("test", add_help=False,
+ help="Run testsuite")
+ parser_test.set_defaults(func=do_test)
+
+ args = parser.parse_args(sys.argv[1:])
+ if "log_level" in args:
+ logging.basicConfig(level=args.log_level)
+
+ if "files" in args:
+ ids = args.files[0]
+ ids = map(lambda filename:
+ (lambda x: (filename, x.groups()[0]) if x else None)
+ (re.match(".*#(tt[0-9]{7}).*", filename)),
+ ids)
+ args.func(args, list(filter(lambda i: i is not None, ids)))
+ elif "func" in args:
+ args.func(args)
+ else:
+ HelpAction("")(parser, None, None)