mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
When bulk downloading metadata for more than 100 books ata time, automatically split up the download into batches of 100. Fixes #828373 (Split Bulk Metadata download job into smaller jobs)
This commit is contained in:
parent
127b517977
commit
1d74d7cc93
@ -89,6 +89,15 @@ class ConfirmDialog(QDialog):
|
|||||||
self.identify = False
|
self.identify = False
|
||||||
self.accept()
|
self.accept()
|
||||||
|
|
||||||
|
def split_jobs(ids, batch_size=100):
|
||||||
|
ans = []
|
||||||
|
ids = list(ids)
|
||||||
|
while ids:
|
||||||
|
jids = ids[:batch_size]
|
||||||
|
ans.append(jids)
|
||||||
|
ids = ids[batch_size:]
|
||||||
|
return ans
|
||||||
|
|
||||||
def start_download(gui, ids, callback):
|
def start_download(gui, ids, callback):
|
||||||
d = ConfirmDialog(ids, gui)
|
d = ConfirmDialog(ids, gui)
|
||||||
ret = d.exec_()
|
ret = d.exec_()
|
||||||
@ -96,11 +105,13 @@ def start_download(gui, ids, callback):
|
|||||||
if ret != d.Accepted:
|
if ret != d.Accepted:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
for batch in split_jobs(ids):
|
||||||
job = ThreadedJob('metadata bulk download',
|
job = ThreadedJob('metadata bulk download',
|
||||||
_('Download metadata for %d books')%len(ids),
|
_('Download metadata for %d books')%len(batch),
|
||||||
download, (ids, gui.current_db, d.identify, d.covers), {}, callback)
|
download, (batch, gui.current_db, d.identify, d.covers), {}, callback)
|
||||||
gui.job_manager.run_threaded_job(job)
|
gui.job_manager.run_threaded_job(job)
|
||||||
gui.status_bar.show_message(_('Metadata download started'), 3000)
|
gui.status_bar.show_message(_('Metadata download started'), 3000)
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def get_job_details(job):
|
def get_job_details(job):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user