Are you converting the books from the calibre directory? If so, you can extract the id from the folder location. Or parse the metadata.opf
It is also possible to use calibre-debug to run calibre's code to trigger a library convert, but that is above my paygrade -- I don't know how.