Skip to content

Commit

Permalink
Merge pull request #882 from philborman/master
Browse files Browse the repository at this point in the history
Check ebook/audiobook locations on rescan, button to clear blocklist
  • Loading branch information
philborman authored Jun 21, 2017
2 parents 5648538 + 25b2ee4 commit e88df56
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 28 deletions.
17 changes: 11 additions & 6 deletions data/interfaces/bookstrap/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,11 @@ <h1>${title}</h1>
</fieldset>
<div class="checkbox">
<%
if lazylibrarian.CONFIG['TOR_DOWNLOADER_RTORRENT'] == True:
checked = 'checked="checked"'
else:
checked = ''
%>
if lazylibrarian.CONFIG['TOR_DOWNLOADER_RTORRENT'] == True:
checked = 'checked="checked"'
else:
checked = ''
%>
<label for="tor_downloader_rtorrent" class="control-label">
<input type="checkbox" id="tor_downloader_rtorrent" name="tor_downloader_rtorrent" value="1" ${checked} />
Use rTorrent</label>
Expand Down Expand Up @@ -2459,8 +2459,13 @@ <h1>${title}</h1>
message: '<pre>'+data+'</pre>',
buttons: {
primary: {
label: "Close",
label: "Ok",
className: 'btn-primary'
},
prompt: {
label: "Clear Blocklist",
className: 'btn-primary',
callback: function(result){ $.get("clearblocked", function(e) {}); }
}
}
});
Expand Down
45 changes: 23 additions & 22 deletions lazylibrarian/librarysync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' %
Expand All @@ -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' %
Expand Down Expand Up @@ -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'])
Expand All @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions lazylibrarian/webServe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand All @@ -2001,6 +2012,7 @@ def showblocked(self):

if result == '':
result = 'No blocked providers'
logger.debug(result)
return result

@cherrypy.expose
Expand Down

0 comments on commit e88df56

Please sign in to comment.