mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1549 (Metadata plugin not working)
This commit is contained in:
parent
b1594e46c9
commit
c524170f71
@ -105,30 +105,43 @@ def reread_metadata_plugins():
|
||||
for plugin in _initialized_plugins:
|
||||
if isinstance(plugin, MetadataReaderPlugin):
|
||||
for ft in plugin.file_types:
|
||||
_metadata_readers[ft] = plugin
|
||||
if not _metadata_readers.has_key(ft):
|
||||
_metadata_readers[ft] = []
|
||||
_metadata_readers[ft].append(plugin)
|
||||
elif isinstance(plugin, MetadataWriterPlugin):
|
||||
for ft in plugin.file_types:
|
||||
_metadata_writers[ft] = plugin
|
||||
if not _metadata_writers.has_key(ft):
|
||||
_metadata_writers[ft] = []
|
||||
_metadata_writers[ft].append(plugin)
|
||||
|
||||
|
||||
|
||||
def get_file_type_metadata(stream, ftype):
|
||||
mi = MetaInformation(None, None)
|
||||
try:
|
||||
plugin = _metadata_readers[ftype.lower().strip()]
|
||||
if not is_disabled(plugin):
|
||||
with plugin:
|
||||
mi = plugin.get_metadata(stream, ftype.lower().strip())
|
||||
except:
|
||||
pass
|
||||
ftype = ftype.lower().strip()
|
||||
if _metadata_readers.has_key(ftype):
|
||||
for plugin in _metadata_readers[ftype]:
|
||||
if not is_disabled(plugin):
|
||||
with plugin:
|
||||
try:
|
||||
mi = plugin.get_metadata(stream, ftype.lower().strip())
|
||||
break
|
||||
except:
|
||||
continue
|
||||
return mi
|
||||
|
||||
def set_file_type_metadata(stream, mi, ftype):
|
||||
try:
|
||||
plugin = _metadata_writers[ftype.lower().strip()]
|
||||
if not is_disabled(plugin):
|
||||
with plugin:
|
||||
plugin.set_metadata(stream, mi, ftype.lower().strip())
|
||||
except:
|
||||
traceback.print_exc()
|
||||
ftype = ftype.lower().strip()
|
||||
if _metadata_writers.has_key(ftype):
|
||||
for plugin in _metadata_writers[ftype]:
|
||||
if not is_disabled(plugin):
|
||||
with plugin:
|
||||
try:
|
||||
plugin.set_metadata(stream, mi, ftype.lower().strip())
|
||||
break
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
def _run_filetype_plugins(path_to_file, ft=None, occasion='preprocess'):
|
||||
occasion = {'import':_on_import, 'preprocess':_on_preprocess,
|
||||
|
@ -88,7 +88,7 @@ def render_table(soup, table, css, base_dir, width, height, dpi, factor=1.0):
|
||||
|
||||
def do_render(html, base_dir, width, height, dpi, factor):
|
||||
if QApplication.instance() is None:
|
||||
QApplication([])
|
||||
QApplication([])
|
||||
tr = HTMLTableRenderer(html, base_dir, width, height, dpi, factor)
|
||||
tr.loop.exec_()
|
||||
return tr.images, tr.tdir
|
@ -231,7 +231,7 @@ NULL = DevNull()
|
||||
|
||||
def do_add(db, paths, one_book_per_directory, recurse, add_duplicates):
|
||||
orig = sys.stdout
|
||||
sys.stdout = NULL
|
||||
#sys.stdout = NULL
|
||||
try:
|
||||
files, dirs = [], []
|
||||
for path in paths:
|
||||
|
@ -34,6 +34,7 @@ except:
|
||||
|
||||
iswindows = 'win32' in sys.platform or 'win64' in sys.platform
|
||||
isosx = 'darwin' in sys.platform
|
||||
isbsd = 'bsd' in sys.platform
|
||||
DISABLED = False
|
||||
#if isosx:
|
||||
# libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user