View Single Post
Old 01-23-2010, 03:20 PM   #1
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
How To: Getting summary metadata and images, not tags, author, title

I add books to my library as soon as I get them. Usually, I take the time to make sure the title and author are right, but I don't always have time to download the metadata and covers. I particularly like getting the summary info.

Later I want to edit metadata, add my personal tags, pick up covers, etc. I open up the edit metadata screen, and tell it to fetch, and I see 3 or four likely descriptions. The problem is always that the title or author may be in all caps. Or the title will have the series name in it, even though the other books in that series don't have the series in the title. If I want to pick up the summary description, it writes over my correct author/title. I've particularly noticed that the title is often incorrectly capitalized. I then have to go back and fix the author and title that was correct when I started!

Another issue occurs when I want to look at several different cover images. To do that you have to choose different results from the fetch table, but each choice writes over the author and title again. I know some people hate the multiple tags - this lets you stop picking them up,while still picking up ratings and images, etc.

The one thing that is really, really nice about open source software is you have control. Now I know that not many of us are programmers, and even fewer are familiar with Python, but it really is easy to make small changes that improve things for special cases. You just need to take a few steps to get the source code, and use Notepad (Windows) to type "# " in front of a few lines to prevent Calibre from overwriting the existing data with the new data. You can pick up only the summary, or even pick up summaries from 3 versions of the book. (Summaries are cumulative - they don't write over your comments or the summaries already in there.)

Here's how I fixed it. First, read this on Setting up a calibre development environment¶

It may seem tricky, but truthfully, all you have to do is download Bazaar, run it once to tell it where you want to put your source code, and set one environment variable in Windows to tell Calibre where you put it. Then you're ready to take control. As long as that environment variable is set, Calibre will use your changes. As soon as you delete or change the environment variable from "CALIBRE_DEVELOP_FROM" to something else (like "CALIBRE_NOT_DEVELOP_FROM") you hide your revised source code and Calibre goes back to its normal behavior.

Now all you need to know is what changes to make. Go to where you told Bazaar to put your source code ( I use a folder called src inside the Calibre folder) and find the file called calibre\gui2\dialogs\metadata_single.py

starting at line 575 you see:

Code:
                        else:
                            book.tags = []
                        # self.title.setText(book.title)
                        # self.authors.setText(authors_to_string(book.authors))
                        # if book.author_sort: self.author_sort.setText(book.author_sort)
                        if book.publisher: self.publisher.setEditText(book.publisher)
                        if book.isbn: self.isbn.setText(book.isbn)
                        if book.pubdate:
                            d = book.pubdate
                            d = d - self.local_timezone_offset
                            self.pubdate.setDate(QDate(d.year, d.month, d.day))
                        summ = book.comments
                        if summ:
                            prefix = unicode(self.comments.toPlainText())
                            if prefix:
                                prefix += '\n'
                            self.comments.setText(prefix + summ)
                        if book.rating is not None:
                            self.rating.setValue(int(book.rating))
                        if book.tags:
                            self.tags.setText(', '.join(book.tags))
Just comment out (that means put "# " in front of) any line that controls something you don't want picked up. In the code above, I've commented out the title, author and author_sort and left everything else. There are a few lines that are inside "if" blocks. For those, you just need to comment out the if line and all indented lines below it.

I know it can be scary to play with the source code, if you've never done it, but all you have to do is delete or change the environment variable, as above, and all your changes stop having any effect on Calibre. It's a lot easier than writing a regex expression. This little change made it possible for me to quickly look at several different images, pick up multiple descriptions, and still get the correct publisher, pubdate on the last selection without having to constantly fix the author and title.

Have fun.

Last edited by Starson17; 01-25-2010 at 09:37 AM.
Starson17 is offline   Reply With Quote