-
Notifications
You must be signed in to change notification settings - Fork 0
/
unrar_and_move
executable file
·69 lines (51 loc) · 2.29 KB
/
unrar_and_move
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
import sys
import argparse
from um import UandM
class SmartHelpFormatter(argparse.HelpFormatter):
def _split_lines(self, text, width):
# this is the RawTextHelpFormatter._split_lines
if text.startswith('R|'):
return text[2:].splitlines()
return argparse.HelpFormatter._split_lines(self, text, width)
def main():
um = UandM(config_path='./uandm.conf')
p = argparse.ArgumentParser(
description=u"Extract and copy torrents",
)
p.add_argument("-v", "--verbose", help="increase output verbosity",
action="store_true")
p.add_argument("-f", "--force", help="force extract and copy actions",
action="store_true")
sp = p.add_subparsers()
p_ex = sp.add_parser("ex", help=u"extract rar files only",
formatter_class=SmartHelpFormatter)
p_ex.add_argument("-f", "--force", help=u"force extract on all files, ignore any excluded files",
action="store_true")
p_ex.set_defaults(func=um.extract_and_copy)
p_mv = sp.add_parser("mv", help=u"copy extracted files only",
formatter_class=SmartHelpFormatter)
p_mv.set_defaults(func=um.move)
p_rm = sp.add_parser("rm", help=u"remove torrents files only",
formatter_class=SmartHelpFormatter)
p_rm.add_argument("t", help=u"remove torrents")
p_rm.add_argument("v", help=u"remove videos")
p_rm.add_argument("-a", "--age", nargs="?",
metavar='2d', default="2w", const="1y",
help=u"R|Age of files to remove.\n\n"
"NOTE: When removing files, if --age/-a\n"
"is not provided, files of the specified type older\n"
"than 1 year will be removed\n\n"
"If a value is not passed, files older than \n"
"2 weeks will be removed\n\n"
"Age can be represented in multiple ways:\n\n"
"Days (eg. 2d)\n"
"Weeks (eg. 6w)\n"
"Months (eg. 3m)\n"
"Years (eg. 1y)\n\n")
p_rm.set_defaults(func=um.remove)
args = p.parse_args()
args.func(args)
#excludes = um.get_excludes()
if __name__ == "__main__":
sys.exit(main())