View Single Post
Old 10-14-2013, 07:18 PM   #1
At_Libitum
Addict
At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.At_Libitum ought to be getting tired of karma fortunes by now.
 
Posts: 265
Karma: 724240
Join Date: Aug 2013
Device: KyBook
viewing file on device with no epub extension

Hi, I am experimenting with accessing my 'ole reader' app on my iPhone so I can view what books are on the device.

So far so good. After a lot of puzzling and wall banging I now have the reading part working up to a point.

There is however one snag. This app has an option to disable file sharing via the iTunes share folder. As a result it does not place downloaded epubs in the share folder, but only keeps a copy in the internal library, which is also accessible as a sub folder struct in that same share folder, so no problem there because I can also access the internal copy.

However, the files are stored without an extension. And, when building a booklist I need to store a physical path to the book on the device in the book object. But if I use the path as is, then when I do a (V)iew Book in the device view, the get_file function also receives a path to a temp outfile without extension. The result is that instead of the book being opened by Calibre, I get shown an 'Open With' dialog.

Of course if iTunes file sharing is turned on, I can store the filename as found in the share folder, and then viewing the book is no problem. Even so, with file sharing enabled, there is still the possibility that a file might not exist in the share folder so I would still need to revert to the internal library and right back to the View issue

I can get around this problem when sending the books from the device to Calibre because that happens to call 'prepare_addable_books' which is overlayed in my code so I can tack on the epub extension at this point. But for the life of me I have no idea what the (V)iew Book calls as then it directly lands in the get_file without any of the other overlayed def's (new to python, are they called functions like in other languages?) being called first according to the trace if I run in debug mode

The problem is that once I end up in get_file, the physical file is already created and awaiting to be written to, so I cannot add an extension because the name property is read only

How do I get around this?

Last edited by At_Libitum; 10-14-2013 at 07:29 PM.
At_Libitum is offline   Reply With Quote