Skip to content

Commit

Permalink
Merge pull request #884 from philborman/master
Browse files Browse the repository at this point in the history
Renamed filter, message changes, urlencode all torrent params
  • Loading branch information
philborman authored Jun 23, 2017
2 parents 458eac7 + d3e47fc commit fb4b821
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 58 deletions.
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ <h1>${title}</h1>
return btn;} }
],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No books found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ <h1><a href="${author['AuthorLink']}" target="_blank" rel="noreferrer">${author[
return btn;} }
],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No books found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/books.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ <h1>${title}</h1>
return btn;} }
],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No books found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
2 changes: 1 addition & 1 deletion data/interfaces/bookstrap/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ <h1>${title}</h1>
</div>
</fieldset>
<button class="button btn btn-sm btn-primary" type="button" value="showblocked" id="showblocked"> Blocked Providers</button>
<br>
<br><br>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ <h1>${title}</h1>
return ftype;} },
],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"Show _MENU_ rows per page",
"sEmptyTable": "No history found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ <h1>${title}</h1>
{ type: 'natural', targets: 3 },
{ type: 'natural-nohtml', targets: 4 }],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No authors found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/issues.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ <h1>${title}</h1>
"order": [[ 2, 'desc']],
"columnDefs": [{ targets: 'no-sort', orderable: false }],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"Show _MENU_ issues per page",
"sEmptyTable": "No issues found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ results",
Expand Down
2 changes: 1 addition & 1 deletion data/interfaces/bookstrap/logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h1>${title}</h1>
"stateSave": true,
"order": [[ 0, 'desc' ]],
"oLanguage": {
"sSearch":"",
"sSearch":"Filter: ",
"sLengthMenu":"Show _MENU_ rows per page",
"sEmptyTable": "No log information available",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/magazines.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ <h1>${title}</h1>
[{ targets: 'no-sort', orderable: false },
{ type: 'natural', targets: 3 }],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No magazines found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/managebooks.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ <h1>${title}</h1>
return '<img src="images/' + data + '-stars.png" alt="Rating">';} }
],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No books found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/manageissues.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ <h3>Magazines with status ${whichStatus}</h3>
]
,
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No matching issues found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/manualsearch.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ <h2>${title}</h2>
"responsive": true,
"order": [[ 0, 'desc' ]],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"Show _MENU_ rows per page",
"sEmptyTable": "No results found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/members.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ <h1>${series['AuthorName']} : ${title}</h1>
"columnDefs": [{ targets: 'no-sort', orderable: false },
{ type: 'natural', targets: 4 }],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No books found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/searchresults.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ <h1>${title}</h1>
[{ targets: 'no-sort', orderable: false }]
,
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"Show _MENU_ books per page",
"sEmptyTable": "No books found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ results",
Expand Down
1 change: 1 addition & 0 deletions data/interfaces/bookstrap/series.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ <h1>${title}</h1>
}
],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No series found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
Expand Down
1 change: 1 addition & 0 deletions lazylibrarian/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def update_totals(AuthorID):
# author totals needs to be updated every time a book is marked differently
match = myDB.select('SELECT AuthorID from authors WHERE AuthorID="%s"' % AuthorID)
if not match:
logger.debug('Update_totals - authorid [%s] not found' % AuthorID)
return
cmd = 'SELECT BookName, BookLink, BookDate from books WHERE AuthorID="%s"' % AuthorID
cmd += ' AND Status != "Ignored" order by BookDate DESC'
Expand Down
11 changes: 6 additions & 5 deletions lazylibrarian/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ def processDir(reset=False):
logger.debug("Not removing original files as in download root")

logger.info('Successfully processed: %s' % global_name)

ppcount += 1
custom_notify_download(book['BookID'])

