![]() |
#1 |
Enthusiast
![]() ![]() Posts: 34
Karma: 100
Join Date: Oct 2014
Device: Likebook Mars
|
Is there any way to backup/restore reading progress to Calibre?
I know I asked this a year or two ago and the answer was basically no, but curious if something has changed since then. Back when I was using my old Kobo H2O I always liked being able to automatically backup all my reading progress to Calibre each time I plugged it in using KoboUtilities plugin, or push it all back to the device when necessary. Even integrated with goodreads so it would update my finished status on there when it did so... Kinda miss the functionality since switching to my Likebook Mars and using KOReader as the main reader app.
Experimented around a bit with the auto-sync feature built into KOReader which could maybe potentially serve a similar purpose but I think it's limited to the specific book you're reading? Or is there a way to push reading progress for your entire library at once? I usually leave wifi off since it has a large impact on battery life for my device so updates are kind of sporadic and mostly happen when I specifically go out of my way to let it sync. Also doesn't necessarily have to go through Calibre (though that would be preferred) but if someone knows of another good quick way to backup/restore your reading positions and started/finished/etc status for your entire library at once that might be good enough for me for now, since I could probably just use KOReader on whatever new device I get in the future anyway and import that data. Edit: Oh, actually looking at the contents of my SD card it looks like that data is stored in a pretty easily readable form in the same folder as the epub files... I guess backing that up should be easy enough. Last edited by OrangeFlavored; 03-12-2020 at 03:36 PM. |
![]() |
![]() |
![]() |
#2 |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
The <book_filename>.sdr folders (stored in the same directory as the books) should contain that info.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Enthusiast
![]() ![]() Posts: 34
Karma: 100
Join Date: Oct 2014
Device: Likebook Mars
|
Yeah for now just automated the backup process using Windows Task Scheduler, figured I'd share my process if anyone else is interested in doing so:
First open up Event Viewer and go to Applications and Services -> Microsoft -> Windows -> DriverFrameworks-UserMode and right click Operational, Enable Log. Then plug your device in, refresh the list, find a bunch of Verbose items that popped up, go to Details, copy down the InstanceId and paste it into this: Code:
<QueryList> <Query Id="0" Path="Microsoft-Windows-DriverFrameworks-UserMode/Operational"> <Select Path="Microsoft-Windows-DriverFrameworks-UserMode/Operational">*[System[Provider[@Name='Microsoft-Windows-DriverFrameworks-UserMode'] and (Level=5) and Task = 33 and (EventID=2004)]] and *[UserData[UMDFHostAddDeviceBegin[(InstanceId='PASTE_YOUR_INSTANCE_ID_HERE')]]]</Select> </Query> </QueryList> Code:
adb shell mkdir /sdcard/Download/Temp adb shell cp -r /sdcard/Books/*.sdr/ /sdcard/Download/Temp adb pull /sdcard/Download/Temp G:\Backup\KOReader\%date:~-8,4%_%date:~-14,2%_%date:~-11,2% adb shell rm -r /sdcard/Download/Temp If you can't or don't want to enable USB debugging but have some experience with Python I know there's a few libraries there such as PyMTP that allow you to copy files over from a MTP device, that might work out for you. Also if your device doesn't use MTP and just mounts on a normal drive letter then all that is irrelevant and you can just have your batch file copy the folders over as normal. Last edited by OrangeFlavored; 03-12-2020 at 07:09 PM. |
![]() |
![]() |
![]() |
#4 |
cosiñeiro
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
|
As ilovejedd said the info is stored on a sidecar dir, they will be stored in koreader/history if the path is read only.
KOReader was hacked on top of a filemanager and lacks the concept of "library".The best way to emulate one is to parse all metadata. This will give you info for any book that was opened at least once. https://github.com/noembryo/KoHighlights is a standalone tool that does that very well (iterate over a path looking for metadata). |
![]() |
![]() |
![]() |
#5 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
On a tangentially related note, there's also https://github.com/koreader/koreader/issues/3814 which might warrant another poke to see if @onde2rock got stuff back in working order.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Enthusiast
![]() ![]() Posts: 34
Karma: 100
Join Date: Oct 2014
Device: Likebook Mars
|
Experimented around with Calibre's database API as mentioned here and managed to set up a little CLI plugin to pull read percentage and last read time from a folder full of KOreader metadata into Calibre.
Code:
import os import datetime from dateutil.tz import tzlocal from calibre.customize import Plugin from calibre.library import db class KoreaderPercentSync(Plugin): name = 'KOreader Percent Sync' description = 'Sync KOReader Percentage from command line' supported_platforms = ['windows', 'osx', 'linux'] author = 'Orange' version = (0, 0, 3) minimum_calibre_version = (0, 7, 53) def cli_main(self, args): target = args[1] database = db(args[2]).new_api to_update_percent, to_update_date = {}, {} for root, dirs, files in os.walk(target): for target_folder in dirs: book = int(target_folder[:-4].rpartition(" - ")[2]) calibre_percent = database.field_for("#perc_read", book) if calibre_percent != 1: percent, date = parse_metadata(os.path.join(root, target_folder, "metadata.epub.lua")) if not calibre_percent or abs(calibre_percent - percent) > 0.00001: to_update_percent[book] = percent to_update_date[book] = date database.set_field("#perc_read", to_update_percent) database.set_field("#last_read", to_update_date) def parse_metadata(meta_file): with open(meta_file, "r") as metadata: percent = 0 date = datetime.datetime.fromtimestamp(os.path.getmtime(meta_file), tzlocal()) for line in metadata: read_line = line.strip() if read_line.startswith("[\"percent_finished\"]"): percent = read_line[23:-1] elif read_line == "[\"status\"] = \"complete\"": return (1, date) return (float(percent), date) Last edited by OrangeFlavored; 05-27-2020 at 03:12 PM. |
![]() |
![]() |
![]() |
#8 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,742
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
At a quick glance that looks fairly cross-platform btw?
|
![]() |
![]() |
![]() |
#9 | |
Enthusiast
![]() ![]() Posts: 34
Karma: 100
Join Date: Oct 2014
Device: Likebook Mars
|
Quote:
Yeah, it probably would work on other platforms too, though I only tried it on windows. Last edited by OrangeFlavored; 05-06-2020 at 03:49 PM. |
|
![]() |
![]() |
![]() |
#10 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Oh, right, I was assuming you were working on a partition exported over USBMS. But Android, of course, means that, nope, not going to happen ;p.
|
![]() |
![]() |
![]() |
#11 |
Enthusiast
![]() ![]() Posts: 34
Karma: 100
Join Date: Oct 2014
Device: Likebook Mars
|
Turns out timestamps can be preserved if I tar everything before pulling it, so doing that now, seems faster this way anyway since I only have to pull a single file rather than hundreds of individual ones. Though I do have to be careful not to let the path get over 100 characters or it gives an error. Ran into that with a few files but for now just shortened everything enough that it's not a problem anymore.
Also changed my send to device template to append the book id to the end of each book so there's no need to search the database for each book based on title/author anymore, just uses the ID from the end of the folder name to lookup the book directly. I considered trying to mess with upload_books() to add this info to the metadata.epub.lua instead, but it seemed like generating this file for every book in my library at upload time might not be desirable for the moment so I put that idea off for now. Using a plugboard and writing the calibre db ID into the ebook's metadata could also be a potential option I guess, though depends on whether you consider it less intrusive to mess with the ebook's metadata vs sticking something in its filename. Personally I think the filename thing is fine for now since it also makes it less likely I run into an unintentional filename collision on my device or something. Last edited by OrangeFlavored; 05-08-2020 at 05:16 AM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Kobo] Reading progress not updated in calibre anymore | 69carat | Devices | 2 | 01-16-2020 11:01 PM |
Backup Kindle reading position to Calibre library | MagratG | Calibre | 3 | 04-11-2018 12:30 PM |
[Old Thread] Calibre Backup and Restore | Timber | Calibre | 21 | 06-01-2011 07:31 PM |
Backup Restore Application | WzeroMN | Nook Developer's Corner | 6 | 05-20-2011 12:28 AM |
iLiad Backup / Restore ? | ce3po | iRex Developer's Corner | 3 | 11-18-2007 05:53 PM |