X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=scripts%2Fml-search.py;h=e6cde27184ac6b593e44ba0b21f47f43cea1de47;hb=6c8ac7767478984cb4f3210da73fa9f0c0a21b5f;hp=fe8dc48be67140af19d63108f9b96474be8fcb74;hpb=281320701796a6fd5984f3ef66ee450ea2e7c4b3;p=m_librarian.git diff --git a/scripts/ml-search.py b/scripts/ml-search.py index fe8dc48..e6cde27 100755 --- a/scripts/ml-search.py +++ b/scripts/ml-search.py @@ -2,6 +2,11 @@ from __future__ import print_function import argparse +try: + from configparser import NoSectionError, NoOptionError +except ImportError: # Python 2 + from ConfigParser import NoSectionError, NoOptionError +import os import sys from sqlobject.sqlbuilder import CONCAT @@ -199,7 +204,13 @@ def _search_books(case_sensitive, search_type, args): print(" ", encode(_("Deleted")), ":", encode(_(str(book.deleted)))) if args.get or args.get_many: - download(book, args.path, args.format) + download_to = args.download_to + if download_to is None: + try: + download_to = get_config().get('download', 'path') + except (NoSectionError, NoOptionError): + download_to = os.path.curdir + download(book, download_to, args.path, args.format) count += 1 print_count(count) @@ -322,6 +333,9 @@ if __name__ == '__main__': parser.add_argument('-l', '--lang', help='search by language') parser.add_argument('--lid', type=int, help='search by language\'s id') parser.add_argument('-P', '--path', help='path to the library archives') + parser.add_argument('--download-to', nargs='?', + const=None, default=os.path.curdir, + help='download directory') parser.add_argument('-F', '--format', help='download format, default is %%f') parser.add_argument('--get', action='store_true',