View Single Post
Old 10-13-2012, 08:43 AM   #1
Xwang
Connoisseur
Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.
 
Posts: 77
Karma: 2136220
Join Date: Sep 2012
Device: none
Plugin to trasform database to upper case

Hi to all,
I've the windows portable calibre installed on an usb ntfs formatted external drive. Moreover, I access the same library from the linux version when I'm running linux. I've the need to be able to add books both in linux and windows and I alternate the use of these operating systems (windows at work, linux at home).

Since the alternating use of windows and linux creates issues given by differences in how ntfs is handled by the two OS (see PS below), I would like to create one (or more if necessary) plugin(s) to transform the existing database in an upper case one, and to maintain so on when books are added.
At the same time, the plugin(s) should avoid to create a file path longer than 256 characters.

To transform the existing database I've thought to create a plugin that, for each book in the database, changes author(s) name and title to upper case and add a specific string ('_MYTEMP') to both of them (the latter is needed to force the operating system to change file and dir name even if it is case insensitive). After the changes are saved, it will remove the specific string from names and title and save the changes again.

So I expected that at the end of the running the original file tree
Code:
Federal Aviation Administration
├── FAA Helicopter Flying Handbook - 8083-21 (292)
│** ├── cover.jpg
│** ├── FAA Helicopter Flying Handbook - 8083-21 - Federal Aviation Administration.pdf
│** └── metadata.opf
├── Pilot's Handbook of Aeronautical Knowled (291)
│** ├── cover.jpg
│** ├── metadata.opf
│** └── Pilot's Handbook of Aeronautical Knowled - Federal Aviation Administration.pdf
└── Special Federal Aviation Regulations SFA (293)
    ├── cover.jpg
    ├── metadata.opf
    └── Special Federal Aviation Regulations SFA - Federal Aviation Administration.pdf
has been changed in the following way regardless the OS in use
Code:
FEDERAL AVIATION ADMINISTRATION
├── FAA HELICOPTER FLYING HANDBOOK - 8083-21 (292)
│** ├── cover.jpg
│** ├── FAA HELICOPTER FLYING HANDBOOK - 8083-21 - FEDERAL AVIATION ADMINISTRATION.PDF
│** └── METADATA.OPF
├── PILOT'S HANDBOOK OF AERONAUTICAL KNOWLED (291)
│** ├── cover.jpg
│** ├── metadata.opf
│** └── PILOT'S HANDBOOK OF AERONAUTICAL KNOWLED - FEDERAL AVIATION ADMINISTRATION.PDF
└── SPECIAL FEDERAL AVIATION REGULATIONS SFA (293)
    ├── cover.jpg
    ├── metadata.opf
    └── SPECIAL FEDERAL AVIATION REGULATIONS SFA - FEDERAL AVIATION ADMINISTRATION.PDF
Then it would be nice to have a plugin which on save does the same to maintain the library upper case (in case this second plugin is difficult, Maybe I can modify the first one to verify if book and author is upper cased before modify them).

Obviously the plugin(s) should work on any file type.
So the (initial) questions are:
1)which type of plugin should I do? A FileTypePlugin or a MetadData one?
2)how can I loop for all the books?

Thank you,
Xwang


PS: the biggest difference is the fact that linux can create multiple files with same names with the exception of the case and such files are not visible under windows, the other problem is that windows has a maximum path name length of 256 characters which linux do not have, so I can find some books which are not readable under windows)

PS2: I prefer to have this implemented as plugin because I don't have so much time to maintain a personal source code branch which will need to be aligned to upstream version every time they are modified
Xwang is offline   Reply With Quote