View Single Post
Old 12-23-2025, 10:47 AM   #10
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,286
Karma: 16800000
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Quote:
Originally Posted by kovidgoyal View Post
Not sure what AI you were using but after getting the file name, this is literally 5 lines of code.

Code:
from calibre.ebooks.oeb.polish import get_container
from calibre.ebooks.oeb.polish.replace import remove_links_to
c = get_container(path, tweak_mode=True)
def predicate(name, href, fragment=None): return name == fname_to_remove
remove_links_to(c, 
c.remove_item(name_to_remove)
c.commit(path_to_save_to)
@Kovid, if you're still reading this thread...

I've been using the calibre get_container function for many years and I'm slightly concerned by this tweak_mode=True parameter. I'm pretty sure I've never used it (at least not knowingly). Yet I have, over the years, written various plugins (User and Editor) which appeared to work OK.

What have I missed? Can you explain, in simple terms, when it should be used and when it's OK to leave it as default tweak_mode=False. Many thanks.
jackie_w is offline   Reply With Quote