]> git.phdru.name Git - m_librarian.git/blobdiff - scripts/ml-search.py
Docs: Update TODO
[m_librarian.git] / scripts / ml-search.py
index 5ee84ccd1e19c6b390c6a1cede087d3cfc3f4635..7e6c9da3b793c02df82ea5d8570635258427a31a 100755 (executable)
@@ -4,6 +4,7 @@ from __future__ import print_function
 import argparse
 import os
 import sys
+
 from sqlobject.sqlbuilder import CONCAT
 
 from m_lib.defenc import default_encoding
@@ -153,7 +154,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', '-date'),
+                         use_filters=args.filters)
     if args.count:
         print_count(books.count())
         return
@@ -200,7 +202,10 @@ def _search_books(case_sensitive, search_type, args):
             print(" ", encode(_("Deleted")), ":",
                   encode(_(str(book.deleted))))
         if args.get or args.get_many:
-            download(book, os.path.curdir, args.path, args.format)
+            download_to = args.download_to
+            if download_to is None:
+                download_to = get_config().getpath('download', 'path')
+            download(book, download_to, args.path, args.format)
         count += 1
     print_count(count)
 
@@ -322,7 +327,12 @@ 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,
+                        help='download directory')
     parser.add_argument('-F', '--format',
                         help='download format, default is %%f')
     parser.add_argument('--get', action='store_true',
@@ -368,7 +378,7 @@ if __name__ == '__main__':
 
     if int(args.start) + int(args.substring) + int(args.full) > 1:
         sys.stderr.write(
-            "Cannot search case sensitive and case insensitive "
+            "Cannot search from start, substring and full "
             "at the same time\n")
         main_parser.print_help()
         sys.exit(1)