From 170858cfe37daeb9b32824db5853006b6c6efd8e Mon Sep 17 00:00:00 2001 From: "phil.borman@gmail.com" Date: Thu, 15 Jan 2026 17:52:35 +0100 Subject: [PATCH] Return default download directory for downloads from annas/zlib/libgen --- lazylibrarian/annas.py | 6 +++--- lazylibrarian/postprocess.py | 9 ++++++--- lib/zlibrary.py | 2 +- unittests/testdata/testconfig-defaults.ini | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lazylibrarian/annas.py b/lazylibrarian/annas.py index 0403c17f..59f3dd8a 100644 --- a/lazylibrarian/annas.py +++ b/lazylibrarian/annas.py @@ -30,8 +30,8 @@ import lazylibrarian from lazylibrarian import database from lazylibrarian.blockhandler import BLOCKHANDLER from lazylibrarian.config2 import CONFIG -from lazylibrarian.filesystem import DIRS, path_isfile, remove_file -from lazylibrarian.formatter import check_int, get_list, md5_utf8, plural, sanitize, size_in_bytes +from lazylibrarian.filesystem import DIRS, get_directory, path_isfile, remove_file +from lazylibrarian.formatter import check_int, md5_utf8, plural, sanitize, size_in_bytes py310 = sys.version_info >= (3, 10) @@ -360,7 +360,7 @@ def annas_download(md5, folder, title, extn): logger.warning(msg) return False, msg logger.debug(f"Got {len(filedata)} bytes for {url}") - download_dir = get_list(CONFIG['DOWNLOAD_DIR'])[0] + download_dir = get_directory('Download') if folder: parent = os.path.join(download_dir, folder) if not os.path.isdir(parent): diff --git a/lazylibrarian/postprocess.py b/lazylibrarian/postprocess.py index de7d3031..e1c39219 100644 --- a/lazylibrarian/postprocess.py +++ b/lazylibrarian/postprocess.py @@ -394,9 +394,12 @@ class BookState: if self.source and self.download_id: general_folder = get_download_folder(self.source, self.download_id) - download_name = get_download_name( - self.download_title, self.source, self.download_id - ) + download_name = get_download_name(self.download_title, self.source, self.download_id) + if general_folder is None and self.source == 'DIRECT': + res = db.match("SELECT NZBprov,NZBtitle from wanted where source='DIRECT' and DownloadID=?", (self.download_id, )) + # These download into first download_dir + if res and res['NZBprov'] in ['annas', 'zlibrary'] or res['NZBprov'].startswith('libgen'): + general_folder = get_directory('Download') # For usenet clients (SABnzbd, NZBGet), the storage field already contains # the complete download path including the folder name, so we don't join diff --git a/lib/zlibrary.py b/lib/zlibrary.py index 36624609..31ce8059 100644 --- a/lib/zlibrary.py +++ b/lib/zlibrary.py @@ -152,7 +152,7 @@ class Zlibrary: def unsaveUserBook(self, bookid: [int, str]) -> dict[str, str]: return self.__makeGetRequest(f"/eapi/user/book/{bookid}/unsave") - def getBookForamt(self, bookid: [int, str], hashid: str) -> dict[str, str]: + def getBookFormat(self, bookid: [int, str], hashid: str) -> dict[str, str]: return self.__makeGetRequest(f"/eapi/book/{bookid}/{hashid}/formats") def getDonations(self) -> dict[str, str]: diff --git a/unittests/testdata/testconfig-defaults.ini b/unittests/testdata/testconfig-defaults.ini index 86c31455..e910ccc0 100644 --- a/unittests/testdata/testconfig-defaults.ini +++ b/unittests/testdata/testconfig-defaults.ini @@ -1,6 +1,6 @@ [GENERAL] no_ipv6 = True -imp_preflang = en-US, eng, en, English, en-GB +imp_preflang = English, en-GB, en, eng, en-US http_ext_timeout = 100 ebook_dir = ./testdata/eBooks audio_dir = ./testdata/Audiobooks