mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
GwR revisions, tweaks
This commit is contained in:
parent
b33c664009
commit
526e7198d7
@ -149,7 +149,7 @@ class DeviceManager(Thread):
|
|||||||
possibly_connected_devices.append((device, detected_device))
|
possibly_connected_devices.append((device, detected_device))
|
||||||
if possibly_connected_devices:
|
if possibly_connected_devices:
|
||||||
if not self.do_connect(possibly_connected_devices):
|
if not self.do_connect(possibly_connected_devices):
|
||||||
print 'Connect to device failed, retying in 5 seconds...'
|
print 'Connect to device failed, retrying in 5 seconds...'
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
if not self.do_connect(possibly_connected_devices):
|
if not self.do_connect(possibly_connected_devices):
|
||||||
print 'Device connect failed again, giving up'
|
print 'Device connect failed again, giving up'
|
||||||
|
@ -1119,12 +1119,14 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
#<p class="title"><a name="<database_id>"></a><em>Book Title</em></p>
|
#<p class="title"><a name="<database_id>"></a><em>Book Title</em></p>
|
||||||
emTag = Tag(soup, "em")
|
emTag = Tag(soup, "em")
|
||||||
if title['series']:
|
if title['series']:
|
||||||
# Insert br at colon
|
# title<br />series series_index
|
||||||
brTag = Tag(soup,'br')
|
brTag = Tag(soup,'br')
|
||||||
title_tokens = title['title'].split(': ')
|
title_tokens = title['title'].split(': ')
|
||||||
emTag.insert(0, title_tokens[0] + ':')
|
emTag.insert(0, NavigableString(title_tokens[1]))
|
||||||
emTag.insert(1, brTag)
|
emTag.insert(1, brTag)
|
||||||
emTag.insert(2, title_tokens[1])
|
smallTag = Tag(soup,'small')
|
||||||
|
smallTag.insert(0,NavigableString(title_tokens[0]))
|
||||||
|
emTag.insert(2, smallTag)
|
||||||
else:
|
else:
|
||||||
emTag.insert(0, NavigableString(escape(title['title'])))
|
emTag.insert(0, NavigableString(escape(title['title'])))
|
||||||
titleTag = body.find(attrs={'class':'title'})
|
titleTag = body.find(attrs={'class':'title'})
|
||||||
@ -1202,6 +1204,11 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
else:
|
else:
|
||||||
imgTag['src'] = "../images/thumbnail_default.jpg"
|
imgTag['src'] = "../images/thumbnail_default.jpg"
|
||||||
imgTag['alt'] = "cover"
|
imgTag['alt'] = "cover"
|
||||||
|
|
||||||
|
# Tweak image size if we're building for Sony, not sure why this is needed
|
||||||
|
if self.opts.fmt == 'epub' and self.opts.output_profile.startswith("sony"):
|
||||||
|
imgTag['style'] = 'width: %dpx; height:%dpx;' % (self.THUMB_WIDTH * 2, self.THUMB_HEIGHT * 2)
|
||||||
|
else:
|
||||||
imgTag['style'] = 'width: %dpx; height:%dpx;' % (self.THUMB_WIDTH, self.THUMB_HEIGHT)
|
imgTag['style'] = 'width: %dpx; height:%dpx;' % (self.THUMB_WIDTH, self.THUMB_HEIGHT)
|
||||||
thumbnailTag = body.find(attrs={'class':'thumbnail'})
|
thumbnailTag = body.find(attrs={'class':'thumbnail'})
|
||||||
thumbnailTag.insert(0,imgTag)
|
thumbnailTag.insert(0,imgTag)
|
||||||
@ -1697,7 +1704,9 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
|
|
||||||
for genre in genre_list:
|
for genre in genre_list:
|
||||||
for key in genre:
|
for key in genre:
|
||||||
self.opts.log.info(" %s: %d titles" % (key, len(genre[key])))
|
self.opts.log.info(" %s: %d %s" % (self.getFriendlyGenreTag(key),
|
||||||
|
len(genre[key]),
|
||||||
|
'titles' if len(genre[key]) > 1 else 'title'))
|
||||||
|
|
||||||
# Write the results
|
# Write the results
|
||||||
# genre_list = [ {friendly_tag:[{book},{book}]}, {friendly_tag:[{book},{book}]}, ...]
|
# genre_list = [ {friendly_tag:[{book},{book}]}, {friendly_tag:[{book},{book}]}, ...]
|
||||||
@ -2042,6 +2051,10 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
self.playOrder += 1
|
self.playOrder += 1
|
||||||
navLabelTag = Tag(ncx_soup, "navLabel")
|
navLabelTag = Tag(ncx_soup, "navLabel")
|
||||||
textTag = Tag(ncx_soup, "text")
|
textTag = Tag(ncx_soup, "text")
|
||||||
|
if book['series']:
|
||||||
|
tokens = book['title'].split(': ')
|
||||||
|
textTag.insert(0, NavigableString(self.formatNCXText('%s (%s)' % (tokens[1], tokens[0]))))
|
||||||
|
else:
|
||||||
textTag.insert(0, NavigableString(self.formatNCXText(book['title'])))
|
textTag.insert(0, NavigableString(self.formatNCXText(book['title'])))
|
||||||
navLabelTag.insert(0,textTag)
|
navLabelTag.insert(0,textTag)
|
||||||
navPointVolumeTag.insert(0,navLabelTag)
|
navPointVolumeTag.insert(0,navLabelTag)
|
||||||
@ -2548,15 +2561,25 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
else:
|
else:
|
||||||
yield tag
|
yield tag
|
||||||
|
|
||||||
self.opts.log.info(u' %d available genre tags in database (exclude_genre: %s):' % \
|
self.opts.log.info(u' %d genre tags in database (excluding genres matching %s):' % \
|
||||||
(len(genre_tags_dict), self.opts.exclude_genre))
|
(len(genre_tags_dict), self.opts.exclude_genre))
|
||||||
|
|
||||||
# Display friendly/normalized genres
|
# Display friendly/normalized genres
|
||||||
# friendly => normalized
|
# friendly => normalized
|
||||||
|
if False:
|
||||||
sorted_tags = ['%s => %s' % (key, genre_tags_dict[key]) for key in sorted(genre_tags_dict.keys())]
|
sorted_tags = ['%s => %s' % (key, genre_tags_dict[key]) for key in sorted(genre_tags_dict.keys())]
|
||||||
|
|
||||||
for tag in next_tag(sorted_tags):
|
for tag in next_tag(sorted_tags):
|
||||||
self.opts.log(u' %s' % tag)
|
self.opts.log(u' %s' % tag)
|
||||||
|
else:
|
||||||
|
sorted_tags = ['%s' % (key) for key in sorted(genre_tags_dict.keys())]
|
||||||
|
out_str = ''
|
||||||
|
line_break = 70
|
||||||
|
for tag in next_tag(sorted_tags):
|
||||||
|
out_str += tag
|
||||||
|
if len(out_str) >= line_break:
|
||||||
|
self.opts.log.info(' %s' % out_str)
|
||||||
|
out_str = ''
|
||||||
|
self.opts.log.info(' %s' % out_str)
|
||||||
|
|
||||||
return genre_tags_dict
|
return genre_tags_dict
|
||||||
|
|
||||||
@ -2596,13 +2619,8 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
body.insert(btc,aTag)
|
body.insert(btc,aTag)
|
||||||
btc += 1
|
btc += 1
|
||||||
|
|
||||||
# Find the first instance of friendly_tag matching genre
|
|
||||||
for friendly_tag in self.genre_tags_dict:
|
|
||||||
if self.genre_tags_dict[friendly_tag] == genre:
|
|
||||||
break
|
|
||||||
|
|
||||||
titleTag = body.find(attrs={'class':'title'})
|
titleTag = body.find(attrs={'class':'title'})
|
||||||
titleTag.insert(0,NavigableString('<b><i>%s</i></b>' % escape(friendly_tag)))
|
titleTag.insert(0,NavigableString('<b><i>%s</i></b>' % escape(self.getFriendlyGenreTag(genre))))
|
||||||
|
|
||||||
# Insert the books by author list
|
# Insert the books by author list
|
||||||
divTag = body.find(attrs={'class':'authors'})
|
divTag = body.find(attrs={'class':'authors'})
|
||||||
@ -2927,6 +2945,12 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
else:
|
else:
|
||||||
return char
|
return char
|
||||||
|
|
||||||
|
def getFriendlyGenreTag(self, genre):
|
||||||
|
# Find the first instance of friendly_tag matching genre
|
||||||
|
for friendly_tag in self.genre_tags_dict:
|
||||||
|
if self.genre_tags_dict[friendly_tag] == genre:
|
||||||
|
return friendly_tag
|
||||||
|
|
||||||
def markdownComments(self, comments):
|
def markdownComments(self, comments):
|
||||||
'''
|
'''
|
||||||
Convert random comment text to normalized, xml-legal block of <p>s
|
Convert random comment text to normalized, xml-legal block of <p>s
|
||||||
@ -3076,7 +3100,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
opts.basename = "Catalog"
|
opts.basename = "Catalog"
|
||||||
opts.plugin_path = self.plugin_path
|
opts.plugin_path = self.plugin_path
|
||||||
opts.cli_environment = not hasattr(opts,'sync')
|
opts.cli_environment = not hasattr(opts,'sync')
|
||||||
# GwR *** hardwired for the moment
|
# GwR *** hardwired to sort by author, could be an option if passed in opts
|
||||||
opts.sort_descriptions_by_author = True
|
opts.sort_descriptions_by_author = True
|
||||||
|
|
||||||
if opts.verbose:
|
if opts.verbose:
|
||||||
@ -3087,6 +3111,15 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
if opts_dict['ids']:
|
if opts_dict['ids']:
|
||||||
log(" Book count: %d" % len(opts_dict['ids']))
|
log(" Book count: %d" % len(opts_dict['ids']))
|
||||||
|
|
||||||
|
sections_list = ['Descriptions','Authors']
|
||||||
|
if opts.generate_titles:
|
||||||
|
sections_list.append('Titles')
|
||||||
|
if opts.generate_recently_added:
|
||||||
|
sections_list.append('Recently Added')
|
||||||
|
if not opts.exclude_genre.strip() == '.':
|
||||||
|
sections_list.append('Genres')
|
||||||
|
log(u"Creating Sections for %s" % ', '.join(sections_list))
|
||||||
|
|
||||||
# If exclude_genre is blank, assume user wants all genre tags included
|
# If exclude_genre is blank, assume user wants all genre tags included
|
||||||
if opts.exclude_genre.strip() == '':
|
if opts.exclude_genre.strip() == '':
|
||||||
opts.exclude_genre = '\[^.\]'
|
opts.exclude_genre = '\[^.\]'
|
||||||
@ -3098,8 +3131,8 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
log(" opts:")
|
log(" opts:")
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if key in ['catalog_title','exclude_genre','exclude_tags','generate_titles',
|
if key in ['catalog_title','exclude_genre','exclude_tags',
|
||||||
'generate_recently_added','note_tag','numbers_as_text','read_tag',
|
'note_tag','numbers_as_text','read_tag',
|
||||||
'search_text','sort_by','sort_descriptions_by_author','sync']:
|
'search_text','sort_by','sort_descriptions_by_author','sync']:
|
||||||
log(" %s: %s" % (key, opts_dict[key]))
|
log(" %s: %s" % (key, opts_dict[key]))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user