View Single Post
Old 04-26-2012, 11:01 AM   #206
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,733
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
@Dastral.

It seems to me you have multiple issues here you are rolling into one - I suggest you break them down into their parts.

For a start - you want a regex for adding books to calibre when their name looks like:
John Doe - End Of Time 1 - The Start.epub
John Doe - The Ever War - First Years 1 - Alex Smith.epub

This is the regex I use for this (from the Quick preferences plugin):
Code:
^(?P<author>((?!\s-\s).)+)\s-\s(?:(?:\[\s*)?(?P<series>.+)\s(?P<series_index>[\d\.]+)(?:\s*\])?\s-\s)?(?P<title>[^(]+)(?:\(.*\))?
That gives me the following results:

Title: The Start
Author: John Doe
Series: End Of Time [1]

Title: Alex Smith
Author: John Doe
Series: The Ever War - First Years [1]

Which I believe is the correct metadata for the books that you wanted.

As for the second step, I don't know if there is an "easy" way for what you want to achieve. You can do something like this:
Code:
{series:re(-,)} {series_index}
Which will strip out the - signs. But I don't know if the calibre template language supports substituting back in carriage returns, certainly my attempts didn't work.
kiwidude is offline   Reply With Quote