Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 04-05-2025, 11:14 PM   #1
Geremia
Addict
Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!
 
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).
Geremia is offline   Reply With Quote
Old 04-05-2025, 11:33 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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
kovidgoyal is offline   Reply With Quote
Advert
Old 04-06-2025, 05:23 PM   #3
Geremia
Addict
Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!
 
Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
Oh I see there's an OpenSearchOPDSStore I can inherit from.
Geremia is offline   Reply With Quote
Old 04-06-2025, 07:48 PM   #4
Geremia
Addict
Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!
 
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
::::::::::::::
Geremia is offline   Reply With Quote
Old 04-06-2025, 10:02 PM   #5
Geremia
Addict
Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!
 
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
with what Calibre's OPDS returns (it contains relative links).
Geremia is offline   Reply With Quote
Advert
Old 04-07-2025, 06:40 AM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Old 04-07-2025, 09:56 PM   #7
Geremia
Addict
Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!
 
Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
Quote:
Originally Posted by kovidgoyal View Post
You will need to absolutize the links
That's what I figured. Since it's Calibre generating the OPDS XML, is there a way to absolutize them in Calibre? Why does calibre-server emit relatives links there?
Geremia is offline   Reply With Quote
Old 04-07-2025, 10:07 PM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Old 04-08-2025, 07:53 PM   #9
Geremia
Addict
Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!
 
Posts: 256
Karma: 100000
Join Date: Oct 2012
Device: Calibre
Quote:
Originally Posted by kovidgoyal View Post
Because the calibre server has no knowledge of what the hostname/ip address of the machine it is running on is.
Good point. Thanks. 🙏
Geremia is offline   Reply With Quote
Old 04-08-2025, 11:59 PM   #10
Geremia
Addict
Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!
 
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
Geremia is offline   Reply With Quote
Old 04-09-2025, 12:12 AM   #11
Geremia
Addict
Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!
 
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.
Geremia is offline   Reply With Quote
Old 04-09-2025, 01:12 AM   #12
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
mobileread at least works fine for me on linux.
Attached Thumbnails
Click image for larger version

Name:	screenshot.png
Views:	79
Size:	464.8 KB
ID:	214954  
kovidgoyal is offline   Reply With Quote
Old 04-09-2025, 11:46 AM   #13
Geremia
Addict
Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!Geremia rocks like Gibraltar!
 
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
Geremia is offline   Reply With Quote
Old 04-09-2025, 12:10 PM   #14
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Reply

Tags
get books, opds, plugins, stores


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 07:17 PM.


MobileRead.com is a privately owned, operated and funded community.