Skip to content

Commit

Permalink
Merge pull request #883 from philborman/master
Browse files Browse the repository at this point in the history
Extra libgen parsing options
  • Loading branch information
philborman authored Jun 22, 2017
2 parents e88df56 + e80d615 commit 458eac7
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 123 deletions.
8 changes: 4 additions & 4 deletions lazylibrarian/resultlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,16 @@ def findBestResult(resultlist, book, searchtype, source):
highest = max(matches, key=lambda s: (s[0], s[4]))
score = highest[0]
resultTitle = highest[1]
# newValueDict = match[2]
# controlValueDict = match[3]
newValueDict = highest[2]
# controlValueDict = highest[3]
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']))
else:
logger.info(u'Best %s match (%s%%): %s using %s search, priority %s' %
(source.upper(), score, resultTitle, searchtype, dlpriority))
logger.info(u'Best %s match (%s%%): %s using %s search, %s priority %s' %
(source.upper(), 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
29 changes: 21 additions & 8 deletions lazylibrarian/searchbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def search_book(books=None, library=None):
books is a list of new books to add, or None for backlog search
library is "eBook" or "AudioBook" or None to search all book types
"""
# noinspection PyBroadException
try:
threadname = threading.currentThread().name
if "Thread-" in threadname:
Expand Down Expand Up @@ -117,9 +118,11 @@ def search_book(books=None, library=None):
"searchterm": searchterm})

# only get rss results once per run, as they are not search specific
rss_resultlist, nproviders = IterateOverRSSSites()
if not nproviders:
rss_resultlist = None
rss_resultlist = None
if 'rss' in modelist:
rss_resultlist, nproviders = IterateOverRSSSites()
if not nproviders:
modelist.remove('rss')

book_count = 0
for book in searchlist:
Expand All @@ -130,26 +133,24 @@ def search_book(books=None, library=None):
searchtype = 'audio'
else:
searchtype = 'book'

resultlist = None
if mode == 'nzb':
resultlist, nproviders = IterateOverNewzNabSites(book, searchtype)
if not nproviders:
logger.debug("No active nzb providers found")
modelist.remove('nzb')
break # no point in continuing
elif mode == 'tor':
resultlist, nproviders = IterateOverTorrentSites(book, searchtype)
if not nproviders:
logger.debug("No active tor providers found")
modelist.remove('tor')
break # no point in continuing
elif mode == 'rss':
if rss_resultlist:
resultlist = rss_resultlist
nproviders = 1 # dummy value
else:
logger.debug("No active rss providers found")
modelist.remove('rss')
break

if resultlist:
match = findBestResult(resultlist, book, searchtype, mode)
Expand All @@ -161,8 +162,14 @@ def search_book(books=None, library=None):
searchtype = 'short' + searchtype
if mode == 'nzb':
resultlist, nproviders = IterateOverNewzNabSites(book, searchtype)
if not nproviders:
logger.debug("No active nzb providers found")
modelist.remove('nzb')
elif mode == 'tor':
resultlist, nproviders = IterateOverTorrentSites(book, searchtype)
if not nproviders:
logger.debug("No active tor providers found")
modelist.remove('nzb')
elif mode == 'rss':
resultlist = rss_resultlist

Expand All @@ -177,6 +184,9 @@ def search_book(books=None, library=None):
searchtype = 'general'
if mode == 'nzb':
resultlist, nproviders = IterateOverNewzNabSites(book, searchtype)
if not nproviders:
logger.debug("No active nzb providers found")
modelist.remove('nzb')
if resultlist:
match = findBestResult(resultlist, book, searchtype, mode)
else:
Expand All @@ -186,7 +196,10 @@ def search_book(books=None, library=None):
if not goodEnough(match) and '(' in book['searchterm']:
searchtype = 'shortgeneral'
if mode == 'nzb':
resultlist, nproviders = IterateOverNewzNabSites(book, searchtype)
resultlist, _ = IterateOverNewzNabSites(book, searchtype)
if not nproviders:
logger.debug("No active nzb providers found")
modelist.remove('nzb')
if resultlist:
match = findBestResult(resultlist, book, searchtype, mode)
else:
Expand Down
Loading

0 comments on commit 458eac7

Please sign in to comment.