Esempio n. 1
0
    def metadata_downloaded(self, job):
        if job.failed:
            self.gui.job_exception(job, dialog_title=_('Failed to download metadata'))
            return
        from calibre.gui2.metadata.bulk_download import get_job_details
        (aborted, id_map, tdir, log_file, failed_ids, failed_covers, all_failed,
                det_msg, lm_map) = get_job_details(job)
        if aborted:
            return self.cleanup_bulk_download(tdir)
        if all_failed:
            num = len(failed_ids | failed_covers)
            self.cleanup_bulk_download(tdir)
            return error_dialog(self.gui, _('Download failed'),
            _('Failed to download metadata or covers for any of the %d'
               ' book(s).') % num, det_msg=det_msg, show=True)

        self.gui.status_bar.show_message(_('Metadata download completed'), 3000)

        msg = '<p>' + _('Finished downloading metadata for <b>%d book(s)</b>. '
            'Proceed with updating the metadata in your library?')%len(id_map)

        show_copy_button = False
        if failed_ids or failed_covers:
            show_copy_button = True
            num = len(failed_ids.union(failed_covers))
            msg += '<p>'+_('Could not download metadata and/or covers for %d of the books. Click'
                    ' "Show details" to see which books.')%num

        payload = (id_map, tdir, log_file, lm_map)
        self.gui.proceed_question(self.apply_downloaded_metadata,
                payload, log_file,
                _('Download log'), _('Download complete'), msg,
                det_msg=det_msg, show_copy_button=show_copy_button,
                cancel_callback=lambda x:self.cleanup_bulk_download(tdir),
                log_is_file=True)
Esempio n. 2
0
    def metadata_downloaded(self, job):
        if job.failed:
            self.gui.job_exception(
                job, dialog_title=_('Failed to download metadata'))
            return
        from calibre.gui2.metadata.bulk_download import get_job_details
        (aborted, id_map, tdir, log_file, failed_ids, failed_covers,
         all_failed, det_msg, lm_map) = get_job_details(job)
        if aborted:
            return self.cleanup_bulk_download(tdir)
        if all_failed:
            num = len(failed_ids | failed_covers)
            self.cleanup_bulk_download(tdir)
            return error_dialog(
                self.gui,
                _('Download failed'),
                _('Failed to download metadata or covers for any of the %d'
                  ' book(s).') % num,
                det_msg=det_msg,
                show=True)

        self.gui.status_bar.show_message(_('Metadata download completed'),
                                         3000)

        msg = '<p>' + _('Finished downloading metadata for <b>%d book(s)</b>. '
                        'Proceed with updating the metadata in your library?'
                        ) % len(id_map)

        show_copy_button = False
        checkbox_msg = None
        if failed_ids or failed_covers:
            show_copy_button = True
            num = len(failed_ids.union(failed_covers))
            msg += '<p>' + _(
                'Could not download metadata and/or covers for %d of the books. Click'
                ' "Show details" to see which books.') % num
            checkbox_msg = _('Show the &failed books in the main book list '
                             'after updating metadata')

        payload = (id_map, tdir, log_file, lm_map,
                   failed_ids.union(failed_covers))
        review_apply = partial(self.apply_downloaded_metadata, True)
        normal_apply = partial(self.apply_downloaded_metadata, False)
        self.gui.proceed_question(normal_apply,
                                  payload,
                                  log_file,
                                  _('Download log'),
                                  _('Download complete'),
                                  msg,
                                  det_msg=det_msg,
                                  show_copy_button=show_copy_button,
                                  cancel_callback=partial(
                                      self.cleanup_bulk_download, tdir),
                                  log_is_file=True,
                                  checkbox_msg=checkbox_msg,
                                  checkbox_checked=False,
                                  action_callback=review_apply,
                                  action_label=_('Review downloaded metadata'),
                                  action_icon=QIcon(I('auto_author_sort.png')))
