From 0780b49eacc8a5261f17b75e64f40b641407e5f5 Mon Sep 17 00:00:00 2001 From: Florent FAYOLLE Date: Wed, 15 Aug 2012 20:39:28 +0200 Subject: [PATCH] add the store ebooksgratuits.com; add mimetypes epub, mobi and pdb(eReader) --- resources/compiled_coffeescript.zip | Bin 52826 -> 52826 bytes src/calibre/__init__.py | 10 ++++++++++ src/calibre/customize/builtins.py | 10 ++++++++++ src/calibre/gui2/store/opensearch_store.py | 4 ++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index 43781bf7488ac2e2c238617d18bc298991ed34ea..2e85fd0b33a9da3fee451b73222d175c10c50b1f 100644 GIT binary patch delta 133 zcmcaLhxyhVX1)M#W)=|!5YV2@@3{Gc%W7U`o!R^wdGEWh0BOg~^Ml+4AgotO(g_e2 z=i$qod?57-MmH47co`VVcqhL)qdqz6tO!W+GsH-cNs}L( lkz#t}GFkDQ=w!jOB49%&7oGJ0n>l&kS!b}3lUdJ&0st#iH;VuO diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index a0f3b49498..e64cfa30c7 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -40,6 +40,9 @@ def _init_mimetypes(): global _mt_inited import mimetypes mimetypes.init([P('mime.types')]) + mimetypes.add_type('application/epub+zip', '.epub') + mimetypes.add_type('application/x-mobipocket-ebook', '.mobi') + mimetypes.add_type('application/x-palmreader', '.pdb') _mt_inited = True def guess_type(*args, **kwargs): @@ -54,6 +57,13 @@ 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() + return mimetypes.guess_extension(*args, **kwargs) + def get_types_map(): import mimetypes if not _mt_inited: diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 6f443a0013..da9af537f1 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -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' @@ -1644,6 +1653,7 @@ plugins += [ StoreEbookNLStore, StoreEbookpointStore, StoreEbookscomStore, + StoreEbooksGratuitsStore, StoreEHarlequinStore, StoreEKnigiStore, StoreEscapeMagazineStore, diff --git a/src/calibre/gui2/store/opensearch_store.py b/src/calibre/gui2/store/opensearch_store.py index a66418aa77..ada37de3c1 100644 --- a/src/calibre/gui2/store/opensearch_store.py +++ b/src/calibre/gui2/store/opensearch_store.py @@ -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 @@ -81,7 +81,7 @@ 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