07-26-2012, 02:11 AM | #1 |
Junior Member
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. |
01-05-2013, 02:59 PM | #2 |
Junior Member
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 ? |
Advert | |
|
01-05-2013, 05:54 PM | #3 |
Addict
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. |
01-11-2013, 04:52 PM | #4 | |
Junior Member
Posts: 6
Karma: 18180
Join Date: Jan 2013
Device: Kobo Glo
|
Quote:
|
|
01-30-2013, 07:52 AM | #5 | |
Member
Posts: 17
Karma: 11628
Join Date: Oct 2012
Device: Kobo Touch
|
I'm having trouble running this on the kobo touch:
Quote:
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 |
|
Advert | |
|
06-10-2013, 06:42 PM | #6 |
Junior Member
Posts: 4
Karma: 10
Join Date: Sep 2010
Device: Kindle 3, Aura HD
|
This script works on Kobo Aura HD ?
|
06-10-2013, 07:52 PM | #7 |
Grand Sorcerer
Posts: 12,167
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.
|
01-27-2014, 09:59 AM | #8 |
Junior Member
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() |
|
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 |