mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GwR catalog comments appended
This commit is contained in:
commit
80e5f15fb4
@ -139,12 +139,11 @@ class FileTypePlugin(Plugin):
|
||||
#: to the database
|
||||
on_import = False
|
||||
|
||||
#: If True, this plugin is run whenever an any2* tool
|
||||
#: is used, on the file passed to the any2* tool.
|
||||
#: If True, this plugin is run just before a conversion
|
||||
on_preprocess = False
|
||||
|
||||
#: If True, this plugin is run after an any2* tool is
|
||||
#: used, on the final file produced by the tool.
|
||||
#: If True, this plugin is run after conversion
|
||||
#: on the final file produced by the conversion output plugin.
|
||||
on_postprocess = False
|
||||
|
||||
type = _('File type')
|
||||
|
@ -3462,52 +3462,56 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
|
||||
opts.basename = "Catalog"
|
||||
opts.cli_environment = not hasattr(opts,'sync')
|
||||
# GwR *** hardwired to sort by author, could be an option if passed in opts
|
||||
opts.sort_descriptions_by_author = True
|
||||
|
||||
build_log = []
|
||||
|
||||
# If exclude_genre is blank, assume user wants all genre tags included
|
||||
if opts.exclude_genre.strip() == '':
|
||||
opts.exclude_genre = '\[^.\]'
|
||||
log(" converting empty exclude_genre to '\[^.\]'")
|
||||
#log(" converting empty exclude_genre to '\[^.\]'")
|
||||
build_log.append(" converting empty exclude_genre to '\[^.\]'")
|
||||
|
||||
if opts.connected_device['name']:
|
||||
if opts.connected_device['serial']:
|
||||
log(" connected_device: '%s' #%s%s " % \
|
||||
build_log.append(" connected_device: '%s' #%s%s " % \
|
||||
(opts.connected_device['name'],
|
||||
opts.connected_device['serial'][0:4],
|
||||
'x' * (len(opts.connected_device['serial']) - 4)))
|
||||
else:
|
||||
log(" connected_device: '%s'" % opts.connected_device['name'])
|
||||
build.log.append(" connected_device: '%s'" % opts.connected_device['name'])
|
||||
for storage in opts.connected_device['storage']:
|
||||
if storage:
|
||||
log(" mount point: %s" % storage)
|
||||
build_log.append(" mount point: %s" % storage)
|
||||
|
||||
opts_dict = vars(opts)
|
||||
build_log.append(u"%s(): Generating %s %sin %s environment" %
|
||||
(self.name,self.fmt,'for %s ' % opts.output_profile if opts.output_profile else '',
|
||||
'CLI' if opts.cli_environment else 'GUI'))
|
||||
if opts_dict['ids']:
|
||||
build_log.append(" 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')
|
||||
build_log.append(u"Creating Sections for %s" % ', '.join(sections_list))
|
||||
|
||||
# Display opts
|
||||
keys = opts_dict.keys()
|
||||
keys.sort()
|
||||
build_log.append(" opts:")
|
||||
for key in keys:
|
||||
if key in ['catalog_title','authorClip','descriptionClip','exclude_genre','exclude_tags',
|
||||
'note_tag','numbers_as_text','read_tag',
|
||||
'search_text','sort_by','sort_descriptions_by_author','sync']:
|
||||
build_log.append(" %s: %s" % (key, opts_dict[key]))
|
||||
|
||||
if opts.verbose:
|
||||
opts_dict = vars(opts)
|
||||
log(u"%s(): Generating %s %sin %s environment" %
|
||||
(self.name,self.fmt,'for %s ' % opts.output_profile if opts.output_profile else '',
|
||||
'CLI' if opts.cli_environment else 'GUI'))
|
||||
if 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))
|
||||
|
||||
# Display opts
|
||||
keys = opts_dict.keys()
|
||||
keys.sort()
|
||||
log(" opts:")
|
||||
for key in keys:
|
||||
if key in ['catalog_title','authorClip','descriptionClip','exclude_genre','exclude_tags',
|
||||
'note_tag','numbers_as_text','read_tag',
|
||||
'search_text','sort_by','sort_descriptions_by_author','sync']:
|
||||
log(" %s: %s" % (key, opts_dict[key]))
|
||||
log('\n'.join(line for line in build_log))
|
||||
|
||||
self.opts = opts
|
||||
|
||||
@ -3527,9 +3531,7 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
|
||||
if catalog_source_built:
|
||||
recommendations = []
|
||||
# recommendations.append(('cover', I('catalog.svg'), OptionRecommendation.HIGH))
|
||||
|
||||
recommendations.append(('comments', 'I added this comment in library.cli:run()',
|
||||
recommendations.append(('comments', '\n'.join(line for line in build_log),
|
||||
OptionRecommendation.HIGH))
|
||||
|
||||
dp = getattr(opts, 'debug_pipeline', None)
|
||||
@ -3553,7 +3555,7 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
plumber.merge_ui_recommendations(recommendations)
|
||||
|
||||
plumber.run()
|
||||
catalog.updateCatalogMetadata("I added this comment from library.catalog:run()")
|
||||
catalog.updateCatalogMetadata('\n'.join(line for line in build_log))
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
|
@ -1475,18 +1475,21 @@ class LibraryDatabase2(LibraryDatabase):
|
||||
self.data.books_added([db_id], self)
|
||||
self.set_path(db_id, index_is_id=True)
|
||||
self.conn.commit()
|
||||
try:
|
||||
mi = get_metadata(stream,
|
||||
os.path.splitext(path)[1][1:].lower())
|
||||
except:
|
||||
mi = MetaInformation(title, ['calibre'])
|
||||
mi.tags = [_('Catalog')]
|
||||
self.set_metadata(db_id, mi)
|
||||
|
||||
mi.title, mi.authors = title, ['calibre']
|
||||
mi.tags = [_('Catalog')]
|
||||
mi.pubdate = mi.timestamp = nowf()
|
||||
self.set_metadata(db_id, mi)
|
||||
|
||||
self.add_format(db_id, format, stream, index_is_id=True)
|
||||
if not hasattr(path, 'read'):
|
||||
stream.close()
|
||||
self.conn.commit()
|
||||
if existing:
|
||||
t = utcnow()
|
||||
self.set_timestamp(db_id, t, notify=False)
|
||||
self.set_pubdate(db_id, t, notify=False)
|
||||
self.data.refresh_ids(self, [db_id]) # Needed to update format list and size
|
||||
return db_id
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user