diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2016-01-02 00:08:07 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2016-01-02 00:19:52 +0100 |
commit | a27092c056c34f57933ad381908e4336f885ab33 (patch) | |
tree | eeb5434c2de8ec6ec5ef9b110a8a2fd3acf6c0a5 /bin/movietool | |
parent | 69a121948f67b88694ded3e94cf6f7ca2409e510 (diff) | |
download | movietool-master.tar.gz movietool-master.zip |
Diffstat (limited to 'bin/movietool')
-rwxr-xr-x | bin/movietool | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/bin/movietool b/bin/movietool index ce16861..00dff64 100755 --- a/bin/movietool +++ b/bin/movietool @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # coding: utf-8 # python3 works as well +import os from movietool import * if __name__ == "__main__": @@ -19,38 +20,39 @@ if __name__ == "__main__": 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="+", + parser_aka.add_argument("paths", 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="+", + parser_data.add_argument("paths", 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="+", + parser_year.add_argument("paths", 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="+", + parser_prune.add_argument("paths", 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="+", + parser_rating.add_argument("paths", 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_index.add_argument("paths", action="append", nargs="+", + help="Directories that are named with movie-ids, or " + "contain other directories named with movie-ids") parser_rename = subparsers.add_parser("rename", add_help=False, help="Search supported rename") @@ -66,12 +68,18 @@ if __name__ == "__main__": if "log_level" in args: logging.basicConfig(level=args.log_level) - if "files" in args: - ids = args.files[0] + if "paths" in args: + files = [] + for path in args.paths[0]: + if re.match('.*#(tt[0-9]{7}).*', path): + files += [os.path.basename(os.path.normpath(path))] + else: + files += os.listdir(path) + ids = map(lambda filename: (lambda x: (filename, x.groups()[0]) if x else None) (re.match(".*#(tt[0-9]{7}).*", filename)), - ids) + files) args.func(args, list(filter(lambda i: i is not None, ids))) elif "func" in args: args.func(args) |