Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 07-26-2012, 02:11 AM   #1
deufeufeu
Junior Member
deufeufeu has a complete set of Star Wars action figures.deufeufeu has a complete set of Star Wars action figures.deufeufeu has a complete set of Star Wars action figures.deufeufeu has a complete set of Star Wars action figures.deufeufeu has a complete set of Star Wars action figures.
 
Posts: 1
Karma: 462
Join Date: Jul 2012
Device: Kobo Touch
Python script for building shelf automatically

Hi,
I just got a new Kobo Touch yesterday but the shelves feature seemed broken by the fact that I couldn't do a "check all" while searching to add books.
So I wrote a python script that will build shelves based on the directory in which your ebooks are located. For example if you have all IronThrones books in the folder /mnt/onboard/IronThrones it will make a shelf named IronThrones with all books of this folder added.
The script is here http://pastebin.com/hX2kqQ9b .
I don't have time to explain how to make it works, but I'm sure those having rooted their kobos will have no problem.
deufeufeu is offline   Reply With Quote
Old 01-05-2013, 02:59 PM   #2
DigitalWarS
Junior Member
DigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a Texan
 
Posts: 6
Karma: 18180
Join Date: Jan 2013
Device: Kobo Glo
GREAT JOB!

Anyone checked this out? This is a great feature I've been hoping for...
Yet.. I'm a newbie...
I'd need some help. Anyone available ?
DigitalWarS is offline   Reply With Quote
Advert
Old 01-05-2013, 05:54 PM   #3
ewphoenix123
Addict
ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'ewphoenix123 understands when you whisper 'The dog barks at midnight.'
 
Posts: 200
Karma: 42238
Join Date: Oct 2012
Device: Kobo: Glo, Aura , Aura H2O, Aura ONE, Forma, Elipsa
If you don't know what to do with this, you should probably just use calibre.

https://www.mobileread.com/forums/sho...d.php?t=193184

Very userfriendly and gives you the same result.
ewphoenix123 is offline   Reply With Quote
Old 01-11-2013, 04:52 PM   #4
DigitalWarS
Junior Member
DigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a TexanDigitalWarS might easily be mistaken for a Texan
 
Posts: 6
Karma: 18180
Join Date: Jan 2013
Device: Kobo Glo
Quote:
Originally Posted by ewphoenix123 View Post
If you don't know what to do with this, you should probably just use calibre.

https://www.mobileread.com/forums/sho...d.php?t=193184

Very userfriendly and gives you the same result.
Thank you very much for the advice, I'll try!
DigitalWarS is offline   Reply With Quote
Old 01-30-2013, 07:52 AM   #5
jkgeyti
Member
jkgeyti is a marvel to beholdjkgeyti is a marvel to beholdjkgeyti is a marvel to beholdjkgeyti is a marvel to beholdjkgeyti is a marvel to beholdjkgeyti is a marvel to beholdjkgeyti is a marvel to beholdjkgeyti is a marvel to beholdjkgeyti is a marvel to beholdjkgeyti is a marvel to beholdjkgeyti is a marvel to behold
 
Posts: 17
Karma: 11628
Join Date: Oct 2012
Device: Kobo Touch
I'm having trouble running this on the kobo touch:

Quote:
Traceback (most recent call last):
File "build-shelves.py", line 1, in <module>
import sqlite3
File "/mnt/onboard/.python/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/mnt/onboard/.python/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
I've installed python 2.7 from the KoboWeather download
I've tried downloading a couple of armel sqlite libs, but nothing that made any difference. Can anyone help me getting sqlite to run?

Thanks in advance
jkgeyti is offline   Reply With Quote
Advert
Old 06-10-2013, 06:42 PM   #6
evgeniy
Junior Member
evgeniy began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Sep 2010
Device: Kindle 3, Aura HD
This script works on Kobo Aura HD ?
evgeniy is offline   Reply With Quote
Old 06-10-2013, 07:52 PM   #7
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 12,166
Karma: 73448616
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
Should do; in effect all Kobo eReaders use the same basic software. But many people find using calibre to manage shelves a lot easier.
PeterT is offline   Reply With Quote
Old 01-27-2014, 09:59 AM   #8
lormac
Junior Member
lormac began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jan 2014
Device: kobo glo
wasn't working for kobo glo, I had to tweak it a little bit, here it is:

#!/usr/bin/python

import sqlite3

conn = sqlite3.connect('KoboReader.sqlite')

c = conn.cursor()

c.execute('''SELECT DISTINCT BookID FROM content''')

import re
re_path = re.compile(r'^file:///mnt/(?P<dev>[^/]*)/(?P<path>.*)/(?P<filename>[^/]*)$')
#(r'^file:///mnt/(?P<dev>)([^/]?P<path>)([^/]?P<filename>)$')
#(r'^file:///mnt/(?P<dev>[^/]*)/(?P<path>.*)/(?P<filename>[^/]*)$')

def splitpath(p):
m = re_path.match(p)
# print('qui',m)
return (m.group('dev'), m.group('path'), m.group('filename'))

database = {}
for v in c.fetchall():
p = v[0]
if p and p.startswith('file:///mnt/'):
dev, dirpath, filename = splitpath(p)
print(dev , dirpath , filename)
if (dev,dirpath) not in database:
database[(dev,dirpath)] = []
database[(dev,dirpath)].append(filename)

for dev,dirpath in database:
shelf = dirpath.replace('/','_')
print('shelf',shelf)
c.execute("SELECT * FROM Shelf WHERE InternalName='prova'")
print(c.fetchone())
c.execute("SELECT * FROM Shelf WHERE InternalName='%s'" % shelf)
temp = c.fetchone()
print(temp)
if temp is None:
c.execute("INSERT INTO Shelf VALUES ('2014-01-27T15:09:57Z', '%s', '%s', '2014-01-27T15:09:57Z', '%s', NULL, 'false', 'true', 'false')" % (shelf,shelf,shelf))
c.execute("SELECT * FROM Shelf WHERE InternalName='%s'" % shelf)
for f in database[(dev,dirpath)]:
fullname = u'file:///mnt/%s/%s/%s' % (dev,dirpath,f)
fullname = fullname.replace("'","''")
c.execute("SELECT * FROM ShelfContent WHERE ShelfName='%s' AND ContentId='%s'" % (shelf, fullname))
r = c.fetchone()
print(r)
if r is None:
c.execute("INSERT INTO ShelfContent VALUES ('%s','%s','2014-01-27T15:09:57Z','false','false')" % (shelf,fullname))

conn.commit()
c.close()
lormac is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to automatically populate a tag with the decade from the pubdate via python smoothrolla Library Management 5 11-19-2011 06:41 AM
how to use python script with windows xp tuufbiz1 Other formats 12 01-08-2011 08:22 AM
How do I get a shortcut for a Python script onto the taskbar in W7? Sydney's Mom Workshop 6 03-28-2010 08:11 PM
Nedd a little help with a python script gandor62 Calibre 1 08-07-2008 09:59 PM
Python script to create collections gwynevans Sony Reader Dev Corner 2 03-13-2008 12:29 PM


All times are GMT -4. The time now is 11:50 PM.


MobileRead.com is a privately owned, operated and funded community.