mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2261 (Conversion metadata problem)
This commit is contained in:
parent
b52d7f60d9
commit
28a9c6868a
@ -176,19 +176,19 @@ class Config(ResizableDialog, Ui_Dialog):
|
||||
def get_metadata(self):
|
||||
title, authors = self.get_title_and_authors()
|
||||
mi = MetaInformation(title, authors)
|
||||
publisher = unicode(self.publisher.text())
|
||||
publisher = unicode(self.publisher.text()).strip()
|
||||
if publisher:
|
||||
mi.publisher = publisher
|
||||
author_sort = unicode(self.author_sort.text())
|
||||
author_sort = unicode(self.author_sort.text()).strip()
|
||||
if author_sort:
|
||||
mi.author_sort = author_sort
|
||||
comments = unicode(self.comment.toPlainText())
|
||||
comments = unicode(self.comment.toPlainText()).strip()
|
||||
if comments:
|
||||
mi.comments = comments
|
||||
mi.series_index = int(self.series_index.value())
|
||||
if self.series.currentIndex() > -1:
|
||||
mi.series = unicode(self.series.currentText())
|
||||
tags = [t.strip() for t in unicode(self.tags.text()).split(',')]
|
||||
mi.series = unicode(self.series.currentText()).strip()
|
||||
tags = [t.strip() for t in unicode(self.tags.text()).strip().split(',')]
|
||||
if tags:
|
||||
mi.tags = tags
|
||||
|
||||
@ -267,6 +267,7 @@ class Config(ResizableDialog, Ui_Dialog):
|
||||
).exec_()
|
||||
return
|
||||
mi = self.get_metadata()
|
||||
self.user_mi = mi
|
||||
self.read_settings()
|
||||
self.cover_file = None
|
||||
if self.row is not None:
|
||||
|
@ -52,10 +52,10 @@ def convert_single(fmt, parent, db, comics, others):
|
||||
temp_files.append(d.cover_file)
|
||||
opts.cover = d.cover_file.name
|
||||
temp_files.extend([d.opf_file, pt, of])
|
||||
jobs.append(('any2'+fmt, args, _('Convert book: ')+d.mi.title,
|
||||
jobs.append(('any2'+fmt, args, _('Convert book: ')+d.mi.title,
|
||||
fmt.upper(), row_id, temp_files))
|
||||
changed = True
|
||||
|
||||
|
||||
for row, row_id in zip(comics, comics_ids):
|
||||
mi = db.get_metadata(row)
|
||||
title = author = _('Unknown')
|
||||
@ -72,7 +72,7 @@ def convert_single(fmt, parent, db, comics, others):
|
||||
try:
|
||||
data = db.format(row, _fmt.upper())
|
||||
if data is not None:
|
||||
break
|
||||
break
|
||||
except:
|
||||
continue
|
||||
pt = PersistentTemporaryFile('.'+_fmt)
|
||||
@ -84,12 +84,12 @@ def convert_single(fmt, parent, db, comics, others):
|
||||
opts.verbose = 2
|
||||
args = [pt.name, opts]
|
||||
changed = True
|
||||
jobs.append(('comic2'+fmt, args, _('Convert comic: ')+opts.title,
|
||||
jobs.append(('comic2'+fmt, args, _('Convert comic: ')+opts.title,
|
||||
fmt.upper(), row_id, [pt, of]))
|
||||
|
||||
|
||||
return jobs, changed
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def convert_single_lrf(parent, db, comics, others):
|
||||
changed = False
|
||||
@ -114,10 +114,10 @@ def convert_single_lrf(parent, db, comics, others):
|
||||
if d.cover_file:
|
||||
temp_files.append(d.cover_file)
|
||||
temp_files.extend([pt, of])
|
||||
jobs.append(('any2lrf', [cmdline], _('Convert book: ')+d.title(),
|
||||
jobs.append(('any2lrf', [cmdline], _('Convert book: ')+d.title(),
|
||||
'LRF', row_id, temp_files))
|
||||
changed = True
|
||||
|
||||
|
||||
for row, row_id in zip(comics, comics_ids):
|
||||
mi = db.get_metadata(row)
|
||||
title = author = _('Unknown')
|
||||
@ -134,7 +134,7 @@ def convert_single_lrf(parent, db, comics, others):
|
||||
try:
|
||||
data = db.format(row, fmt.upper())
|
||||
if data is not None:
|
||||
break
|
||||
break
|
||||
except:
|
||||
continue
|
||||
if data is None:
|
||||
@ -148,19 +148,20 @@ def convert_single_lrf(parent, db, comics, others):
|
||||
opts.verbose = 1
|
||||
args = [pt.name, opts]
|
||||
changed = True
|
||||
jobs.append(('comic2lrf', args, _('Convert comic: ')+opts.title,
|
||||
jobs.append(('comic2lrf', args, _('Convert comic: ')+opts.title,
|
||||
'LRF', row_id, [pt, of]))
|
||||
|
||||
|
||||
return jobs, changed
|
||||
|
||||
def convert_bulk(fmt, parent, db, comics, others):
|
||||
if others:
|
||||
d = get_dialog(fmt)(parent, db)
|
||||
if d.exec_() != QDialog.Accepted:
|
||||
others = []
|
||||
others, user_mi = [], None
|
||||
else:
|
||||
opts = d.opts
|
||||
opts.verbose = 2
|
||||
user_mi = d.user_mi
|
||||
if comics:
|
||||
comic_opts = ComicConf.get_bulk_conversion_options(parent)
|
||||
if not comic_opts:
|
||||
@ -171,7 +172,7 @@ def convert_bulk(fmt, parent, db, comics, others):
|
||||
if total == 0:
|
||||
return
|
||||
parent.status_bar.showMessage(_('Starting Bulk conversion of %d books')%total, 2000)
|
||||
|
||||
|
||||
for i, row in enumerate(others+comics):
|
||||
row_id = db.id(row)
|
||||
if row in others:
|
||||
@ -188,6 +189,11 @@ def convert_bulk(fmt, parent, db, comics, others):
|
||||
continue
|
||||
options = opts.copy()
|
||||
mi = db.get_metadata(row)
|
||||
if user_mi is not None:
|
||||
if user_mi.series_index == 1:
|
||||
user_mi.series_index = None
|
||||
mi.smart_update(user_mi)
|
||||
db.set_metadata(db.id(row), mi)
|
||||
opf = OPFCreator(os.getcwdu(), mi)
|
||||
opf_file = PersistentTemporaryFile('.opf')
|
||||
opf.render(opf_file)
|
||||
@ -223,10 +229,10 @@ def convert_bulk(fmt, parent, db, comics, others):
|
||||
try:
|
||||
data = db.format(row, _fmt.upper())
|
||||
if data is not None:
|
||||
break
|
||||
break
|
||||
except:
|
||||
continue
|
||||
|
||||
|
||||
pt = PersistentTemporaryFile('.'+_fmt.lower())
|
||||
pt.write(data)
|
||||
pt.close()
|
||||
@ -236,17 +242,17 @@ def convert_bulk(fmt, parent, db, comics, others):
|
||||
options.verbose = 1
|
||||
args = [pt.name, options]
|
||||
desc = _('Convert book %d of %d (%s)')%(i+1, total, repr(mi.title))
|
||||
jobs.append(('comic2'+fmt, args, desc, fmt.upper(), row_id, [pt, of]))
|
||||
|
||||
jobs.append(('comic2'+fmt, args, desc, fmt.upper(), row_id, [pt, of]))
|
||||
|
||||
if bad_rows:
|
||||
res = []
|
||||
for row in bad_rows:
|
||||
title = db.title(row)
|
||||
res.append('<li>%s</li>'%title)
|
||||
|
||||
|
||||
msg = _('<p>Could not convert %d of %d books, because no suitable source format was found.<ul>%s</ul>')%(len(res), total, '\n'.join(res))
|
||||
warning_dialog(parent, _('Could not convert some books'), msg).exec_()
|
||||
|
||||
|
||||
return jobs, False
|
||||
|
||||
|
||||
@ -265,7 +271,7 @@ def convert_bulk_lrf(parent, db, comics, others):
|
||||
if total == 0:
|
||||
return
|
||||
parent.status_bar.showMessage(_('Starting Bulk conversion of %d books')%total, 2000)
|
||||
|
||||
|
||||
for i, row in enumerate(others+comics):
|
||||
row_id = db.id(row)
|
||||
if row in others:
|
||||
@ -320,10 +326,10 @@ def convert_bulk_lrf(parent, db, comics, others):
|
||||
try:
|
||||
data = db.format(row, fmt.upper())
|
||||
if data is not None:
|
||||
break
|
||||
break
|
||||
except:
|
||||
continue
|
||||
|
||||
|
||||
pt = PersistentTemporaryFile('.'+fmt.lower())
|
||||
pt.write(data)
|
||||
pt.close()
|
||||
@ -333,17 +339,17 @@ def convert_bulk_lrf(parent, db, comics, others):
|
||||
options.verbose = 1
|
||||
args = [pt.name, options]
|
||||
desc = _('Convert book %d of %d (%s)')%(i+1, total, repr(mi.title))
|
||||
jobs.append(('comic2lrf', args, desc, 'LRF', row_id, [pt, of]))
|
||||
|
||||
jobs.append(('comic2lrf', args, desc, 'LRF', row_id, [pt, of]))
|
||||
|
||||
if bad_rows:
|
||||
res = []
|
||||
for row in bad_rows:
|
||||
title = db.title(row)
|
||||
res.append('<li>%s</li>'%title)
|
||||
|
||||
|
||||
msg = _('<p>Could not convert %d of %d books, because no suitable source format was found.<ul>%s</ul>')%(len(res), total, '\n'.join(res))
|
||||
warning_dialog(parent, _('Could not convert some books'), msg).exec_()
|
||||
|
||||
|
||||
return jobs, False
|
||||
|
||||
def set_conversion_defaults_lrf(comic, parent, db):
|
||||
@ -370,7 +376,7 @@ def _fetch_news(data, fmt):
|
||||
args.extend(['--password', data['password']])
|
||||
args.append(data['script'] if data['script'] else data['title'])
|
||||
return 'feeds2'+fmt.lower(), [args], _('Fetch news from ')+data['title'], fmt.upper(), [pt]
|
||||
|
||||
|
||||
|
||||
def fetch_scheduled_recipe(recipe, script):
|
||||
from calibre.gui2.dialogs.scheduler import config
|
||||
@ -385,7 +391,7 @@ def fetch_scheduled_recipe(recipe, script):
|
||||
args.extend(['--username', x[0], '--password', x[1]])
|
||||
args.append(script)
|
||||
return 'feeds2'+fmt, [args], _('Fetch news from ')+recipe.title, fmt.upper(), [pt]
|
||||
|
||||
|
||||
|
||||
def convert_single_ebook(*args):
|
||||
fmt = prefs['output_format'].lower()
|
||||
@ -393,14 +399,14 @@ def convert_single_ebook(*args):
|
||||
return convert_single_lrf(*args)
|
||||
elif fmt in ('epub', 'mobi'):
|
||||
return convert_single(fmt, *args)
|
||||
|
||||
|
||||
def convert_bulk_ebooks(*args):
|
||||
fmt = prefs['output_format'].lower()
|
||||
if fmt == 'lrf':
|
||||
return convert_bulk_lrf(*args)
|
||||
elif fmt in ('epub', 'mobi'):
|
||||
return convert_bulk(fmt, *args)
|
||||
|
||||
|
||||
def set_conversion_defaults(comic, parent, db):
|
||||
fmt = prefs['output_format'].lower()
|
||||
if fmt == 'lrf':
|
||||
@ -410,4 +416,4 @@ def set_conversion_defaults(comic, parent, db):
|
||||
|
||||
def fetch_news(data):
|
||||
fmt = prefs['output_format'].lower()
|
||||
return _fetch_news(data, fmt)
|
||||
return _fetch_news(data, fmt)
|
||||
|
@ -15,19 +15,19 @@ def title_sort(title):
|
||||
def server_config(defaults=None):
|
||||
desc=_('Settings to control the calibre content server')
|
||||
c = Config('server', desc) if defaults is None else StringConfig(defaults, desc)
|
||||
|
||||
c.add_opt('port', ['-p', '--port'], default=8080,
|
||||
|
||||
c.add_opt('port', ['-p', '--port'], default=8080,
|
||||
help=_('The port on which to listen. Default is %default'))
|
||||
c.add_opt('timeout', ['-t', '--timeout'], default=120,
|
||||
c.add_opt('timeout', ['-t', '--timeout'], default=120,
|
||||
help=_('The server timeout in seconds. Default is %default'))
|
||||
c.add_opt('thread_pool', ['--thread-pool'], default=30,
|
||||
c.add_opt('thread_pool', ['--thread-pool'], default=30,
|
||||
help=_('The max number of worker threads to use. Default is %default'))
|
||||
c.add_opt('password', ['--password'], default=None,
|
||||
c.add_opt('password', ['--password'], default=None,
|
||||
help=_('Set a password to restrict access. By default access is unrestricted.'))
|
||||
c.add_opt('username', ['--username'], default='calibre',
|
||||
help=_('Username for access. By default, it is: %default'))
|
||||
c.add_opt('develop', ['--develop'], default=False,
|
||||
help='Development mode. Server automatically restarts on file changes and serves code files (html, css, js) from the file system instead of calibre\'s resource system.')
|
||||
c.add_opt('max_cover', ['--max-cover'], default='600x800',
|
||||
c.add_opt('max_cover', ['--max-cover'], default='600x800',
|
||||
help=_('The maximum size for displayed covers. Default is %default.'))
|
||||
return c
|
||||
|
Loading…
x
Reference in New Issue
Block a user