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