Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 07-07-2023, 12:44 AM   #1
geekraver
Addict
geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.
 
Posts: 364
Karma: 1035291
Join Date: Jul 2006
Location: Redmond, WA
Device: iPad Mini,Kindle Paperwhite
Adding new formats

Hi all

For each of my epub books, I have generated a summary as a.txt plaintext file, in the same folder. I'd like these to show up as an additional format in the entry for each book. However, I don't see how to do this. Using Library Maintenance I can find them as "Extra book formats" but the only option seems to be to delete them, not add them. Is there are good solution to this?

Thanks
G
geekraver is offline   Reply With Quote
Old 07-07-2023, 01:03 AM   #2
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,611
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
If you press shift-a, you can navigate to, and select the txt file. It is a recognised format so you should be able to add it easily.
Karellen is offline   Reply With Quote
Advert
Old 07-07-2023, 01:24 AM   #3
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,718
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
In future use the Add Books->Add an empty file to selected book records option to create the TXT file and then edit it.

Assuming the files are in the book folders and named summary.txt, you could open the book folder, drag-n-drop the summary.txt file onto the book details panel, and then delete the summary.txt file.

Added: tested in version 6.22.

BR

Last edited by BetterRed; 07-07-2023 at 01:27 AM.
BetterRed is offline   Reply With Quote
Old 07-08-2023, 11:43 AM   #4
geekraver
Addict
geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.
 
Posts: 364
Karma: 1035291
Join Date: Jul 2006
Location: Redmond, WA
Device: iPad Mini,Kindle Paperwhite
Thanks for these suggestions. Unfortunately I am really looking for a bulk method; I have a large library and doing this one by one would be pretty tedious.

Sounds like I would need to make a PR against Calibre.
geekraver is offline   Reply With Quote
Old 07-08-2023, 12:30 PM   #5
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by geekraver View Post
Hi all

For each of my epub books, I have generated a summary as a.txt plaintext file, in the same folder. I'd like these to show up as an additional format in the entry for each book. However, I don't see how to do this. Using Library Maintenance I can find them as "Extra book formats" but the only option seems to be to delete them, not add them. Is there are good solution to this?

Thanks
G
What you did, was add books 'Beneath the skirts' , so Calibre did not log them in(to the DB).

One possible way is to Use Copy to Library (delete after copy) to (a)NewLibrary

what is left is your problem books

The rest of my idea won't work, unless the file has the same (filename) naming as the real book , just with a .TXT extension
theducks is offline   Reply With Quote
Advert
Old 07-08-2023, 01:27 PM   #6
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,969
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
First, move all the text files out of your library folder. I suggest use a bulk-renamer to rename them to the folder name and then move them somewhere else. (They aren't registered in the Calibre database so it shouldn't cause any issues, as long as you're careful to limit it to the txts.)

Get Action Chains plugin. Make a new chain. Single-field edit on formats, this template (swapping out D:\Whatever\ for your somewhere else):

Code:
D:\Whatever\{title} ({id}).txt
This should detect the files and add them to your books. Test it on one or two to make sure it works as expected first.

EDIT: You may be able to skip the 'copying them all out and bulk-editing' by repliating the library path with a template. I don't know how to do this.

I don't know what will happen if the file doesn't exist.

Last edited by ownedbycats; 07-08-2023 at 01:39 PM.
ownedbycats is online now   Reply With Quote
Old 07-08-2023, 01:43 PM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by geekraver View Post
Sounds like I would need to make a PR against Calibre.
If you know how to code well enough to make a PR (github Pull Request) against calibre then you should be able to write a script that does the work. The script would walk the library looking for an a.txt file (or whatever it is named) in the book folder. When it finds one then it uses the calibre API method cache.add_format() method to add it as a book.

After verifying that the script worked, delete all the a.txt files.

This script might be a place to start.
Code:
import os
from calibre.library import db as DB

lib_path = sys.argv[1]
db = DB(path = lib_path)
cache = db.new_api
# Get the normalized library path
library_path = cache.backend.library_path

for book_id in cache.all_book_ids():
    # Construct the full path to the book folder
    path = os.path.join(library_path, cache.field_for('path', book_id).replace('/', os.sep))
    
    # Check if the file a.txt is in that folder
    txt_file = os.path.join(path, 'a.txt')
    if os.path.exists(txt_file):
        # It is. Add it as a format
        cache.add_format(book_id, 'txt', txt_file, run_hooks=False)
        print('added', txt_file)
You run it with calibre-debug -e script_file path_to_library

Of course, back up your library before running it!

Last edited by chaley; 07-08-2023 at 01:45 PM.
chaley is offline   Reply With Quote
Old 07-08-2023, 06:40 PM   #8
geekraver
Addict
geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.
 
Posts: 364
Karma: 1035291
Join Date: Jul 2006
Location: Redmond, WA
Device: iPad Mini,Kindle Paperwhite
That's a good option. It may still be worth a PR though; it seems like missing functionality in the database repair options. If I have a format not in the DB, it seems reasonable to want to either add it to the database or delete it from the file system; right now only the latter is available.
geekraver is offline   Reply With Quote
Old 07-08-2023, 06:54 PM   #9
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by geekraver View Post
That's a good option. It may still be worth a PR though; it seems like missing functionality in the database repair options. If I have a format not in the DB, it seems reasonable to want to either add it to the database or delete it from the file system; right now only the latter is available.
Working out whether some random file in the book folder is in fact an addable format is non-trivial. You must determine a) whether it is a valid format file type, b) determine if there isn't already such a format, c) determine that the book record actually exists, then d) whether the format will have the same name, which if true can cause data loss. Then you must e) add the format, and f) delete the "random file", both in a reliable (atomic) way. In the "check database" context you must do this on a folder-by-folder basis, controlling the fix options appropriately.

If you want to take this on then have at it, but bear in mind that in this case "you touched it last".
chaley is offline   Reply With Quote
Old 07-09-2023, 01:06 PM   #10
geekraver
Addict
geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.
 
Posts: 364
Karma: 1035291
Join Date: Jul 2006
Location: Redmond, WA
Device: iPad Mini,Kindle Paperwhite
Fair enough, you''ve scared me off. I'll stick to a script for my own purposes. :-)
geekraver is offline   Reply With Quote
Old 09-15-2023, 12:59 PM   #11
kjdavies
Zealot
kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.
 
Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by geekraver View Post
Hi all

For each of my epub books, I have generated a summary as a.txt plaintext file, in the same folder. I'd like these to show up as an additional format in the entry for each book. However, I don't see how to do this. Using Library Maintenance I can find them as "Extra book formats" but the only option seems to be to delete them, not add them. Is there are good solution to this?

Thanks
G
Out of curiosity, have you considered adding a custom column and storing the text there? That means you could see it with the other metadata and I believe would allow indexing of the text, so you could search it.

If you do this, you could script "read the text file and assign metadata field" (via calibredb, or possibly within calibre itself -- I haven't worked with action chains, and I'm still pretty new to python)

Last edited by kjdavies; 09-15-2023 at 01:04 PM.
kjdavies is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding the same book in different formats Rellwood Library Management 3 01-04-2021 11:03 PM
Adding formats to a book? edhasted Conversion 3 05-28-2013 02:49 PM
Problem adding additional formats Loosheesh Calibre 16 05-12-2013 08:06 AM
Adding formats to catalog kamanza Library Management 5 09-14-2012 02:25 PM
Adding the same title, but different formats... Frodolass Calibre 3 12-13-2009 05:44 AM


All times are GMT -4. The time now is 09:25 AM.


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