@KevinH: I also think that the book title would make for a better file name and I use it as the file name in my Kindlegen wrapper. My file name generation method is not as elegant as your method, though, but it works.

I merely mentioned the the win32gui library, because the OP specifically asked for a method of getting the file name.
(Since this method cannot be easily ported to Linux/OSX and all Sigil plugins should ideally work on all three platforms, I wouldn't use it for plugins uploaded to MR.)