- for book in search_books(search_type, case_sensitive, values,
- join_expressions,
- orderBy=('series', 'ser_no', 'title')):
- print book.title.encode(default_encoding)
- if args.details >= 1:
- print " ", _("Author(s)"), ":",
+ lvalues = {}
+ if args.lang:
+ lvalues['name'] = args.lang
+ if args.lid:
+ lvalues['id'] = args.lid
+ if lvalues:
+ join_expressions.append(Book.j.language)
+ conditions = mk_search_conditions(
+ Language, search_type, case_sensitive, lvalues)
+ join_expressions.extend(conditions)
+ books = search_books(search_type, case_sensitive, values, join_expressions,
+ orderBy=('series', 'ser_no', 'title'))
+ if args.count:
+ print_count(books.count())
+ return
+ if args.get_many:
+ books = books[:args.get_many]
+ elif args.get:
+ count = books.count()
+ if count != 1:
+ sys.stderr.write("There must be exactly 1 book for --get; "
+ "(found %d).\n" % count)
+ sys.stderr.write("Use --get-many N to download more than one "
+ "book.\n")
+ sys.exit(1)
+ count = 0
+ for book in books:
+ print book.title.encode(default_encoding),
+ if args.verbose >= 1:
+ print "(id=%d)" % book.id,
+ print
+ if args.verbose >= 1:
+ print " ", _("Author(s)").encode(default_encoding), ":",