![]() |
#1 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Aug 2015
Device: none
|
calibre regexp for adding books
adding books to calibre, trying to get regexp for recognizing metadata
for books in this format: \[(?P<title>[^\]]+)\](?P<author>[^(]+)\(ZAP\.org\)\.pdf [Betty Crocker]Cooking is Fun(ZAP.org).pdf that regexp doesn't work. I think it's something about the first [^\]] If there is a bug, how do we contact the calibre author? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,367
Karma: 78877538
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
Try
Code:
\[(?P<title>.+)\](?P<author>.+)\( Code:
\[(?P<title>.+)\](?P<author>.+)\((?P<publisher>.*)\) |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Aug 2015
Device: none
|
That doesn't work because the first part of the regexp matches the whole string.
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,367
Karma: 78877538
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
I hate to say but I tested those out in the test interface and they worked like a charm.
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Aug 2015
Device: none
|
don't understand
\[(?P<author>.+)\](?P<title>.+)\(ZAP\.org\)\.pdf
does not work but \[(?P<author>.+)\](?P<title>.+)\( does work. I do not understand. Both should match [cooking]mytitle(ZAP.org).pdf The second one does work I just tested it. Also, why doesn't the first ".+" just match the whole expression following it until the end of the line? |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Aug 2015
Device: none
|
fails on the second period
\[(?P<author>.+)\](?P<title>.+)\(ZAP\.org\)\.
fails \[(?P<author>.+)\](?P<title>.+)\(ZAP\.org\) passes with filename [cooking]mytitle(ZAP.org).pdf it fails on the second period for some reason. |
![]() |
![]() |
![]() |
#7 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,939
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
the \.PDF is wrong
you do not include the extension part of a file name OTOH Name\(pdf\) would be included If you wanted that as part of the Title |
![]() |
![]() |
![]() |
#8 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Aug 2015
Device: none
|
fails on the second period
still, this does the job, and it has the added bonus
that it can match either .pdf .djvu or .epub formats |
![]() |
![]() |
![]() |
#9 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,939
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
![]() |
![]() |
![]() |
#10 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Aug 2015
Device: none
|
what I was looking for
\[(?P<author>.*?)\](?P<title>.*?)\(ZAP\.org\)
This works and is what I was originally looking for. You guys explained it. All the other solutions worked fine when you remove the ".pdf" from the end of the regexp, since it is matched automatically. Also, I did not understand that regexp match the longest string possible (by greedy default) but *cat still matches acat the * does not match the whole string, it backtracks. Could I please request that they put something more in the documentation about the automatic matching of extensions such as .pdf (or is this my fault for not RTFM?) |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Regexp for adding books failing | nvcleemp | Library Management | 10 | 08-29-2015 02:23 AM |
Regexp help for saving books | Phssthpok | Library Management | 3 | 06-24-2015 11:31 AM |
Calibre & Covers: Adding books through Calibre vs dragging and dropping? | VirgoGirl | Calibre | 12 | 06-08-2014 05:34 AM |
Adding books to Calibre... | jrickert | Library Management | 1 | 02-15-2013 02:41 AM |
Adding Books to Calibre | Canadian reader | Calibre | 0 | 11-20-2010 06:31 PM |