diff --git a/src/calibre/gui2/store/stores/archive_org_plugin.py b/src/calibre/gui2/store/stores/archive_org_plugin.py index d43a201d68..b231d364f3 100644 --- a/src/calibre/gui2/store/stores/archive_org_plugin.py +++ b/src/calibre/gui2/store/stores/archive_org_plugin.py @@ -8,20 +8,33 @@ __copyright__ = '2011, John Schember ' __docformat__ = 'restructuredtext en' from calibre.gui2.store.basic_config import BasicStoreConfig -from calibre.gui2.store.opensearch_store import OpenSearchOPDSStore +from calibre.gui2.store.opensearch_store import OpenSearchOPDSStore, open_search from calibre.gui2.store.search_result import SearchResult +SEARCH_URL = 'http://bookserver.archive.org/catalog/opensearch.xml' + + +def search(query, max_results=10, timeout=60): + for result in open_search(SEARCH_URL, query, max_results=max_results, timeout=timeout): + yield result + class ArchiveOrgStore(BasicStoreConfig, OpenSearchOPDSStore): - open_search_url = 'http://bookserver.archive.org/catalog/opensearch.xml' + open_search_url = SEARCH_URL web_url = 'http://www.archive.org/details/texts' # http://bookserver.archive.org/catalog/ def search(self, query, max_results=10, timeout=60): - for s in OpenSearchOPDSStore.search(self, query, max_results, timeout): + for s in search(query, max_results, timeout): s.detail_item = 'http://www.archive.org/details/' + s.detail_item.split(':')[-1] s.price = '$0.00' s.drm = SearchResult.DRM_UNLOCKED yield s + + +if __name__ == '__main__': + import sys + for s in search(' '.join(sys.argv[1:])): + print(s)