From a22d9fc10c232517c8806345b7d310d1dbab602b Mon Sep 17 00:00:00 2001 From: Phil Borman Date: Wed, 21 Jun 2017 14:06:32 +0200 Subject: [PATCH 1/3] Button to clear provider blocklist --- data/interfaces/bookstrap/config.html | 17 +++++++++++------ lazylibrarian/webServe.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/data/interfaces/bookstrap/config.html b/data/interfaces/bookstrap/config.html index ab6c7266a..901e2e0c0 100644 --- a/data/interfaces/bookstrap/config.html +++ b/data/interfaces/bookstrap/config.html @@ -664,11 +664,11 @@

${title}

<% - if lazylibrarian.CONFIG['TOR_DOWNLOADER_RTORRENT'] == True: - checked = 'checked="checked"' - else: - checked = '' - %> + if lazylibrarian.CONFIG['TOR_DOWNLOADER_RTORRENT'] == True: + checked = 'checked="checked"' + else: + checked = '' + %> @@ -2459,8 +2459,13 @@

${title}

message: '
'+data+'
', buttons: { primary: { - label: "Close", + label: "Ok", className: 'btn-primary' + }, + prompt: { + label: "Clear Blocklist", + className: 'btn-primary', + callback: function(result){ $.get("clearblocked", function(e) {}); } } } }); diff --git a/lazylibrarian/webServe.py b/lazylibrarian/webServe.py index f4a113b51..8e6ca6e91 100644 --- a/lazylibrarian/webServe.py +++ b/lazylibrarian/webServe.py @@ -1986,6 +1986,17 @@ def clearhistory(self, status=None): myDB.action('DELETE from wanted WHERE Status="%s"' % status) raise cherrypy.HTTPRedirect("history") + @cherrypy.expose + def clearblocked(self): + cherrypy.response.headers[ + 'Cache-Control'] = "max-age=0,no-cache,no-store" + # clear any currently blocked providers + num = len(lazylibrarian.PROVIDER_BLOCKLIST) + lazylibrarian.PROVIDER_BLOCKLIST = [] + result = 'Cleared %s blocked providers' % num + logger.debug(result) + return result + @cherrypy.expose def showblocked(self): cherrypy.response.headers[ @@ -2001,6 +2012,7 @@ def showblocked(self): if result == '': result = 'No blocked providers' + logger.debug(result) return result @cherrypy.expose From fb777e16fca4f751e3b6b4448d73429ee2b41272 Mon Sep 17 00:00:00 2001 From: Phil Borman Date: Wed, 21 Jun 2017 17:30:05 +0200 Subject: [PATCH 2/3] Check ebook/audiobook locations on author scan --- lazylibrarian/librarysync.py | 41 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lazylibrarian/librarysync.py b/lazylibrarian/librarysync.py index 3300970e1..b4b7b3dcd 100644 --- a/lazylibrarian/librarysync.py +++ b/lazylibrarian/librarysync.py @@ -676,16 +676,16 @@ def LibraryScan(startdir=None, library='eBook'): logger.debug('Unable to find bookid %s in database' % bookid) else: book_filename = None - if library == 'eBook' and check_status['Status'] != 'Open': - # we found a new book - new_book_count += 1 - myDB.action( - 'UPDATE books set Status="Open" where BookID="%s"' % bookid) - myDB.action( - 'UPDATE books set BookLibrary="%s" where BookID="%s"' % (now(), bookid)) - - # store book location so we can check if it gets removed - # store the first book_type found in ebook_type + if library == 'eBook': + if check_status['Status'] != 'Open': + # we found a new book + new_book_count += 1 + myDB.action( + 'UPDATE books set Status="Open" where BookID="%s"' % bookid) + myDB.action( + 'UPDATE books set BookLibrary="%s" where BookID="%s"' % (now(), bookid)) + + # check and store book location so we can check if it gets (re)moved book_filename = os.path.join(r, files) book_basename = os.path.splitext(book_filename)[0] booktype_list = getList(lazylibrarian.CONFIG['EBOOK_TYPE']) @@ -710,17 +710,18 @@ def LibraryScan(startdir=None, library='eBook'): myDB.action('UPDATE books set BookFile="%s" where BookID="%s"' % (book_filename, bookid)) - elif library == 'Audio' and check_status['AudioStatus'] != 'Open': - # we found a new audiobook - new_book_count += 1 - myDB.action( - 'UPDATE books set AudioStatus="Open" where BookID="%s"' % bookid) - myDB.action( - 'UPDATE books set AudioLibrary="%s" where BookID="%s"' % ( - now(), bookid)) - # store audiobook location so we can check if it gets removed + elif library == 'Audio': + if check_status['AudioStatus'] != 'Open': + # we found a new audiobook + new_book_count += 1 + myDB.action( + 'UPDATE books set AudioStatus="Open" where BookID="%s"' % bookid) + myDB.action( + 'UPDATE books set AudioLibrary="%s" where BookID="%s"' % ( + now(), bookid)) + # store audiobook location so we can check if it gets (re)moved book_filename = os.path.join(r, files) - # try to keep track of the first part of multi-part audiobooks + # link to the first part of multi-part audiobooks for fname in os.listdir(r): if is_valid_booktype(fname, booktype='audiobook') and '01' in fname: book_filename = os.path.join(r, fname) From 25b2ee40717f6dc15fc03a1635fea596bade48b5 Mon Sep 17 00:00:00 2001 From: Phil Borman Date: Wed, 21 Jun 2017 18:01:55 +0200 Subject: [PATCH 3/3] Fix check for missing books on libraryscan --- lazylibrarian/librarysync.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lazylibrarian/librarysync.py b/lazylibrarian/librarysync.py index b4b7b3dcd..32f444f5e 100644 --- a/lazylibrarian/librarysync.py +++ b/lazylibrarian/librarysync.py @@ -333,7 +333,7 @@ def LibraryScan(startdir=None, library='eBook'): for book in books: bookfile = book['BookFile'] - if not (bookfile and os.path.isfile(bookfile)): + if bookfile and not os.path.isfile(bookfile): myDB.action('update books set Status="%s",BookFile="",BookLibrary="" where BookID="%s"' % (status, book['BookID'])) logger.warn('eBook %s - %s updated as not found on disk' % @@ -350,7 +350,7 @@ def LibraryScan(startdir=None, library='eBook'): for book in books: bookfile = book['AudioFile'] - if not (bookfile and os.path.isfile(bookfile)): + if bookfile and not os.path.isfile(bookfile): myDB.action('update books set AudioStatus="%s",AudioFile="",AudioLibrary="" where BookID="%s"' % (status, book['BookID'])) logger.warn('Audiobook %s - %s updated as not found on disk' %