mirror of
https://gitlab.com/LazyLibrarian/LazyLibrarian.git
synced 2026-02-06 10:47:15 +00:00
Better fix for #2945 provider api access
This commit is contained in:
parent
04b8a7c5d8
commit
8ee9f64347
@ -1,3 +1,5 @@
|
||||
[ Buy Me a Coffee](https://buymeacoffee.com/philbormang)
|
||||
|
||||
## LazyLibrarian
|
||||
LazyLibrarian is a program to follow authors and grab metadata for all your digital reading needs.
|
||||
It uses a combination of [HardCover](https://hardcover.app) [OpenLibrary](https://openlibrary.org/) [Librarything](https://www.librarything.com/) [GoodReads](https://www.goodreads.com) and optionally [GoogleBooks](https://www.googleapis.com/books/v1/) as sources for author info and book info. License: GNU GPL v3
|
||||
@ -53,3 +55,5 @@ LinuxServer : https://hub.docker.com/r/linuxserver/lazylibrarian/
|
||||
The docker package includes ghostscript for magazine cover generation and calibredb (via optional variable)
|
||||
LinuxServer docker is multi-arch and works on X86_64, armhf and aarch64 (calibredb only available on X86_64)
|
||||
The dockers can be upgraded using the lazylibrarian internal upgrade mechanism
|
||||
|
||||
[ Buy Me a Coffee](https://buymeacoffee.com/philbormang)
|
||||
|
||||
@ -2257,7 +2257,7 @@ class Api:
|
||||
|
||||
if source in lazylibrarian.INFOSOURCES.keys():
|
||||
this_source = lazylibrarian.INFOSOURCES[source]
|
||||
ap = this_source['api']
|
||||
ap = this_source['api']()
|
||||
res = ap.find_author_id(authorname=authorname)
|
||||
self.data = str(res)
|
||||
|
||||
@ -2281,7 +2281,7 @@ class Api:
|
||||
return
|
||||
|
||||
authordata = db.select(f"SELECT AuthorName from authors WHERE {key}='' or {key} is null")
|
||||
api = this_source['api']
|
||||
api = this_source['api']()
|
||||
for author in authordata:
|
||||
res = api.find_author_id(authorname=author['AuthorName'])
|
||||
if res.get('authorid'):
|
||||
@ -2299,7 +2299,7 @@ class Api:
|
||||
|
||||
authorname = format_author_name(kwargs['name'], postfix=get_list(CONFIG.get_csv('NAME_POSTFIX')))
|
||||
this_source = lazylibrarian.INFOSOURCES[CONFIG['BOOK_API']]
|
||||
api = this_source['api']
|
||||
api = this_source['api']()
|
||||
myqueue = Queue()
|
||||
search_api = threading.Thread(target=api.find_results,
|
||||
name=f"API-{this_source['src']}RESULTS",
|
||||
@ -2315,7 +2315,7 @@ class Api:
|
||||
return
|
||||
|
||||
this_source = lazylibrarian.INFOSOURCES[CONFIG['BOOK_API']]
|
||||
api = this_source['api']
|
||||
api = this_source['api']()
|
||||
myqueue = Queue()
|
||||
search_api = threading.Thread(target=api.find_results,
|
||||
name=f"API-{this_source['src']}RESULTS",
|
||||
@ -2371,7 +2371,7 @@ class Api:
|
||||
self.data = 'Missing parameter: id'
|
||||
return
|
||||
this_source = lazylibrarian.INFOSOURCES[CONFIG['BOOK_API']]
|
||||
api = this_source['api']
|
||||
api = this_source['api']()
|
||||
if 'wait' in kwargs:
|
||||
self.data = api.add_bookid_to_db(kwargs['id'], None, None, "Added by API")
|
||||
else:
|
||||
|
||||
@ -929,8 +929,7 @@ def search_for(searchterm, source=None):
|
||||
source = CONFIG['BOOK_API']
|
||||
searchinglogger.debug(f"{source} {searchterm}")
|
||||
this_source = lazylibrarian.INFOSOURCES[source]
|
||||
api = this_source['api']
|
||||
api.__init__()
|
||||
api = this_source['api']()
|
||||
if CONFIG[this_source['enabled']]:
|
||||
myqueue = Queue()
|
||||
search_api = threading.Thread(target=api.find_results,
|
||||
|
||||
@ -105,7 +105,7 @@ def get_book_meta(fdir, reason="get_book_meta"):
|
||||
if not existing_book:
|
||||
logger.debug(f"Searching {CONFIG['BOOK_API']} for {bookid}")
|
||||
this_source = lazylibrarian.INFOSOURCES[CONFIG['BOOK_API']]
|
||||
api = this_source['api']
|
||||
api = this_source['api']()
|
||||
_ = api.add_bookid_to_db(bookid, None, None, reason)
|
||||
existing_book = db.match(cmd, (bookid,))
|
||||
db.close()
|
||||
@ -1039,7 +1039,7 @@ def library_scan(startdir=None, library='eBook', authid=None, remove=True):
|
||||
f"Metadata bookid [{bookid}] not found in database, trying to add...")
|
||||
|
||||
this_source = lazylibrarian.INFOSOURCES[CONFIG['BOOK_API']]
|
||||
api = this_source['api']
|
||||
api = this_source['api']()
|
||||
book_id = eval(this_source['book_key'])
|
||||
if book_id:
|
||||
src = this_source['src']
|
||||
@ -1160,7 +1160,7 @@ def library_scan(startdir=None, library='eBook', authid=None, remove=True):
|
||||
else:
|
||||
logger.debug(f"Adding {bookid} [{bookauthor}] on rescan for {booktitle}")
|
||||
this_source = lazylibrarian.INFOSOURCES[source]
|
||||
api = this_source['api']
|
||||
api = this_source['api']()
|
||||
_ = api.add_bookid_to_db(bookid, reason=f"Librarysync {source} "
|
||||
f"rescan {bookauthor}")
|
||||
if language and language != "Unknown":
|
||||
|
||||
@ -276,7 +276,7 @@ def process_book_from_dir(source_dir=None, library="eBook", bookid=None):
|
||||
if not book:
|
||||
logger.warning(f"Bookid [{bookid}] not found in database, trying to add...")
|
||||
this_source = lazylibrarian.INFOSOURCES[CONFIG["BOOK_API"]]
|
||||
api = this_source["api"]
|
||||
api = this_source["api"]()
|
||||
_ = api.add_bookid_to_db(bookid, None, None, f"Added by book_from_dir {source_dir}")
|
||||
# see if it's there now...
|
||||
book = db.match("SELECT * from books where BookID=?", (bookid,))
|
||||
|
||||
@ -330,15 +330,15 @@ class StartupLazyLibrarian:
|
||||
def build_sources():
|
||||
info_sources = {
|
||||
'OpenLibrary': {'src': 'OL', 'author_key': 'ol_id', 'book_key': 'ol_id', 'enabled': 'OL_API',
|
||||
'api': ol.OpenLibrary(), 'has_subs': 0},
|
||||
'api': ol.OpenLibrary, 'has_subs': 0},
|
||||
'GoodReads': {'src': 'GR', 'author_key': 'gr_id', 'book_key': 'gr_id', 'enabled': 'GR_API',
|
||||
'api': gr.GoodReads(), 'has_subs': 0},
|
||||
'api': gr.GoodReads, 'has_subs': 0},
|
||||
'HardCover': {'src': 'HC', 'author_key': 'hc_id', 'book_key': 'hc_id', 'enabled': 'HC_API',
|
||||
'api': hc.HardCover(), 'has_subs': 1},
|
||||
'api': hc.HardCover, 'has_subs': 1},
|
||||
'GoogleBooks': {'src': 'GB', 'author_key': 'authorid', 'book_key': 'gb_id', 'enabled': 'GB_API',
|
||||
'api': gb.GoogleBooks(), 'has_subs': 1},
|
||||
'api': gb.GoogleBooks, 'has_subs': 1},
|
||||
'DNB': {'src': 'DN', 'author_key': 'authorid', 'book_key': 'dnb_id', 'enabled': 'DNB_API',
|
||||
'api': dnb.DNB(), 'has_subs': 1},
|
||||
'api': dnb.DNB, 'has_subs': 1},
|
||||
}
|
||||
adminlogger = logging.getLogger('special.admin')
|
||||
adminlogger.debug(info_sources)
|
||||
|
||||
@ -3374,7 +3374,7 @@ class WebInterface:
|
||||
update_totals(author_id)
|
||||
else:
|
||||
this_source = lazylibrarian.INFOSOURCES[CONFIG['BOOK_API']]
|
||||
api = this_source['api']
|
||||
api = this_source['api']()
|
||||
t = threading.Thread(target=api.add_bookid_to_db,
|
||||
name=f"{this_source['src']}-BOOK",
|
||||
args=[bookid, ebook_status, audio_status, "Added by user"])
|
||||
@ -4388,7 +4388,7 @@ class WebInterface:
|
||||
args.pop(arg, None)
|
||||
|
||||
this_source = lazylibrarian.INFOSOURCES[CONFIG['BOOK_API']]
|
||||
api = this_source['api']
|
||||
api = this_source['api']()
|
||||
ids = set(args.keys())
|
||||
if action in ['AddBook', 'AddAudio', 'AddBoth']:
|
||||
wantbook = "Wanted" if action in ['AddBook', 'AddBoth'] else 'Skipped'
|
||||
|
||||
2
unittests/testdata/testconfig-defaults.ini
vendored
2
unittests/testdata/testconfig-defaults.ini
vendored
@ -1,6 +1,6 @@
|
||||
[GENERAL]
|
||||
no_ipv6 = True
|
||||
imp_preflang = en-US, en, eng, English, en-GB
|
||||
imp_preflang = eng, en-GB, en, en-US, English
|
||||
http_ext_timeout = 100
|
||||
ebook_dir = ./testdata/eBooks
|
||||
audio_dir = ./testdata/Audiobooks
|
||||
|
||||
Loading…
Reference in New Issue
Block a user