Get Books: Add biblio.bg store

This commit is contained in:
Kovid Goyal 2012-05-02 19:55:34 +05:30
commit 7aeb6157f6
2 changed files with 64 additions and 0 deletions

View File

@ -1254,6 +1254,15 @@ class StoreBeWriteStore(StoreBase):
headquarters = 'US' headquarters = 'US'
formats = ['EPUB', 'MOBI', 'PDF'] formats = ['EPUB', 'MOBI', 'PDF']
class StoreBiblioStore(StoreBase):
name = u'Библио.бг'
author = 'Alex Stanev'
description = u'Електронна книжарница за книги и списания във формати ePUB и PDF. Част от заглавията са с активна DRM защита.'
actual_plugin = 'calibre.gui2.store.stores.biblio_plugin:BiblioStore'
headquarters = 'BG'
formats = ['EPUB, PDF']
class StoreBookotekaStore(StoreBase): class StoreBookotekaStore(StoreBase):
name = 'Bookoteka' name = 'Bookoteka'
author = u'Tomasz Długosz' author = u'Tomasz Długosz'
@ -1597,6 +1606,7 @@ plugins += [
StoreBNStore, StoreBNStore,
StoreBeamEBooksDEStore, StoreBeamEBooksDEStore,
StoreBeWriteStore, StoreBeWriteStore,
StoreBiblioStore,
StoreBookotekaStore, StoreBookotekaStore,
StoreChitankaStore, StoreChitankaStore,
StoreDieselEbooksStore, StoreDieselEbooksStore,

View File

@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
from __future__ import (unicode_literals, division, absolute_import, print_function)
__license__ = 'GPL 3'
__copyright__ = '2012, Alex Stanev <alex@stanev.org>'
__docformat__ = 'restructuredtext en'
import re
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 BiblioStore(BasicStoreConfig, OpenSearchOPDSStore):
open_search_url = 'http://biblio.bg/feed.opds.php'
web_url = 'http://biblio.bg/'
def search(self, query, max_results=10, timeout=60):
# check for cyrillic symbols before performing search
uquery = unicode(query.strip(), 'utf-8')
reObj = re.search(u'^[а-яА-Я\\d\\s]{3,}$', uquery)
if not reObj:
return
for s in OpenSearchOPDSStore.search(self, query, max_results, timeout):
yield s
def get_details(self, search_result, timeout):
# get format and DRM status
from calibre import browser
from contextlib import closing
from lxml import html
br = browser()
with closing(br.open(search_result.detail_item, timeout=timeout)) as nf:
idata = html.fromstring(nf.read())
search_result.formats = ''
if idata.xpath('.//span[@class="format epub"]'):
search_result.formats = 'EPUB'
if idata.xpath('.//span[@class="format pdf"]'):
if search_result.formats == '':
search_result.formats = 'PDF'
else:
search_result.formats.join(', PDF')
if idata.xpath('.//span[@class="format nodrm-icon"]'):
search_result.drm = SearchResult.DRM_UNLOCKED
else:
search_result.drm = SearchResult.DRM_LOCKED
return True