Esempio n. 3
0
    def metadata_downloaded(self, job):
        if job.failed:
            self.gui.job_exception(job, dialog_title=_('Failed to download metadata'))
            return
        from calibre.gui2.metadata.bulk_download import get_job_details
        (aborted, id_map, tdir, log_file, failed_ids, failed_covers, all_failed,
                det_msg, lm_map) = get_job_details(job)
        if aborted:
            return self.cleanup_bulk_download(tdir)
        if all_failed:
            num = len(failed_ids | failed_covers)
            self.cleanup_bulk_download(tdir)
            return error_dialog(self.gui, _('Download failed'), ngettext(
                'Failed to download metadata or cover for the selected book.',
                'Failed to download metadata or covers for any of the {} books.', num
            ).format(num), det_msg=det_msg, show=True)

        self.gui.status_bar.show_message(_('Metadata download completed'), 3000)

        msg = '<p>' + ngettext(
            'Finished downloading metadata for the selected book.',
            'Finished downloading metadata for <b>{} books</b>.', len(id_map)).format(len(id_map)) + ' ' + \
            _('Proceed with updating the metadata in your library?')

        show_copy_button = False
        checkbox_msg = None
        if failed_ids or failed_covers:
            show_copy_button = True
            num = len(failed_ids.union(failed_covers))
            msg += '<p>'+_('Could not download metadata and/or covers for %d of the books. Click'
                    ' "Show details" to see which books.')%num
            checkbox_msg = _('Show the &failed books in the main book list '
                    'after updating metadata')

        if getattr(job, 'metadata_and_covers', None) == (False, True):
            # Only covers, remove failed cover downloads from id_map
            for book_id in failed_covers:
                if hasattr(id_map, 'discard'):
                    id_map.discard(book_id)
        payload = (id_map, tdir, log_file, lm_map,
                failed_ids.union(failed_covers))
        review_apply = partial(self.apply_downloaded_metadata, True)
        normal_apply = partial(self.apply_downloaded_metadata, False)
        self.gui.proceed_question(
            normal_apply, payload, log_file, _('Download log'),
            _('Metadata download complete'), msg, icon='download-metadata.png',
            det_msg=det_msg, show_copy_button=show_copy_button,
            cancel_callback=partial(self.cleanup_bulk_download, tdir),
            log_is_file=True, checkbox_msg=checkbox_msg,
            checkbox_checked=False, action_callback=review_apply,
            action_label=_('Revie&w downloaded metadata'),
            action_icon=QIcon(I('auto_author_sort.png')))
Esempio n. 4
0
    def metadata_downloaded(self, job):
        if job.failed:
            self.gui.job_exception(
                job, dialog_title=_('Failed to download metadata'))
            return
        from calibre.gui2.metadata.bulk_download import get_job_details
        (aborted, id_map, tdir, log_file, failed_ids, failed_covers,
         all_failed, det_msg, lm_map) = get_job_details(job)
        if aborted:
            return self.cleanup_bulk_download(tdir)
        if all_failed:
            num = len(failed_ids | failed_covers)
            self.cleanup_bulk_download(tdir)
            return error_dialog(
                self.gui,
                _('Download failed'),
                _('Failed to download metadata or covers for any of the %d'
                  ' book(s).') % num,
                det_msg=det_msg,
                show=True)

        self.gui.status_bar.show_message(_('Metadata download completed'),
                                         3000)

        msg = '<p>' + _('Finished downloading metadata for <b>%d book(s)</b>. '
                        'Proceed with updating the metadata in your library?'
                        ) % len(id_map)

        show_copy_button = False
        if failed_ids or failed_covers:
            show_copy_button = True
            num = len(failed_ids.union(failed_covers))
            msg += '<p>' + _(
                'Could not download metadata and/or covers for %d of the books. Click'
                ' "Show details" to see which books.') % num

        payload = (id_map, tdir, log_file, lm_map)
        self.gui.proceed_question(
            self.apply_downloaded_metadata,
            payload,
            log_file,
            _('Download log'),
            _('Download complete'),
            msg,
            det_msg=det_msg,
            show_copy_button=show_copy_button,
            cancel_callback=lambda x: self.cleanup_bulk_download(tdir),
            log_is_file=True)
