mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A spot of refactoring
This commit is contained in:
parent
2b562831d7
commit
f1484411af
@ -20,12 +20,7 @@ from calibre.utils.opensearch.description import Description
|
||||
from calibre.utils.opensearch.query import Query
|
||||
|
||||
|
||||
class ManyBooksStore(BasicStoreConfig, OpenSearchOPDSStore):
|
||||
|
||||
open_search_url = 'http://www.manybooks.net/opds/'
|
||||
web_url = 'http://manybooks.net'
|
||||
|
||||
def search(self, query, max_results=10, timeout=60):
|
||||
def search_manybooks(query, max_results=10, timeout=60, open_search_url='http://www.manybooks.net/opds/'):
|
||||
'''
|
||||
Manybooks uses a very strange opds feed. The opds
|
||||
main feed is structured like a stanza feed. The
|
||||
@ -34,10 +29,8 @@ class ManyBooksStore(BasicStoreConfig, OpenSearchOPDSStore):
|
||||
link has the wrong type specified (text/html instead
|
||||
of application/atom+xml).
|
||||
'''
|
||||
if not hasattr(self, 'open_search_url'):
|
||||
return
|
||||
|
||||
description = Description(self.open_search_url)
|
||||
description = Description(open_search_url)
|
||||
url_template = description.get_best_template()
|
||||
if not url_template:
|
||||
return
|
||||
@ -108,3 +101,19 @@ class ManyBooksStore(BasicStoreConfig, OpenSearchOPDSStore):
|
||||
s.formats = 'EPUB, PDB (eReader, PalmDoc, zTXT, Plucker, iSilo), FB2, ZIP, AZW, MOBI, PRC, LIT, PKG, PDF, TXT, RB, RTF, LRF, TCR, JAR'
|
||||
|
||||
yield s
|
||||
|
||||
|
||||
class ManyBooksStore(BasicStoreConfig, OpenSearchOPDSStore):
|
||||
|
||||
open_search_url = 'http://www.manybooks.net/opds/'
|
||||
web_url = 'http://manybooks.net'
|
||||
|
||||
def search(self, query, max_results=10, timeout=60):
|
||||
for r in search_manybooks(query, max_results=max_results, timeout=timeout, open_search_url=self.open_search_url):
|
||||
yield r
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
for result in search_manybooks(' '.join(sys.argv[1:])):
|
||||
print (result)
|
||||
|
Loading…
x
Reference in New Issue
Block a user