mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
commit
667d2c6a19
@ -822,7 +822,6 @@ application/x-lzh lzh
|
||||
application/x-lzx lzx
|
||||
application/x-maker book fb fbdoc fm frame frm maker
|
||||
application/x-mif mif
|
||||
application/x-mobipocket-ebook mobi prc
|
||||
application/x-ms-application application
|
||||
application/x-ms-wmd wmd
|
||||
application/x-ms-wmz wmz
|
||||
@ -1371,11 +1370,11 @@ application/x-sony-bbeb lrf lrx
|
||||
application/adobe-page-template+xml xpgt
|
||||
application/x-font-opentype otf
|
||||
application/x-font-truetype ttf
|
||||
application/x-mobipocket-ebook mobi prc azw
|
||||
application/x-mobipocket-ebook mobi prc
|
||||
application/vnd.amazon.ebook azw3 azw azw2 azw4
|
||||
application/x-cbz cbz
|
||||
application/x-cbr cbr
|
||||
application/x-cb7 cb7
|
||||
application/x-koboreader-ebook kobo
|
||||
image/wmf wmf
|
||||
application/ereader pdb
|
||||
|
||||
|
@ -54,6 +54,16 @@ def guess_all_extensions(*args, **kwargs):
|
||||
_init_mimetypes()
|
||||
return mimetypes.guess_all_extensions(*args, **kwargs)
|
||||
|
||||
|
||||
def guess_extension(*args, **kwargs):
|
||||
import mimetypes
|
||||
if not _mt_inited:
|
||||
_init_mimetypes()
|
||||
ext = mimetypes.guess_extension(*args, **kwargs)
|
||||
if not ext and args and args[0] == 'application/x-palmreader':
|
||||
ext = '.pdb'
|
||||
return ext
|
||||
|
||||
def get_types_map():
|
||||
import mimetypes
|
||||
if not _mt_inited:
|
||||
|
@ -1351,6 +1351,15 @@ class StoreEbookscomStore(StoreBase):
|
||||
formats = ['EPUB', 'LIT', 'MOBI', 'PDF']
|
||||
affiliate = True
|
||||
|
||||
# class StoreEbooksGratuitsStore(StoreBase):
|
||||
# name = 'EbooksGratuits.com'
|
||||
# description = u''
|
||||
# actual_plugin = 'calibre.gui2.store.stores.ebooksgratuits_plugin:EbooksGratuitsStore'
|
||||
#
|
||||
# headquarters = 'FR'
|
||||
# formats = ['EPUB', 'MOBI', 'PDF', 'PDB']
|
||||
# drm_free_only = True
|
||||
#
|
||||
# class StoreEBookShoppeUKStore(StoreBase):
|
||||
# name = 'ebookShoppe UK'
|
||||
# author = u'Charles Haley'
|
||||
@ -1645,6 +1654,7 @@ plugins += [
|
||||
StoreEbookNLStore,
|
||||
StoreEbookpointStore,
|
||||
StoreEbookscomStore,
|
||||
# StoreEbooksGratuitsStore,
|
||||
StoreEHarlequinStore,
|
||||
StoreEKnigiStore,
|
||||
StoreEscapeMagazineStore,
|
||||
|
@ -13,7 +13,7 @@ from lxml import etree
|
||||
|
||||
from PyQt4.Qt import QUrl
|
||||
|
||||
from calibre import browser
|
||||
from calibre import (browser, guess_extension)
|
||||
from calibre.gui2 import open_url
|
||||
from calibre.gui2.store import StorePlugin
|
||||
from calibre.gui2.store.search_result import SearchResult
|
||||
@ -29,7 +29,7 @@ class OpenSearchOPDSStore(StorePlugin):
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
if not hasattr(self, 'web_url'):
|
||||
return
|
||||
|
||||
|
||||
if external or self.config.get('open_external', False):
|
||||
open_url(QUrl(detail_item if detail_item else self.web_url))
|
||||
else:
|
||||
@ -52,7 +52,7 @@ class OpenSearchOPDSStore(StorePlugin):
|
||||
oquery.searchTerms = query
|
||||
oquery.count = max_results
|
||||
url = oquery.url()
|
||||
|
||||
|
||||
counter = max_results
|
||||
br = browser()
|
||||
with closing(br.open(url, timeout=timeout)) as f:
|
||||
@ -60,18 +60,18 @@ class OpenSearchOPDSStore(StorePlugin):
|
||||
for data in doc.xpath('//*[local-name() = "entry"]'):
|
||||
if counter <= 0:
|
||||
break
|
||||
|
||||
|
||||
counter -= 1
|
||||
|
||||
|
||||
s = SearchResult()
|
||||
|
||||
|
||||
s.detail_item = ''.join(data.xpath('./*[local-name() = "id"]/text()')).strip()
|
||||
|
||||
for link in data.xpath('./*[local-name() = "link"]'):
|
||||
rel = link.get('rel')
|
||||
href = link.get('href')
|
||||
type = link.get('type')
|
||||
|
||||
|
||||
if rel and href and type:
|
||||
if 'http://opds-spec.org/thumbnail' in rel:
|
||||
s.cover_url = href
|
||||
@ -81,15 +81,15 @@ class OpenSearchOPDSStore(StorePlugin):
|
||||
s.detail_item = href
|
||||
elif 'http://opds-spec.org/acquisition' in rel:
|
||||
if type:
|
||||
ext = mimetypes.guess_extension(type)
|
||||
ext = guess_extension(type)
|
||||
if ext:
|
||||
ext = ext[1:].upper().strip()
|
||||
s.downloads[ext] = href
|
||||
s.formats = ', '.join(s.downloads.keys()).strip()
|
||||
|
||||
|
||||
s.title = ' '.join(data.xpath('./*[local-name() = "title"]//text()')).strip()
|
||||
s.author = ', '.join(data.xpath('./*[local-name() = "author"]//*[local-name() = "name"]//text()')).strip()
|
||||
|
||||
|
||||
price_e = data.xpath('.//*[local-name() = "price"][1]')
|
||||
if price_e:
|
||||
price_e = price_e[0]
|
||||
@ -97,6 +97,6 @@ class OpenSearchOPDSStore(StorePlugin):
|
||||
price = ''.join(price_e.xpath('.//text()')).strip()
|
||||
s.price = currency_code + ' ' + price
|
||||
s.price = s.price.strip()
|
||||
|
||||
|
||||
|
||||
yield s
|
||||
|
Loading…
x
Reference in New Issue
Block a user