From d731515ad452f24872d6abcee8516169ac2c6e57 Mon Sep 17 00:00:00 2001 From: GRiker Date: Tue, 14 Sep 2010 14:39:13 -0600 Subject: [PATCH 1/4] GwR revisions --- src/calibre/customize/profiles.py | 6 ++++-- src/calibre/ebooks/oeb/transforms/jacket.py | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index 1563f764ca..b9a159ee7d 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -555,9 +555,11 @@ class KindleOutput(OutputProfile): periodical_date_in_title = False @classmethod +# def tags_to_string(cls, tags): +# return u'%s
%s' % (', '.join(tags), +# 'ttt '.join(tags)+'ttt ') def tags_to_string(cls, tags): - return u'%s
%s' % (', '.join(tags), - 'ttt '.join(tags)+'ttt ') + return u'%s' % (', '.join(tags)) class KindleDXOutput(OutputProfile): diff --git a/src/calibre/ebooks/oeb/transforms/jacket.py b/src/calibre/ebooks/oeb/transforms/jacket.py index dc1d2fea41..ff192ca537 100644 --- a/src/calibre/ebooks/oeb/transforms/jacket.py +++ b/src/calibre/ebooks/oeb/transforms/jacket.py @@ -55,10 +55,11 @@ class Jacket(object): img = I(fname, data=True) if self.opts.output_profile.short_name == 'kindle': + # Original star.png size: 24x23 + # Needs to be scaled by half fname = 'star.jpg' img = save_cover_data_to(img, fname, - return_data=True) - + return_data=True, resize_to=[12,12]) id, href = self.oeb.manifest.generate('calibre_jacket_star', fname) self.oeb.manifest.add(id, href, guess_type(fname)[0], data=img) @@ -97,7 +98,7 @@ class Jacket(object): # Render Jacket {{{ -def get_rating(rating, href): +def get_rating(rating, href, output_profile): ans = '' try: num = float(rating)/2 @@ -114,6 +115,7 @@ def get_rating(rating, href): href, int(num))) else: ans = u' '.join(u'\u2605') + return ans @@ -138,7 +140,7 @@ def render_jacket(mi, output_profile, star_href=None, except: pubdate = '' - rating = get_rating(mi.rating, star_href) + rating = get_rating(mi.rating, star_href, output_profile) tags = mi.tags if mi.tags else alt_tags if tags: From e0afe753ccaa45e2e7ca6da602132bf6d25ef0db Mon Sep 17 00:00:00 2001 From: GRiker Date: Wed, 15 Sep 2010 04:55:08 -0600 Subject: [PATCH 2/4] GR wip --- src/calibre/customize/profiles.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index b9a159ee7d..97b84f1286 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -555,11 +555,9 @@ class KindleOutput(OutputProfile): periodical_date_in_title = False @classmethod -# def tags_to_string(cls, tags): -# return u'%s
%s' % (', '.join(tags), -# 'ttt '.join(tags)+'ttt ') def tags_to_string(cls, tags): - return u'%s' % (', '.join(tags)) + return u'%s
%s' % (', '.join(tags), + 'ttt '.join(tags)+'ttt ') class KindleDXOutput(OutputProfile): From d568fbb3d82c593ba2e496e905f6f400fd958764 Mon Sep 17 00:00:00 2001 From: GRiker Date: Wed, 15 Sep 2010 06:56:44 -0600 Subject: [PATCH 3/4] GwR apple driver bug fix --- src/calibre/devices/apple/driver.py | 41 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index c9bc04a242..5fe36faf75 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -207,8 +207,8 @@ class ITUNES(DriverBase): for (j,p_book) in enumerate(self.update_list): if False: if isosx: - self.log.info(" looking for %s" % - str(p_book['lib_book'])[-9:]) + self.log.info(" looking for '%s' by %s uuid:%s" % + (p_book['title'],p_book['author'], p_book['uuid'])) elif iswindows: self.log.info(" looking for '%s' by %s (%s)" % (p_book['title'],p_book['author'], p_book['uuid'])) @@ -303,7 +303,7 @@ class ITUNES(DriverBase): this_book.device_collections = [] this_book.library_id = library_books[this_book.path] if this_book.path in library_books else None this_book.size = book.size() - this_book.uuid = book.album() + this_book.uuid = book.composer() # Hack to discover if we're running in GUI environment if self.report_progress is not None: this_book.thumbnail = self._generate_thumbnail(this_book.path, book) @@ -732,15 +732,15 @@ class ITUNES(DriverBase): for path in paths: if DEBUG: self._dump_cached_book(self.cached_books[path], indent=2) - self.log.info(" looking for '%s' by '%s' (%s)" % + self.log.info(" looking for '%s' by '%s' uuid:%s" % (self.cached_books[path]['title'], self.cached_books[path]['author'], self.cached_books[path]['uuid'])) # Purge the booklist, self.cached_books, thumb cache for i,bl_book in enumerate(booklists[0]): - if False: - self.log.info(" evaluating '%s' by '%s' (%s)" % + if DEBUG: + self.log.info(" evaluating '%s' by '%s' uuid:%s" % (bl_book.title, bl_book.author,bl_book.uuid)) found = False @@ -781,10 +781,10 @@ class ITUNES(DriverBase): zf.close() break -# else: -# if DEBUG: -# self.log.error(" unable to find '%s' by '%s' (%s)" % -# (bl_book.title, bl_book.author,bl_book.uuid)) + else: + if DEBUG: + self.log.error(" unable to find '%s' by '%s' (%s)" % + (bl_book.title, bl_book.author,bl_book.uuid)) if False: self._dump_booklist(booklists[0], indent = 2) @@ -905,7 +905,8 @@ class ITUNES(DriverBase): # Add new_book to self.cached_books if DEBUG: - self.log.info(" adding '%s' by '%s' ['%s'] to self.cached_books" % + self.log.info("ITUNES.upload_books()") + self.log.info(" adding '%s' by '%s' uuid:%s to self.cached_books" % ( metadata[i].title, metadata[i].author, metadata[i].uuid)) self.cached_books[this_book.path] = { 'author': metadata[i].author, @@ -943,7 +944,11 @@ class ITUNES(DriverBase): new_booklist.append(this_book) self._update_iTunes_metadata(metadata[i], db_added, lb_added, this_book) - # Add new_book to self.cached_paths + # Add new_book to self.cached_books + if DEBUG: + self.log.info("ITUNES.upload_books()") + self.log.info(" adding '%s' by '%s' uuid:%s to self.cached_books" % + ( metadata[i].title, metadata[i].author, metadata[i].uuid)) self.cached_books[this_book.path] = { 'author': metadata[i].author[0], 'dev_book': db_added, @@ -1406,8 +1411,8 @@ class ITUNES(DriverBase): for book in booklist: if isosx: - self.log.info("%s%-40.40s %-30.30s %-10.10s" % - (' '*indent,book.title, book.author, str(book.library_id)[-9:])) + self.log.info("%s%-40.40s %-30.30s %-10.10s %s" % + (' '*indent,book.title, book.author, str(book.library_id)[-9:], book.uuid)) elif iswindows: self.log.info("%s%-40.40s %-30.30s" % (' '*indent,book.title, book.author)) @@ -1547,11 +1552,12 @@ class ITUNES(DriverBase): if isosx: for ub in self.update_list: - self.log.info("%s%-40.40s %-30.30s %-10.10s" % + self.log.info("%s%-40.40s %-30.30s %-10.10s %s" % (' '*indent, ub['title'], ub['author'], - str(ub['lib_book'])[-9:])) + str(ub['lib_book'])[-9:], + ub['uuid'])) elif iswindows: for ub in self.update_list: self.log.info("%s%-40.40s %-30.30s" % @@ -2804,7 +2810,7 @@ class ITUNES_ASYNC(ITUNES): #this_book.library_id = library_books[this_book.path] if this_book.path in library_books else None this_book.library_id = library_books[book] this_book.size = library_books[book].size() - this_book.uuid = library_books[book].album() + this_book.uuid = library_books[book].composer() # Hack to discover if we're running in GUI environment if self.report_progress is not None: this_book.thumbnail = self._generate_thumbnail(this_book.path, library_books[book]) @@ -2844,6 +2850,7 @@ class ITUNES_ASYNC(ITUNES): this_book.device_collections = [] this_book.library_id = library_books[book] this_book.size = library_books[book].Size + this_book.uuid = library_books[book].Composer # Hack to discover if we're running in GUI environment if self.report_progress is not None: this_book.thumbnail = self._generate_thumbnail(this_book.path, library_books[book]) From 8052d91e337345d9b0f59fa917ce2915c0bf931c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 15 Sep 2010 10:01:49 -0600 Subject: [PATCH 4/4] Use asterisk for ratings on most output profiles --- src/calibre/customize/profiles.py | 5 ++++ src/calibre/ebooks/oeb/transforms/jacket.py | 6 ++-- .../gui2/convert/structure_detection.ui | 28 +++++++++---------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index 1563f764ca..a8d7eb2e0d 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -248,6 +248,9 @@ class OutputProfile(Plugin): #: If True, the date is appended to the title of downloaded news periodical_date_in_title = True + #: The character used to represent a star in ratings + ratings_char = u'*' + @classmethod def tags_to_string(cls, tags): return escape(', '.join(tags)) @@ -273,6 +276,7 @@ class iPadOutput(OutputProfile): 'macros': {'border-width': '{length}|medium|thick|thin'} } ] + ratings_char = u'\u2605' touchscreen = True # touchscreen_news_css {{{ touchscreen_news_css = u''' @@ -553,6 +557,7 @@ class KindleOutput(OutputProfile): fsizes = [12, 12, 14, 16, 18, 20, 22, 24] supports_mobi_indexing = True periodical_date_in_title = False + ratings_char = u'\u2605' @classmethod def tags_to_string(cls, tags): diff --git a/src/calibre/ebooks/oeb/transforms/jacket.py b/src/calibre/ebooks/oeb/transforms/jacket.py index a44a18db95..88c7a4ff0e 100644 --- a/src/calibre/ebooks/oeb/transforms/jacket.py +++ b/src/calibre/ebooks/oeb/transforms/jacket.py @@ -93,7 +93,7 @@ class Jacket(object): # Render Jacket {{{ -def get_rating(rating): +def get_rating(rating, rchar): ans = '' try: num = float(rating)/2 @@ -104,7 +104,7 @@ def get_rating(rating): if num < 1: return ans - ans = u'\u2605' * int(num) + ans = rchar * int(num) return ans @@ -129,7 +129,7 @@ def render_jacket(mi, output_profile, except: pubdate = '' - rating = get_rating(mi.rating) + rating = get_rating(mi.rating, output_profile.ratings_char) tags = mi.tags if mi.tags else alt_tags if tags: diff --git a/src/calibre/gui2/convert/structure_detection.ui b/src/calibre/gui2/convert/structure_detection.ui index eb2892a07a..c0b3de3bd9 100644 --- a/src/calibre/gui2/convert/structure_detection.ui +++ b/src/calibre/gui2/convert/structure_detection.ui @@ -41,24 +41,17 @@ - + Insert &metadata as page at start of book - - - - &Preprocess input file to possibly improve structure detection - - - - + - + Qt::Vertical @@ -71,26 +64,33 @@ - + Remove F&ooter - + Remove H&eader - + - + + + + + &Preprocess input file to possibly improve structure detection + + +