@ -244,8 +244,10 @@ class KoboLibrary(object):
written by the Kobo Desktop Edition application , including the list
of books , their titles , and the user ' s encryption key(s). " " "
def __init__ ( self , serials = [ ] ):
def __init__ ( self , serials = [ ] , device_path = None ):
print u " Obok v {0} \n Copyright © 2012-2015 Physisticated et al. " . format ( __version__ )
self . kobodir = ' '
kobodb = ' '
if sys . platform . startswith ( ' win ' ) :
if sys . getwindowsversion ( ) . major > 5 :
self . kobodir = os . environ [ ' LOCALAPPDATA ' ]
@ -254,20 +256,30 @@ class KoboLibrary(object):
self . kobodir = os . path . join ( self . kobodir , ' Kobo ' , ' Kobo Desktop Edition ' )
elif sys . platform . startswith ( ' darwin ' ) :
self . kobodir = os . path . join ( os . environ [ ' HOME ' ] , ' Library ' , ' Application Support ' , ' Kobo ' , ' Kobo Desktop Edition ' )
elif sys . platform . startswith ( ' linux ' ) :
# TODO TODO TODO needs change - fixed path to mount point
self . kobodir = ' /media/norbert/KOBOeReader/.kobo '
self . bookdir = os . path . join ( self . kobodir , ' kepub ' )
if sys . platform . startswith ( ' linux ' ) :
kobodb = os . path . join ( self . kobodir , ' KoboReader.sqlite ' )
else :
kobodb = os . path . join ( self . kobodir , ' Kobo.sqlite ' )
self . __sqlite = sqlite3 . connect ( kobodb )
self . __cursor = self . __sqlite . cursor ( )
self . _userkeys = [ ]
self . _books = [ ]
self . _volumeID = [ ]
self . _serials = serials
# desktop versions use Kobo.sqlite
kobodb = os . path . join ( self . kobodir , ' Kobo.sqlite ' )
if ( self . kobodir == ' ' or not ( os . path . exists ( kobodb ) ) ) :
# kobodb is either not set or not an existing file, that means that either:
# . windows or mac: desktop app is not installed
# . linux
# we check for a connected device and try to set up kobodir and kobodb from there
if ( device_path ) :
self . kobodir = os . path . join ( device_path , ' .kobo ' )
# devices use KoboReader.sqlite
kobodb = os . path . join ( self . kobodir , ' KoboReader.sqlite ' )
if ( not ( os . path . exists ( kobodb ) ) ) :
# give up here, we haven't found anything useful
self . kobodir = ' '
kobodb = ' '
if ( self . kobodir != ' ' ) :
self . bookdir = os . path . join ( self . kobodir , ' kepub ' )
self . __sqlite = sqlite3 . connect ( kobodb )
self . __cursor = self . __sqlite . cursor ( )
self . _userkeys = [ ]
self . _books = [ ]
self . _volumeID = [ ]
self . _serials = serials
def close ( self ) :
""" Closes the database used by the library. """
@ -326,8 +338,10 @@ class KoboLibrary(object):
for m in matches :
# print "m:",m[0]
macaddrs . append ( m [ 0 ] . upper ( ) )
elif sys . platform . startswith ( ' linux ' ) :
macaddrs . extend ( self . _serials )
# extend the list of macaddrs in any case with the serials
# cannot hurt ;-)
macaddrs . extend ( self . _serials )
return macaddrs