Fix download command
Also implement proper usage on error or -h
This commit is contained in:
parent
b77ae6c9a8
commit
4b67699a39
1 changed files with 21 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/usr/local/bin/python
|
||||
#!/usr/local/bin/python
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
# Download shows from the Tivo
|
||||
|
@ -538,9 +538,14 @@ def mirror(toc, downloaddb, one=False):
|
|||
|
||||
def download_episode(toc, downloaddb, episode):
|
||||
items = toc.getItems()
|
||||
options = {}
|
||||
for item in items:
|
||||
if item.title == episode or item.name == episode or item.episode == episode:
|
||||
download_one(item, downloaddb)
|
||||
for i in (item.title, item.episode, item.name):
|
||||
if IncludeShow.includes.has_key(i):
|
||||
options = IncludeShow.includes[i]
|
||||
download_one(item, downloaddb, options)
|
||||
return
|
||||
|
||||
|
||||
def printtoc(toc, downloaddb):
|
||||
|
@ -561,6 +566,12 @@ def printtoc(toc, downloaddb):
|
|||
print "*** {} shows listed".format(len(items))
|
||||
|
||||
|
||||
def usage():
|
||||
print >>sys.stderr, 'usage: tivomirror -dvuT [-c config] cmd'
|
||||
print >>sys.stderr, ' cmd is one of download, list, mirror, mirrorone'
|
||||
sys.exit(64)
|
||||
|
||||
|
||||
def main():
|
||||
global config, logger
|
||||
curdir = os.getcwd()
|
||||
|
@ -576,8 +587,8 @@ def main():
|
|||
conffile = None
|
||||
|
||||
try:
|
||||
options, remainder = getopt.getopt(sys.argv[1:], 'c:dvuT',
|
||||
['config', 'ignoreepisodetitle', 'debug', 'verbose', 'update'])
|
||||
options, remainder = getopt.getopt(sys.argv[1:], 'c:dhvuT?',
|
||||
['config', 'ignoreepisodetitle', 'debug', 'verbose', 'update', help])
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-c', '--config'):
|
||||
|
@ -591,6 +602,8 @@ def main():
|
|||
updateToc = True
|
||||
if opt in ('-T', '--ignoreepisodetitle'):
|
||||
config.ignoreepisodetitle = True
|
||||
if opt in ('-h', '-?', '--help'):
|
||||
usage()
|
||||
|
||||
config = Config(conffile)
|
||||
|
||||
|
@ -614,9 +627,12 @@ def main():
|
|||
else:
|
||||
logger.error("invalid command {}".format(cmd))
|
||||
print >>sys.stderr, "invalid command {}".format(cmd)
|
||||
sys.exit(64)
|
||||
usage()
|
||||
|
||||
downloaddb.close()
|
||||
except getopt.GetoptError as e:
|
||||
print >>sys.stderr, 'Error parsing options: {}'.format(e)
|
||||
usage()
|
||||
except Exception:
|
||||
logger.exception("")
|
||||
logger.info("*** Completed")
|
||||
|
|
Loading…
Reference in a new issue