def extract_manifest_of_file(crx_file):
debug = False
if os.path.isfile(crx_file):
size = os.path.getsize(crx_file)
if size == 0:
print('###################!!!! fucking empty downloads', crx_file)
return
try:
with ZipFile(crx_file) as myzip:
if debug:
# """ #save file to debug later
source = myzip.open('manifest.json')
target = open('lol.json', "wb")
with source, target:
shutil.copyfileobj(source, target)
#"""
with myzip.open('manifest.json') as myfile:
text = myfile.read()
#if debug: print(text)
try:
text = text.decode('utf-8-sig')
except:
text = text.decode('latin-1')
if debug: print(text)
try:
return json.loads(text, strict=False)
except Exception as e:
print(e)
text = uncomment(text)
return json.loads(text, strict=False)
except BadZipFile:
print('fucking interrupted downloads')
else:
print(crx_file,'does not exist')
#TODO: add filesize
评论列表
文章目录