View Single Post
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: 261
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