mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-29 11:51:14 +00:00
Updated omnivore loader for new API
This commit is contained in:
parent
b8a858ee6d
commit
9f5addf645
@ -4,18 +4,24 @@ import logging
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def identify_mime(header):
|
def identify_mime(header, fh):
|
||||||
mime_type = None
|
mime_type = None
|
||||||
try:
|
try:
|
||||||
parser, mime_type = find_diskimage_from_data(header, True)
|
fh.seek(0)
|
||||||
except (errors.UnsupportedContainer, errors.UnsupportedDiskImage, IOError) as e:
|
data = fh.read()
|
||||||
print(f"error in atrcopy parser: {e}")
|
except IOError as e:
|
||||||
|
log.debug(f"atrcopy loader: error reading entire file: {e}")
|
||||||
else:
|
else:
|
||||||
print(f"{parser.image}: {mime_type}")
|
try:
|
||||||
|
parser, mime_type = find_diskimage_from_data(data, True)
|
||||||
|
except (errors.UnsupportedContainer, errors.UnsupportedDiskImage, IOError) as e:
|
||||||
|
print(f"error in atrcopy parser: {e}")
|
||||||
|
else:
|
||||||
|
print(f"{parser.image}: {mime_type}")
|
||||||
|
|
||||||
if mime_type:
|
if mime_type:
|
||||||
log.debug(f"atrcopy loader: identified {mime_type}")
|
log.debug(f"atrcopy loader: identified {mime_type}")
|
||||||
return dict(mime=mime_type, ext="")
|
return dict(mime=mime_type, ext="", atrcopy_parser=parser)
|
||||||
else:
|
else:
|
||||||
log.debug(f"atrcopy loader: unidentified")
|
log.debug(f"atrcopy loader: not recognized")
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user