Esempio n. 5
0
    def metadata_downloaded(self, job):
        if job.failed:
            self.gui.job_exception(job, dialog_title=_('Failed to download metadata'))
            return
        from calibre.gui2.metadata.bulk_download import get_job_details
        (aborted, id_map, tdir, log_file, failed_ids, failed_covers, all_failed,
                det_msg, lm_map) = get_job_details(job)
        if aborted:
            return self.cleanup_bulk_download(tdir)
        if all_failed:
            num = len(failed_ids | failed_covers)
            self.cleanup_bulk_download(tdir)
            return error_dialog(self.gui, _('Download failed'),
            _('Failed to download metadata or covers for any of the %d'
               ' book(s).') % num, det_msg=det_msg, show=True)

        self.gui.status_bar.show_message(_('Metadata download completed'), 3000)

        msg = '<p>' + _('Finished downloading metadata for <b>%d book(s)</b>. '
            'Proceed with updating the metadata in your library?')%len(id_map)

        show_copy_button = False
        checkbox_msg = None
        if failed_ids or failed_covers:
            show_copy_button = True
            num = len(failed_ids.union(failed_covers))
            msg += '<p>'+_('Could not download metadata and/or covers for %d of the books. Click'
                    ' "Show details" to see which books.')%num
            checkbox_msg = _('Show the &failed books in the main book list '
                    'after updating metadata')

        payload = (id_map, tdir, log_file, lm_map,
                failed_ids.union(failed_covers))
        review_apply = partial(self.apply_downloaded_metadata, True)
        normal_apply = partial(self.apply_downloaded_metadata, False)
        self.gui.proceed_question(normal_apply, payload,
                log_file, _('Download log'), _('Download complete'), msg,
                det_msg=det_msg, show_copy_button=show_copy_button,
                cancel_callback=partial(self.cleanup_bulk_download, tdir),
                log_is_file=True, checkbox_msg=checkbox_msg,
                checkbox_checked=False, action_callback=review_apply,
                action_label=_('Review downloaded metadata'),
                action_icon=QIcon(I('auto_author_sort.png')))
Esempio n. 6
0
    def metadata_downloaded(self, job):
        if job.failed:
            self.gui.job_exception(job, dialog_title=_("Failed to download metadata"))
            return
        from calibre.gui2.metadata.bulk_download import get_job_details

        (aborted, id_map, tdir, log_file, failed_ids, failed_covers, all_failed, det_msg, lm_map) = get_job_details(job)
        if aborted:
            return self.cleanup_bulk_download(tdir)
        if all_failed:
            num = len(failed_ids | failed_covers)
            self.cleanup_bulk_download(tdir)
            return error_dialog(
                self.gui,
                _("Download failed"),
                _("Failed to download metadata or covers for any of the %d" " book(s).") % num,
                det_msg=det_msg,
                show=True,
            )

        self.gui.status_bar.show_message(_("Metadata download completed"), 3000)

        msg = "<p>" + _(
            "Finished downloading metadata for <b>%d book(s)</b>. "
            "Proceed with updating the metadata in your library?"
        ) % len(id_map)

        show_copy_button = False
        checkbox_msg = None
        if failed_ids or failed_covers:
            show_copy_button = True
            num = len(failed_ids.union(failed_covers))
            msg += (
                "<p>"
                + _(
                    "Could not download metadata and/or covers for %d of the books. Click"
                    ' "Show details" to see which books.'
                )
                % num
            )
            checkbox_msg = _("Show the &failed books in the main book list " "after updating metadata")

        if getattr(job, "metadata_and_covers", None) == (False, True):
            # Only covers, remove failed cover downloads from id_map
            for book_id in failed_covers:
                if hasattr(id_map, "discard"):
                    id_map.discard(book_id)
        payload = (id_map, tdir, log_file, lm_map, failed_ids.union(failed_covers))
        review_apply = partial(self.apply_downloaded_metadata, True)
        normal_apply = partial(self.apply_downloaded_metadata, False)
        self.gui.proceed_question(
            normal_apply,
            payload,
            log_file,
            _("Download log"),
            _("Metadata download complete"),
            msg,
            icon="download-metadata.png",
            det_msg=det_msg,
            show_copy_button=show_copy_button,
            cancel_callback=partial(self.cleanup_bulk_download, tdir),
            log_is_file=True,
            checkbox_msg=checkbox_msg,
            checkbox_checked=False,
            action_callback=review_apply,
            action_label=_("Revie&w downloaded metadata"),
            action_icon=QIcon(I("auto_author_sort.png")),
        )