mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
f15e78aa3e
commit
f48de860fa
@ -242,7 +242,7 @@ def apply_metadata(job, gui, q, result):
|
|||||||
q.finished.disconnect()
|
q.finished.disconnect()
|
||||||
if result != q.Accepted:
|
if result != q.Accepted:
|
||||||
return
|
return
|
||||||
id_map, failed_ids, failed_covers, title_map = job.result
|
id_map, failed_ids, failed_covers, title_map, all_failed = job.result
|
||||||
id_map = dict([(k, v) for k, v in id_map.iteritems() if k not in
|
id_map = dict([(k, v) for k, v in id_map.iteritems() if k not in
|
||||||
failed_ids])
|
failed_ids])
|
||||||
if not id_map:
|
if not id_map:
|
||||||
@ -279,31 +279,39 @@ def apply_metadata(job, gui, q, result):
|
|||||||
|
|
||||||
def proceed(gui, job):
|
def proceed(gui, job):
|
||||||
gui.status_bar.show_message(_('Metadata download completed'), 3000)
|
gui.status_bar.show_message(_('Metadata download completed'), 3000)
|
||||||
id_map, failed_ids, failed_covers, title_map = job.result
|
id_map, failed_ids, failed_covers, title_map, all_failed = job.result
|
||||||
fmsg = det_msg = ''
|
if all_failed:
|
||||||
if failed_ids or failed_covers:
|
q = error_dialog(gui, _('Download failed'),
|
||||||
fmsg = '<p>'+_('Could not download metadata and/or covers for %d of the books. Click'
|
_('Failed to download metadata or covers for any of the %d'
|
||||||
' "Show details" to see which books.')%len(failed_ids)
|
' book(s).') % len(id_map))
|
||||||
det_msg = []
|
else:
|
||||||
for i in failed_ids | failed_covers:
|
fmsg = det_msg = ''
|
||||||
title = title_map[i]
|
if failed_ids or failed_covers:
|
||||||
if i in failed_ids:
|
fmsg = '<p>'+_('Could not download metadata and/or covers for %d of the books. Click'
|
||||||
title += (' ' + _('(Failed metadata)'))
|
' "Show details" to see which books.')%len(failed_ids)
|
||||||
if i in failed_covers:
|
det_msg = []
|
||||||
title += (' ' + _('(Failed cover)'))
|
for i in failed_ids | failed_covers:
|
||||||
det_msg.append(title)
|
title = title_map[i]
|
||||||
msg = '<p>' + _('Finished downloading metadata for <b>%d book(s)</b>. '
|
if i in failed_ids:
|
||||||
'Proceed with updating the metadata in your library?')%len(id_map)
|
title += (' ' + _('(Failed metadata)'))
|
||||||
q = MessageBox(MessageBox.QUESTION, _('Download complete'),
|
if i in failed_covers:
|
||||||
msg + fmsg, det_msg='\n'.join(det_msg), show_copy_button=bool(failed_ids),
|
title += (' ' + _('(Failed cover)'))
|
||||||
parent=gui)
|
det_msg.append(title)
|
||||||
|
msg = '<p>' + _('Finished downloading metadata for <b>%d book(s)</b>. '
|
||||||
|
'Proceed with updating the metadata in your library?')%len(id_map)
|
||||||
|
q = MessageBox(MessageBox.QUESTION, _('Download complete'),
|
||||||
|
msg + fmsg, det_msg='\n'.join(det_msg), show_copy_button=bool(failed_ids),
|
||||||
|
parent=gui)
|
||||||
|
q.finished.connect(partial(apply_metadata, job, gui, q))
|
||||||
|
|
||||||
q.vlb = q.bb.addButton(_('View log'), q.bb.ActionRole)
|
q.vlb = q.bb.addButton(_('View log'), q.bb.ActionRole)
|
||||||
q.vlb.setIcon(QIcon(I('debug.png')))
|
q.vlb.setIcon(QIcon(I('debug.png')))
|
||||||
q.vlb.clicked.connect(partial(view_log, job, q))
|
q.vlb.clicked.connect(partial(view_log, job, q))
|
||||||
q.det_msg_toggle.setVisible(bool(failed_ids | failed_covers))
|
q.det_msg_toggle.setVisible(bool(failed_ids | failed_covers))
|
||||||
q.setModal(False)
|
q.setModal(False)
|
||||||
|
if all_failed:
|
||||||
|
q.det_msg_toggle.setVisible(False)
|
||||||
q.show()
|
q.show()
|
||||||
q.finished.connect(partial(apply_metadata, job, gui, q))
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@ -336,6 +344,7 @@ def download(ids, db, do_identify, covers,
|
|||||||
title_map = {}
|
title_map = {}
|
||||||
ans = {}
|
ans = {}
|
||||||
count = 0
|
count = 0
|
||||||
|
all_failed = True
|
||||||
for i, mi in izip(ids, metadata):
|
for i, mi in izip(ids, metadata):
|
||||||
if abort.is_set():
|
if abort.is_set():
|
||||||
log.error('Aborting...')
|
log.error('Aborting...')
|
||||||
@ -350,6 +359,7 @@ def download(ids, db, do_identify, covers,
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if results:
|
if results:
|
||||||
|
all_failed = False
|
||||||
mi = merge_result(mi, results[0])
|
mi = merge_result(mi, results[0])
|
||||||
identifiers = mi.identifiers
|
identifiers = mi.identifiers
|
||||||
if not mi.is_null('rating'):
|
if not mi.is_null('rating'):
|
||||||
@ -367,6 +377,7 @@ def download(ids, db, do_identify, covers,
|
|||||||
with PersistentTemporaryFile('.jpg', 'downloaded-cover-') as f:
|
with PersistentTemporaryFile('.jpg', 'downloaded-cover-') as f:
|
||||||
f.write(cdata[-1])
|
f.write(cdata[-1])
|
||||||
mi.cover = f.name
|
mi.cover = f.name
|
||||||
|
all_failed = False
|
||||||
else:
|
else:
|
||||||
failed_covers.add(i)
|
failed_covers.add(i)
|
||||||
ans[i] = mi
|
ans[i] = mi
|
||||||
@ -374,7 +385,7 @@ def download(ids, db, do_identify, covers,
|
|||||||
notifications.put((count/len(ids),
|
notifications.put((count/len(ids),
|
||||||
_('Downloaded %d of %d')%(count, len(ids))))
|
_('Downloaded %d of %d')%(count, len(ids))))
|
||||||
log('Download complete, with %d failures'%len(failed_ids))
|
log('Download complete, with %d failures'%len(failed_ids))
|
||||||
return (ans, failed_ids, failed_covers, title_map)
|
return (ans, failed_ids, failed_covers, title_map, all_failed)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user