Rebasing onto master

CLI Only working with ffnet *only* reading from Chrome browser cache.
This commit is contained in:
Jim Miller 2021-01-09 16:01:57 -06:00
parent eb51c671f5
commit 2b9d4b4ebd
3 changed files with 27 additions and 0 deletions

View file

@ -55,7 +55,10 @@ class CacheBlock():
# Read Magic Number
magic = struct.unpack('I', header.read(4))[0]
<<<<<<< HEAD
# print("magic number:%s"%hex(magic))
=======
>>>>>>> e94a36a7 (Rebasing onto master)
if magic == CacheBlock.BLOCK_MAGIC:
self.type = CacheBlock.BLOCK
header.seek(2, 1)

View file

@ -113,7 +113,11 @@ class CacheData():
else:
block = open(os.path.join(self.address.path,self.address.fileSelector), 'rb')
block.seek(8192 + self.address.blockNumber*self.address.entrySize)
<<<<<<< HEAD
data = block.read(self.size)
=======
data = block.read(self.size).decode('utf-8')
>>>>>>> e94a36a7 (Rebasing onto master)
block.close()
return data

View file

@ -39,6 +39,7 @@ import os
import struct
import sys
import re
<<<<<<< HEAD
import time
def do_cprofile(func):
@ -67,6 +68,9 @@ except:
# wants the output, too, but returns it
return brotlidec(inbuf,[])
import time
=======
import brotli
>>>>>>> e94a36a7 (Rebasing onto master)
from . import csvOutput
from . import SuperFastHash
@ -139,16 +143,24 @@ class ChromeCache(object):
def __init__(self,path):
self.cache = parse(path)
self.hash_cache = {}
<<<<<<< HEAD
# t = time.time()
for entry in self.cache:
key = entry.keyToStr()
if 'fanfiction.net' not in key:
continue
=======
for entry in self.cache:
key = entry.keyToStr()
>>>>>>> e94a36a7 (Rebasing onto master)
self.hash_cache[key] = entry
normkey = re.sub(r'^(https://www.fanfiction.net/s/\d+/\d+/).+$',r'\1',key)
## either overwrites (no harm), or adds new.
self.hash_cache[normkey] = entry
<<<<<<< HEAD
# print("======:%s"%(time.time()-t))
=======
>>>>>>> e94a36a7 (Rebasing onto master)
def get_cached_file(self,url):
if url in self.hash_cache:
@ -164,7 +176,11 @@ class ChromeCache(object):
if entry.httpHeader.headers[b'content-encoding'] == b"gzip":
data = gzip.decompress(data)
elif entry.httpHeader.headers[b'content-encoding'] == b"br":
<<<<<<< HEAD
data = brotli_decompress(data)
=======
data = brotli.decompress(data)
>>>>>>> e94a36a7 (Rebasing onto master)
return data
return None
@ -243,6 +259,10 @@ def exportToHTML(cache, outpath):
# print("unbrotli'ed:%s"%name)
except IOError:
page.write("Something wrong happened while unzipping")
<<<<<<< HEAD
=======
brotli
>>>>>>> e94a36a7 (Rebasing onto master)
else:
page.write('<a href="%s">%s</a>'%(name ,
entry.keyToStr().split('/')[-1]))