Quote:
Originally Posted by JimmXinu
That doesn't stop Xwang from writing one for his own use, though.
First, Xwang, have you proven that changing the author/title to uppercase like that solves your problem? You tried it manually with a smaller set of books, that is?
Assuming so, I suggest a UI plugin that searches for titles/authors with lower case and updates the metadata on command.
One place you could start is with the Extract ISBN plugin. It's the simplest plugin I know of that modifies metadata. You don't need the whole background processing part, but the technique used to update isbn can probably be adapted to update title/authors instead.
Another possible way to do it is this:
Code:
db = self.gui.current_db
bookids = db.search_getting_ids('title:"~[a-z]" or author:"~[a-z]"', None)
for bookid in bookids:
mi = db.get_metadata(bookid,index_is_id=True)
mi.title = mi.title.upper()
auths=[]
for auth in mi.authors:
auths.append(auth.upper())
mi.authors = auths
db.set_metadata(bookid,mi)
db.refresh_ids(bookids)
I haven't tested it, so I doubt it would work exactly as is, but it's a starting point.
|
First of all, thank you for your help.
I'm pretty sure that transforming and maintaining the db in upper case is sufficient to solve my problem, however it is necessary to execute it with a double step method:
firstly I've to transform in upper case titles and authors adding a special string to both; then I've to remove the special string.
I'm not a python expert but I suppose that adding the string and removing it is not a problem, so I can use your code as a base by running the for cycle twice.
I've two questions:
1) does bookid change when title or authors are changed?
2) what does "db.search_getting_ids('title:"~[a-z]" or author:"~[a-z]"', None)"
exactly do?
My idea is something like this:
Code:
db = self.gui.current_db
bookids = db.search_getting_ids('title:"~[a-z]" or author:"~[a-z]"', None)
for bookid in bookids:
mi = db.get_metadata(bookid,index_is_id=True)
mi.title = mi.title.upper()+'_T#@§'
auths=[]
for auth in mi.authors:
auths.append(auth.upper()+'_T#@§')
mi.authors = auths
db.set_metadata(bookid,mi)
for bookid in bookids:
mi = db.get_metadata(bookid,index_is_id=True)
mi.title = mi.title[:-5]
auths=[]
for auth in mi.authors:
auths.append(auth[:-5])
mi.authors = auths
db.set_metadata(bookid,mi)
db.refresh_ids(bookids)
This should function if bookid is not changed, otherwise I've to do a new search between the two for loops.
Xwang