![]() |
#1 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
|
Template for "Get books" store plugins?
Is there a template for making store plugins to add custom stores to the "Get books" menu?
I'd like to add a store that allows me to add books via an OPDS feed (similar to OPDS Client, but as a store listed us the "Get books" dropdown). |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
There's no template but many existing stores are opds based use one as a base to copy to create your own get books store plugin
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
|
Oh I see there's an OpenSearchOPDSStore I can inherit from.
|
![]() |
![]() |
![]() |
#4 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
|
This helped as a template:
├── __init__.py ├── flibusta.py └── plugin-import-name-store_flibusta.txt Code:
:::::::::::::: __init__.py :::::::::::::: # -*- coding: utf-8 -*- from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL 3' __copyright__ = '2012, Sergey Kuznetsov <clk824@gmail.com>' __docformat__ = 'restructuredtext en' from calibre.customize import StoreBase class FlibustaStore(StoreBase): name = 'Флибуста' description = _('Книжное братство') actual_plugin = 'calibre_plugins.store_flibusta.flibusta:FlibustaStore' :::::::::::::: flibusta.py :::::::::::::: # -*- coding: utf-8 -*- from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL 3' __copyright__ = '2012, Sergey Kuznetsov <clk824@gmail.com>' __docformat__ = 'restructuredtext en' from calibre.gui2.store.basic_config import BasicStoreConfig from calibre.gui2.store.opensearch_store import OpenSearchOPDSStore from calibre.gui2.store.search_result import SearchResult class FlibustaStore(BasicStoreConfig, OpenSearchOPDSStore): open_search_url = 'http://flibusta.net/opds-opensearch.xml' web_url = 'http://flibusta.net/' def search(self, query, max_results=10, timeout=60): for s in OpenSearchOPDSStore.search(self, query, max_results, timeout): s.detail_item = 'http://flibusta.net/b/' + s.detail_item.split(':')[-1] s.price = '$0.00' s.drm = SearchResult.DRM_UNLOCKED yield s def get_details(self, search_result, timeout): search_result.drm = SearchResult.DRM_UNLOCKED search_result.formats = "FB2, EPUB, MOBI" search_result.downloads["FB2"] = search_result.detail_item + "/fb2" search_result.downloads["EPUB"] = search_result.detail_item + "/epub" search_result.downloads["MOBI"] = search_result.detail_item + "/mobi" return True :::::::::::::: plugin-import-name-store_flibusta.txt :::::::::::::: |
![]() |
![]() |
![]() |
#5 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
|
However, I get these errors:
Code:
Traceback (most recent call last): File "mechanize/_mechanize.py", line 266, in _mech_open AttributeError: 'str' object has no attribute 'get_full_url' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "calibre/gui2/store/search/download_thread.py", line 117, in run File "calibre/gui2/store/opensearch_store.py", line 101, in search File "calibre/gui2/store/opensearch_store.py", line 33, in open_search File "mechanize/_mechanize.py", line 257, in open File "mechanize/_mechanize.py", line 273, in _mech_open mechanize._mechanize.BrowserStateError: can't fetch relative reference: not viewing any document |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You will need to absolutize the links, cant help in more detail as this is not a part of the code I am familiar with, it came from @user_none.
|
![]() |
![]() |
![]() |
#7 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
|
|
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Because the calibre server has no knowledge of what the hostname/ip address of the machine it is running on is.
|
![]() |
![]() |
![]() |
#9 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
|
|
![]() |
![]() |
![]() |
#10 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
|
I'm confused now. 🤔
When I specify an open_search_url that contains '{searchTerms}' or when I specify an open_search_url that is to an OpenSearch XML file, I get: Code:
mechanize._response.get_seek_wrapper_class.<locals>.httperror_seek_wrapper: HTTP Error 404: Not Found |
![]() |
![]() |
![]() |
#11 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
|
Actually, I'm noting other stores don't work either, like Archive.org, Google Books, MobileRead, and Project Gutenberg.
I'm using Calibre 8.1.1 on Linux. |
![]() |
![]() |
![]() |
#12 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
mobileread at least works fine for me on linux.
|
![]() |
![]() |
![]() |
#13 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
|
Hmm… Now it's working for me after I upgraded.
However, Google Books gives: Code:
mechanize._response.get_seek_wrapper_class.<locals>.httperror_seek_wrapper: HTTP Error 403: Forbidden |
![]() |
![]() |
![]() |
#14 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That's because the server is blocking you as a bot.
|
![]() |
![]() |
![]() |
Tags |
get books, opds, plugins, stores |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Store" home screen button and "Web" homepage set to weird czech(?) store - fixable? | ell | PocketBook | 10 | 04-16-2024 04:23 AM |
"Normal" template inside GPM template | ownedbycats | Library Management | 20 | 12-02-2020 09:40 PM |
Kindle store: no books after the "homepage" | zamana | Amazon Kindle | 4 | 12-20-2017 09:27 AM |
"Add a book" template like "Save to disk"? | vr8ce | Library Management | 10 | 06-09-2017 08:16 AM |
PRS-T1 "Google Books are no longer available via Reader Store" | tomsem | Sony Reader | 10 | 03-03-2012 07:57 PM |