In what way doesn't it work? Is it not working at all? Or is only part of it not working? And there is no were near enough explanation of what you are actually trying to achieve. For example, are you trying to send a kepub when it exists, or only if it is the only format. Or the only format that is supported by the device.
But, I can think of two problems.
The test 'field('formats') == 'kepub'' will only return true if the only format you have for the book is kepub. If you have anything else as well, it will be false. But, the driver is probably set to send the kepub in preference to the epub or other format. And you will have problems if you have a kepub and a non-supported format such as AZW3. The kepub will be sent, but, the test will fail.
You probably want to use "'KEPUB' in field('formats')". That will return true if one of the formats for the books is kepub.
The other problem is that calibre sanitises the file path when sending the book. That means for the non-kepub path, the leading dot is probably going to be changed to an underscore.
|