X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=scripts%2Fml-search.py;h=24db982fafb1b4cf80ef45741e0ec1d5b76380f5;hb=d3a80ce733d72c46984631e5d8e7f690c5a71bf0;hp=e6cde27184ac6b593e44ba0b21f47f43cea1de47;hpb=6c8ac7767478984cb4f3210da73fa9f0c0a21b5f;p=m_librarian.git diff --git a/scripts/ml-search.py b/scripts/ml-search.py index e6cde27..24db982 100755 --- a/scripts/ml-search.py +++ b/scripts/ml-search.py @@ -2,10 +2,6 @@ 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 @@ -157,7 +153,8 @@ def _search_books(case_sensitive, search_type, args): 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')) + orderBy=('series', 'ser_no', 'title'), + use_filters=args.filters) if args.count: print_count(books.count()) return @@ -206,10 +203,7 @@ def _search_books(case_sensitive, search_type, args): if args.get or args.get_many: 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_to = get_config().getpath('download', 'path') download(book, download_to, args.path, args.format) count += 1 print_count(count) @@ -332,6 +326,8 @@ if __name__ == '__main__': parser.add_argument('--gid', type=int, help='search by genre\'s id') parser.add_argument('-l', '--lang', help='search by language') parser.add_argument('--lid', type=int, help='search by language\'s id') + parser.add_argument('--filters', action='store_true', + help='use filters from config') parser.add_argument('-P', '--path', help='path to the library archives') parser.add_argument('--download-to', nargs='?', const=None, default=os.path.curdir,