![]() |
#1 |
Member
![]() Posts: 18
Karma: 10
Join Date: Jul 2011
Device: iPad
|
mi.timestamp set from imported book
Hi,
I am trying to add a bunch of books into calbre, but want the Date column in calibre to show the Last Modified Date of the existing book, so I can sort the books according to when I acquired them. I have modified the import_book function to set the mi.timestamp field to: mi.timestamp = datetime.fromtimestamp(os.path.getmtime(path)) This is in import_book (in database2.py) at: for path in formats: ext = os.path.splitext(path)[1][1:].lower() mi.timestamp = datetime.fromtimestamp(os.path.getmtime(path)) By adding prints I can see that the timestamp is changed. I use the calbredb add <directory where the existing books are> command. I delete all books and the metadata file from the calibre directory before running the command, so there should be no old data. But if I do: calibredb list -f title,timestamp command right after, I see that the timestamp date is still today's for all books. So something seems to overwrite my change, but I do not see what it could be? If I understand this correctly, calibredb calls command_add, which calls do_add, which calls (in my case) import_book_directory_multiple, which calls import_book. I just can not see what could be overwriting mi.timestamp after the import_book call. |
![]() |
![]() |
![]() |
#2 |
Member
![]() Posts: 18
Karma: 10
Join Date: Jul 2011
Device: iPad
|
I wonder if I understand this correctly: was calibre already doing what I wanted, but was then changed to the current behavior:
Release: 0.7.20 [24 Sep, 2010] New Features EPUB metadata: Don't read timestamp value from epubs as I am sick of closing bugs about adding books and having the Date not be today. Is my solution to just load an earlier version and use it for my (one time) import of my current library? Does epubs mean all formats. as my library is all .lit books? |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,170
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You should use
calibredb show_metadata --as-opf and then use a script to change the timestamp in the opf and then use calibredb set_metadata --from-opf |
![]() |
![]() |
![]() |
#4 |
Member
![]() Posts: 18
Karma: 10
Join Date: Jul 2011
Device: iPad
|
I considered that but rejected it as it would mean having to run the list command to get a mapping for ids and file names, run a dir command to get the modified dates, and then write a script that gets the metadata for an id to an odf file, looks up the file name from the list output, looks up the modified date from the dir output, converts the dir date format to the metadata file format, edits the metadata file to replace the timestamp, and restores the metadata from the odf file.
I am not a Windows programmer so pulling all of that together seemed a much bigger challenge than finding the one (or maybe two now) place(s) in calibre where the timestamp is set and changing that. Have I misunderstood the scope of the project or is there a shortcut that I am not seeing? I do know *nix shell scripting so I could maybe run the show_metadata for all files plus the dir command, then transfer the over five hundred files to *nix and get the dates changed there, then transfer the files back and do the set_metadata for all files. That would be more doable for me, but would still be awkward. So far I have kind of enjoyed learning Python and think I am close to the end already. Would you have any debugging hints on how to find where the timestamp may be overwritten? Or can I look at the 0.7.19 code to see how it was done before? |
![]() |
![]() |
![]() |
#5 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,170
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You dont need to do windows scripting for this. calibre provides its own python scripting environment.
calibre-debug -e I dont have the time to read through the code to tell you what you need to change, if you can discover it for yourself, go for it, otherwise use a script. |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modified date timestamp incorrect? | lgladen | Calibre | 12 | 08-19-2014 09:49 AM |
Set Calibre e-book viewer as default | Huisie | Library Management | 12 | 03-11-2011 08:53 PM |
Classic No book summary on my Calibre-imported Nook documents | alslush | Barnes & Noble NOOK | 4 | 01-26-2011 10:01 AM |
set the cover for the book from....batch | chrisix | Calibre | 6 | 07-08-2010 12:22 PM |
Any way to set book description? | kishante | Amazon Kindle | 0 | 10-19-2009 07:52 PM |