예제 #1
0
파일: single.py 프로젝트: rakyi/calibre
 def fetch_metadata(self, *args):
     from calibre.ebooks.metadata.sources.update import update_sources
     update_sources()
     d = FullFetch(self.cover.pixmap(), self)
     ret = d.start(title=self.title.current_val, authors=self.authors.current_val,
             identifiers=self.identifiers.current_val)
     if ret == d.Accepted:
         self.metadata_before_fetch = {f:getattr(self, f).current_val for f in fetched_fields}
         from calibre.ebooks.metadata.sources.prefs import msprefs
         mi = d.book
         dummy = Metadata(_('Unknown'))
         for f in msprefs['ignore_fields']:
             if ':' not in f:
                 setattr(mi, f, getattr(dummy, f))
         if mi is not None:
             pd = mi.pubdate
             if pd is not None:
                 # Put the downloaded published date into the local timezone
                 # as we discard time info and the date is timezone
                 # invariant. This prevents the as_local_timezone() call in
                 # update_from_mi from changing the pubdate
                 mi.pubdate = datetime(pd.year, pd.month, pd.day,
                         tzinfo=local_tz)
             self.update_from_mi(mi, merge_comments=msprefs['append_comments'])
         if d.cover_pixmap is not None:
             self.metadata_before_fetch['cover'] = self.cover.current_val
             self.cover.current_val = pixmap_to_data(d.cover_pixmap)
예제 #2
0
 def fetch_metadata(self, *args):
     from calibre.ebooks.metadata.sources.update import update_sources
     update_sources()
     d = FullFetch(self.cover.pixmap(), self)
     ret = d.start(title=self.title.current_val, authors=self.authors.current_val,
             identifiers=self.identifiers.current_val)
     if ret == d.Accepted:
         self.metadata_before_fetch = {f:getattr(self, f).current_val for f in fetched_fields}
         from calibre.ebooks.metadata.sources.prefs import msprefs
         mi = d.book
         dummy = Metadata(_('Unknown'))
         for f in msprefs['ignore_fields']:
             if ':' not in f:
                 setattr(mi, f, getattr(dummy, f))
         if mi is not None:
             pd = mi.pubdate
             if pd is not None:
                 # Put the downloaded published date into the local timezone
                 # as we discard time info and the date is timezone
                 # invariant. This prevents the as_local_timezone() call in
                 # update_from_mi from changing the pubdate
                 mi.pubdate = datetime(pd.year, pd.month, pd.day,
                         tzinfo=local_tz)
             self.update_from_mi(mi, merge_comments=msprefs['append_comments'])
         if d.cover_pixmap is not None:
             self.metadata_before_fetch['cover'] = self.cover.current_val
             self.cover.current_val = pixmap_to_data(d.cover_pixmap)
예제 #3
0
파일: single.py 프로젝트: rakyi/calibre
 def download_cover(self, *args):
     from calibre.ebooks.metadata.sources.update import update_sources
     update_sources()
     from calibre.gui2.metadata.single_download import CoverFetch
     d = CoverFetch(self.cover.pixmap(), self)
     ret = d.start(self.title.current_val, self.authors.current_val,
             self.identifiers.current_val)
     if ret == d.Accepted:
         if d.cover_pixmap is not None:
             self.cover.current_val = pixmap_to_data(d.cover_pixmap)
예제 #4
0
 def download_cover(self, *args):
     from calibre.ebooks.metadata.sources.update import update_sources
     update_sources()
     from calibre.gui2.metadata.single_download import CoverFetch
     d = CoverFetch(self.cover.pixmap(), self)
     ret = d.start(self.title.current_val, self.authors.current_val,
             self.identifiers.current_val)
     if ret == d.Accepted:
         if d.cover_pixmap is not None:
             self.cover.current_val = pixmap_to_data(d.cover_pixmap)
예제 #5
0
 def download_metadata(self, ids=None, ensure_fields=None):
     if ids is None:
         rows = self.gui.library_view.selectionModel().selectedRows()
         if not rows or len(rows) == 0:
             return error_dialog(self.gui, _('Cannot download metadata'),
                         _('No books selected'), show=True)
         db = self.gui.library_view.model().db
         ids = [db.id(row.row()) for row in rows]
     from calibre.gui2.metadata.bulk_download import start_download
     from calibre.ebooks.metadata.sources.update import update_sources
     update_sources()
     start_download(self.gui, ids,
             Dispatcher(self.metadata_downloaded),
             ensure_fields=ensure_fields)