mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Preliminary support for the Netronix EB600
This commit is contained in:
parent
b1d6b831d9
commit
0847fcfb2d
@ -13,12 +13,14 @@ def devices():
|
|||||||
from calibre.devices.kindle.driver import KINDLE
|
from calibre.devices.kindle.driver import KINDLE
|
||||||
from calibre.devices.kindle.driver import KINDLE2
|
from calibre.devices.kindle.driver import KINDLE2
|
||||||
from calibre.devices.blackberry.driver import BLACKBERRY
|
from calibre.devices.blackberry.driver import BLACKBERRY
|
||||||
return (PRS500, PRS505, PRS700, CYBOOKG3, KINDLE, KINDLE2, BLACKBERRY)
|
from calibre.devices.eb600.driver import EB600
|
||||||
|
return (PRS500, PRS505, PRS700, CYBOOKG3, KINDLE, KINDLE2,
|
||||||
|
BLACKBERRY, EB600)
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
DAY_MAP = dict(Sun=0, Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6)
|
DAY_MAP = dict(Sun=0, Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6)
|
||||||
MONTH_MAP = dict(Jan=1, Feb=2, Mar=3, Apr=4, May=5, Jun=6, Jul=7, Aug=8, Sep=9, Oct=10, Nov=11, Dec=12)
|
MONTH_MAP = dict(Jan=1, Feb=2, Mar=3, Apr=4, May=5, Jun=6, Jul=7, Aug=8, Sep=9, Oct=10, Nov=11, Dec=12)
|
||||||
INVERSE_DAY_MAP = dict(zip(DAY_MAP.values(), DAY_MAP.keys()))
|
INVERSE_DAY_MAP = dict(zip(DAY_MAP.values(), DAY_MAP.keys()))
|
||||||
INVERSE_MONTH_MAP = dict(zip(MONTH_MAP.values(), MONTH_MAP.keys()))
|
INVERSE_MONTH_MAP = dict(zip(MONTH_MAP.values(), MONTH_MAP.keys()))
|
||||||
|
|
||||||
|
@ -10,37 +10,36 @@ from itertools import cycle
|
|||||||
from calibre.devices.errors import FreeSpaceError
|
from calibre.devices.errors import FreeSpaceError
|
||||||
from calibre.devices.usbms.driver import USBMS
|
from calibre.devices.usbms.driver import USBMS
|
||||||
import calibre.devices.cybookg3.t2b as t2b
|
import calibre.devices.cybookg3.t2b as t2b
|
||||||
from calibre.devices.errors import FreeSpaceError
|
|
||||||
|
|
||||||
class CYBOOKG3(USBMS):
|
class CYBOOKG3(USBMS):
|
||||||
# Ordered list of supported formats
|
# Ordered list of supported formats
|
||||||
# Be sure these have an entry in calibre.devices.mime
|
# Be sure these have an entry in calibre.devices.mime
|
||||||
FORMATS = ['mobi', 'prc', 'html', 'pdf', 'rtf', 'txt']
|
FORMATS = ['mobi', 'prc', 'html', 'pdf', 'rtf', 'txt']
|
||||||
|
|
||||||
VENDOR_ID = [0x0bda, 0x3034]
|
VENDOR_ID = [0x0bda, 0x3034]
|
||||||
PRODUCT_ID = [0x0703, 0x1795]
|
PRODUCT_ID = [0x0703, 0x1795]
|
||||||
BCD = [0x110, 0x132]
|
BCD = [0x110, 0x132]
|
||||||
|
|
||||||
VENDOR_NAME = 'BOOKEEN'
|
VENDOR_NAME = 'BOOKEEN'
|
||||||
WINDOWS_MAIN_MEM = 'CYBOOK_GEN3__-FD'
|
WINDOWS_MAIN_MEM = 'CYBOOK_GEN3__-FD'
|
||||||
WINDOWS_CARD_MEM = 'CYBOOK_GEN3__-SD'
|
WINDOWS_CARD_MEM = 'CYBOOK_GEN3__-SD'
|
||||||
|
|
||||||
OSX_MAIN_MEM = 'Bookeen Cybook Gen3 -FD Media'
|
OSX_MAIN_MEM = 'Bookeen Cybook Gen3 -FD Media'
|
||||||
OSX_CARD_MEM = 'Bookeen Cybook Gen3 -SD Media'
|
OSX_CARD_MEM = 'Bookeen Cybook Gen3 -SD Media'
|
||||||
|
|
||||||
MAIN_MEMORY_VOLUME_LABEL = 'Cybook Gen 3 Main Memory'
|
MAIN_MEMORY_VOLUME_LABEL = 'Cybook Gen 3 Main Memory'
|
||||||
STORAGE_CARD_VOLUME_LABEL = 'Cybook Gen 3 Storage Card'
|
STORAGE_CARD_VOLUME_LABEL = 'Cybook Gen 3 Storage Card'
|
||||||
|
|
||||||
EBOOK_DIR_MAIN = "eBooks"
|
EBOOK_DIR_MAIN = "eBooks"
|
||||||
EBOOK_DIR_CARD = "eBooks"
|
EBOOK_DIR_CARD = "eBooks"
|
||||||
THUMBNAIL_HEIGHT = 144
|
THUMBNAIL_HEIGHT = 144
|
||||||
SUPPORTS_SUB_DIRS = True
|
SUPPORTS_SUB_DIRS = True
|
||||||
|
|
||||||
def upload_books(self, files, names, on_card=False, end_session=True,
|
def upload_books(self, files, names, on_card=False, end_session=True,
|
||||||
metadata=None):
|
metadata=None):
|
||||||
if on_card and not self._card_prefix:
|
if on_card and not self._card_prefix:
|
||||||
raise ValueError(_('The reader has no storage card connected.'))
|
raise ValueError(_('The reader has no storage card connected.'))
|
||||||
|
|
||||||
if not on_card:
|
if not on_card:
|
||||||
path = os.path.join(self._main_prefix, self.EBOOK_DIR_MAIN)
|
path = os.path.join(self._main_prefix, self.EBOOK_DIR_MAIN)
|
||||||
else:
|
else:
|
||||||
@ -59,17 +58,17 @@ class CYBOOKG3(USBMS):
|
|||||||
|
|
||||||
if on_card and size > self.free_space()[2] - 1024*1024:
|
if on_card and size > self.free_space()[2] - 1024*1024:
|
||||||
raise FreeSpaceError(_("There is insufficient free space on the storage card"))
|
raise FreeSpaceError(_("There is insufficient free space on the storage card"))
|
||||||
if not on_card and size > self.free_space()[0] - 2*1024*1024:
|
if not on_card and size > self.free_space()[0] - 2*1024*1024:
|
||||||
raise FreeSpaceError(_("There is insufficient free space in main memory"))
|
raise FreeSpaceError(_("There is insufficient free space in main memory"))
|
||||||
|
|
||||||
paths = []
|
paths = []
|
||||||
names = iter(names)
|
names = iter(names)
|
||||||
metadata = iter(metadata)
|
metadata = iter(metadata)
|
||||||
|
|
||||||
for infile in files:
|
for infile in files:
|
||||||
newpath = path
|
newpath = path
|
||||||
mdata = metadata.next()
|
mdata = metadata.next()
|
||||||
|
|
||||||
if self.SUPPORTS_SUB_DIRS:
|
if self.SUPPORTS_SUB_DIRS:
|
||||||
if 'tags' in mdata.keys():
|
if 'tags' in mdata.keys():
|
||||||
for tag in mdata['tags']:
|
for tag in mdata['tags']:
|
||||||
@ -80,47 +79,47 @@ class CYBOOKG3(USBMS):
|
|||||||
|
|
||||||
if not os.path.exists(newpath):
|
if not os.path.exists(newpath):
|
||||||
os.makedirs(newpath)
|
os.makedirs(newpath)
|
||||||
|
|
||||||
filepath = os.path.join(newpath, names.next())
|
filepath = os.path.join(newpath, names.next())
|
||||||
paths.append(filepath)
|
paths.append(filepath)
|
||||||
|
|
||||||
if hasattr(infile, 'read'):
|
if hasattr(infile, 'read'):
|
||||||
infile.seek(0)
|
infile.seek(0)
|
||||||
|
|
||||||
dest = open(filepath, 'wb')
|
dest = open(filepath, 'wb')
|
||||||
shutil.copyfileobj(infile, dest, 10*1024*1024)
|
shutil.copyfileobj(infile, dest, 10*1024*1024)
|
||||||
|
|
||||||
dest.flush()
|
dest.flush()
|
||||||
dest.close()
|
dest.close()
|
||||||
else:
|
else:
|
||||||
shutil.copy2(infile, filepath)
|
shutil.copy2(infile, filepath)
|
||||||
|
|
||||||
coverdata = None
|
coverdata = None
|
||||||
if 'cover' in mdata.keys():
|
if 'cover' in mdata.keys():
|
||||||
if mdata['cover'] != None:
|
if mdata['cover'] != None:
|
||||||
coverdata = mdata['cover'][2]
|
coverdata = mdata['cover'][2]
|
||||||
|
|
||||||
t2bfile = open('%s_6090.t2b' % (os.path.splitext(filepath)[0]), 'wb')
|
t2bfile = open('%s_6090.t2b' % (os.path.splitext(filepath)[0]), 'wb')
|
||||||
t2b.write_t2b(t2bfile, coverdata)
|
t2b.write_t2b(t2bfile, coverdata)
|
||||||
t2bfile.close()
|
t2bfile.close()
|
||||||
|
|
||||||
return zip(paths, cycle([on_card]))
|
return zip(paths, cycle([on_card]))
|
||||||
|
|
||||||
def delete_books(self, paths, end_session=True):
|
def delete_books(self, paths, end_session=True):
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
|
|
||||||
filepath, ext = os.path.splitext(path)
|
filepath, ext = os.path.splitext(path)
|
||||||
|
|
||||||
# Delete the ebook auxiliary file
|
# Delete the ebook auxiliary file
|
||||||
if os.path.exists(filepath + '.mbp'):
|
if os.path.exists(filepath + '.mbp'):
|
||||||
os.unlink(filepath + '.mbp')
|
os.unlink(filepath + '.mbp')
|
||||||
|
|
||||||
# Delete the thumbnails file auto generated for the ebook
|
# Delete the thumbnails file auto generated for the ebook
|
||||||
if os.path.exists(filepath + '_6090.t2b'):
|
if os.path.exists(filepath + '_6090.t2b'):
|
||||||
os.unlink(filepath + '_6090.t2b')
|
os.unlink(filepath + '_6090.t2b')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.removedirs(os.path.dirname(path))
|
os.removedirs(os.path.dirname(path))
|
||||||
except:
|
except:
|
||||||
|
2
src/calibre/devices/eb600/__init__.py
Executable file
2
src/calibre/devices/eb600/__init__.py
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
31
src/calibre/devices/eb600/driver.py
Executable file
31
src/calibre/devices/eb600/driver.py
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
||||||
|
'''
|
||||||
|
Device driver for Amazon's Kindle
|
||||||
|
'''
|
||||||
|
|
||||||
|
from calibre.devices.usbms.driver import USBMS
|
||||||
|
|
||||||
|
class EB600(USBMS):
|
||||||
|
# Ordered list of supported formats
|
||||||
|
FORMATS = ['epub', 'pdf']
|
||||||
|
|
||||||
|
VENDOR_ID = [0x1f85]
|
||||||
|
PRODUCT_ID = [0x1688]
|
||||||
|
BCD = [0x110]
|
||||||
|
|
||||||
|
VENDOR_NAME = 'NETRONIX'
|
||||||
|
WINDOWS_MAIN_MEM = 'EBOOK'
|
||||||
|
WINDOWS_CARD_MEM = 'CARD_STORAGE'
|
||||||
|
|
||||||
|
OSX_MAIN_MEM = 'EB600 Internal Storage Media'
|
||||||
|
OSX_CARD_MEM = 'EB600 Card Storage Media'
|
||||||
|
|
||||||
|
MAIN_MEMORY_VOLUME_LABEL = 'EB600 Main Memory'
|
||||||
|
STORAGE_CARD_VOLUME_LABEL = 'EB600 Storage Card'
|
||||||
|
|
||||||
|
EBOOK_DIR_MAIN = ''
|
||||||
|
EBOOK_DIR_CARD = ''
|
||||||
|
SUPPORTS_SUB_DIRS = True
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user