View Single Post
Old 10-07-2024, 10:08 PM   #17
camifran
Hija del sol luminoso ☀️
camifran plays well with otherscamifran plays well with otherscamifran plays well with otherscamifran plays well with otherscamifran plays well with otherscamifran plays well with otherscamifran plays well with otherscamifran plays well with otherscamifran plays well with otherscamifran plays well with otherscamifran plays well with others
 
Posts: 8
Karma: 2754
Join Date: Feb 2017
Location: Chile
Device: Kindle Voyage, Kobo Sage, TCL Nxtpaper 11
Quote:
Originally Posted by calk View Post
I'm on mobile so apologies first up for formatting. My first post looks like it failed so trying again. I think you can do this with Calibre's template language and the kobo touch extended plugin.

I'm not a programmer and the documentation on Calibre functions was hard to follow but I've put this together.

> Modify and use this in the device save tenplate settings (Kobo touch extended plugin - save output)

program:
# Template function to check if PDF is the only format
# Use with Kobo plugin to store PDF in a different location to epubs
# Can be modified to include CBR/CBZ as well

book_formats = field('formats');
format_length = count(book_formats,',');
found_format = str_in_list(book_formats, ',', '1', '0');
save_path = '';
if format_length == 1 && found_format == 1 then
save_path = '.pdfs/{author_sort} - {series}{series_index:0>2s| | - }{title} - {authors}'
return save_path
else
save_path = 'books/{author_sort}/{series}/{series}{series_index:0>2s| | - }{title} - {authors}'
return save_path
fi

> Modify this and use this in the kobo touch extended plugin (in the extended settings tab for kepubification) to stop PDFs being kepubified

program:
# Template function to lookup CBZ or CBR Manga file formats
# Use with Kobo plugin where 'epubs' by KCC have been added to the format
# Use to avoid having Kobo plugin convert KCC kepub to kepub
# This uses a custom shelf to check if a book is either in the shelf or if there is a manga file as well - if either are true then don't kepubify
# Can be modified to exclude PDFs as well
book_formats = field('formats');
shelfs = field('#calibre_web_shelf');
found_format = str_in_list(book_formats, ',', 'cbr', 'found cbr', 'cbz', 'found cbz', 'no comic found');
found_shelf = str_in_list(shelfs, ',', 'Graphic-novels', 'found shelf','no shelf found');
if str_in_list(book_formats, ',', 'cbr', 'found cbr', 'cbz', 'found cbz', 'no comic found') || str_in_list(shelfs, ',', 'Graphic-novels', 'found shelf','no shelf found') then
return ''
else
return 'true'
fi
Hi! I tried this but I get the following error:

EXCEPTION: Formatter: if statement: expected 'fi', found 'return' near Unknown on line 12

Could you help me?

I would also want to be able to save both a kepub and pdf version of the same book separately (considering I have both versions beforehand).

Thank you!
camifran is offline   Reply With Quote