Expand Down Expand Up @@ -838,11 +839,6 @@ def processExtras(dest_file=None, global_name=None, bookid=None, book_type="eBoo

myDB = database.DBConnection()

# update authors book counts
match = myDB.match('SELECT AuthorID FROM books WHERE BookID="%s"' % bookid)
if match:
update_totals(match['AuthorID'])

controlValueDict = {"BookID": bookid}
if book_type == 'AudioBook':
newValueDict = {"AudioFile": dest_file, "AudioStatus": "Open", "AudioLibrary": now()}
Expand All @@ -851,6 +847,11 @@ def processExtras(dest_file=None, global_name=None, bookid=None, book_type="eBoo
newValueDict = {"Status": "Open", "BookFile": dest_file, "BookLibrary": now()}
myDB.upsert("books", newValueDict, controlValueDict)

# update authors book counts
match = myDB.match('SELECT AuthorID FROM books WHERE BookID="%s"' % bookid)
if match:
update_totals(match['AuthorID'])

if book_type != 'eBook': # only do autoadd/img/opf for ebooks
return

Expand Down
49 changes: 22 additions & 27 deletions lazylibrarian/resultlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ def findBestResult(resultlist, book, searchtype, source):
resultTitle = re.sub(r"\s\s+", " ", resultTitle) # remove extra whitespace
Author_match = fuzz.token_set_ratio(author, resultTitle)
Book_match = fuzz.token_set_ratio(title, resultTitle)
stype = source.upper()
if res[prefix + 'prov'] == 'libgen':
stype = "DIR"
logger.debug(u"%s author/book Match: %s/%s for %s at %s" %
(source.upper(), Author_match, Book_match, resultTitle, res[prefix + 'prov']))
(stype, Author_match, Book_match, resultTitle, res[prefix + 'prov']))

rejected = False

Expand All @@ -113,45 +116,39 @@ def findBestResult(resultlist, book, searchtype, source):
logger.debug("Rejecting %s, blacklisted at %s" % (resultTitle, already_failed['NZBprov']))
rejected = True

if not rejected:
if not url.startswith('http') and not url.startswith('magnet'):
if not rejected and not url.startswith('http') and not url.startswith('magnet'):
rejected = True
logger.debug("Rejecting %s, invalid URL [%s]" % (resultTitle, url))

if not rejected:
author_words = getList(author.lower())
title_words = getList(title.lower())
result_words = getList(resultTitle.lower())
for word in reject_list:
if word in result_words and word not in author_words and word not in title_words:
if word in getList(resultTitle.lower()) and word not in getList(author.lower()) \
and word not in getList(title.lower()):
rejected = True
logger.debug("Rejecting %s, contains %s" % (resultTitle, word))
break

size_temp = res[prefix + 'size'] # Need to cater for when this is NONE (Issue 35)
size_temp = check_int(size_temp, 1000)
size_temp = check_int(res[prefix + 'size'], 1000) # Need to cater for when this is NONE (Issue 35)
size = round(float(size_temp) / 1048576, 2)

if not rejected:
if maxsize and size > maxsize:
if not rejected and maxsize and size > maxsize:
rejected = True
logger.debug("Rejecting %s, too large" % resultTitle)

if not rejected:
if minsize and size < minsize:
rejected = True
logger.debug("Rejecting %s, too small" % resultTitle)
if not rejected and minsize and size < minsize:
rejected = True
logger.debug("Rejecting %s, too small" % resultTitle)

if not rejected:
bookid = book['bookid']
newTitle = (author + ' - ' + title + ' LL.(' + book['bookid'] + ')').strip()

if source == 'nzb':
mode = res['nzbmode']
mode = res['nzbmode'] # nzb, torznab
elif source == 'tor':
mode = "torrent"
else: # rss returns torrents
mode = "torrent"
mode = res['tor_type'] # torrent, magnet, direct
else:
mode = res['tor_type'] # torrent, magnet, nzb

controlValueDict = {"NZBurl": url}
newValueDict = {
Expand All @@ -169,8 +166,7 @@ def findBestResult(resultlist, book, searchtype, source):
# lose a point for each unwanted word in the title so we get the closest match
# but for RSS ignore anything at the end in square braces [keywords, genres etc]
if source == 'rss':
temptitle = resultTitle.rsplit('[', 1)[0]
wordlist = getList(temptitle.lower())
wordlist = getList(resultTitle.rsplit('[', 1)[0].lower())
else:
wordlist = getList(resultTitle.lower())
words = [x for x in wordlist if x not in getList(author.lower())]
Expand All @@ -184,8 +180,7 @@ def findBestResult(resultlist, book, searchtype, source):
booktypes = [x for x in wordlist if x in getList(lazylibrarian.CONFIG['AUDIOBOOK_TYPE'])]
score -= len(words)
# prioritise titles that include the ebook types we want
if len(booktypes):
score += 1
score += len(booktypes)
matches.append([score, resultTitle, newValueDict, controlValueDict, res['priority']])

if matches:
Expand All @@ -197,11 +192,11 @@ def findBestResult(resultlist, book, searchtype, source):
dlpriority = highest[4]

if score < int(lazylibrarian.CONFIG['MATCH_RATIO']):
logger.info(u'Nearest %s match (%s%%): %s using %s search for %s %s' %
(source.upper(), score, resultTitle, searchtype, book['authorName'], book['bookName']))
logger.info(u'Nearest match (%s%%): %s using %s search for %s %s' %
(score, resultTitle, searchtype, book['authorName'], book['bookName']))
else:
logger.info(u'Best %s match (%s%%): %s using %s search, %s priority %s' %
(source.upper(), score, resultTitle, searchtype, newValueDict['NZBprov'], dlpriority))
logger.info(u'Best match (%s%%): %s using %s search, %s priority %s' %
(score, resultTitle, searchtype, newValueDict['NZBprov'], dlpriority))
return highest
else:
logger.debug("No %s found for [%s] using searchtype %s" % (source, book["searchterm"], searchtype))
Expand Down
14 changes: 11 additions & 3 deletions lazylibrarian/searchbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def search_book(books=None, library=None):
library is "eBook" or "AudioBook" or None to search all book types
"""
# noinspection PyBroadException
print "***",books,library
try:
threadname = threading.currentThread().name
if "Thread-" in threadname:
Expand Down Expand Up @@ -67,8 +68,12 @@ def search_book(books=None, library=None):
cmd += 'from books,authors WHERE BookID="%s" ' % book['bookid']
cmd += 'AND books.AuthorID = authors.AuthorID'
results = myDB.select(cmd)
for terms in results:
searchbooks.append(terms)
if results:
for terms in results:
searchbooks.append(terms)
else:
logger.debug("SearchBooks - BookID %s is not in the database" % book['bookid'])


if len(searchbooks) == 0:
logger.debug("SearchBooks - No books to search for")
Expand Down Expand Up @@ -209,8 +214,11 @@ def search_book(books=None, library=None):
logger.info("%s Searches for %s %s returned no results." %
(mode.upper(), book['library'], book['searchterm']))
else:
smode = mode.upper()
if match[2]['NZBprov'] == 'libgen':
smode = 'DIR'
logger.info("Found %s result: %s %s%%, %s priority %s" %
(mode.upper(), searchtype, match[0], match[2]['NZBprov'], match[4]))
(smode, searchtype, match[0], match[2]['NZBprov'], match[4]))
matches.append(match)

if matches:
Expand Down
Loading

0 comments on commit fb4b821

Please sign in to comment.