mirror of https://github.com/CIRCL/lookyloo
chg: Use cache instead of pickle for meta info
parent
2c6d6b2556
commit
1ae76ddea7
|
@ -203,14 +203,18 @@ class Lookyloo():
|
||||||
|
|
||||||
def get_meta(self, capture_uuid: str, /) -> Dict[str, str]:
|
def get_meta(self, capture_uuid: str, /) -> Dict[str, str]:
|
||||||
'''Get the meta informations from a capture (mostly, details about the User Agent used.)'''
|
'''Get the meta informations from a capture (mostly, details about the User Agent used.)'''
|
||||||
metafile = self._captures_index[capture_uuid].capture_dir / 'meta'
|
cache = self.capture_cache(capture_uuid)
|
||||||
|
if not cache:
|
||||||
|
return {}
|
||||||
|
metafile = cache.capture_dir / 'meta'
|
||||||
if metafile.exists():
|
if metafile.exists():
|
||||||
with metafile.open('r') as f:
|
with metafile.open('r') as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
||||||
|
if not cache.user_agent:
|
||||||
|
return {}
|
||||||
meta = {}
|
meta = {}
|
||||||
ct = self.get_crawled_tree(capture_uuid)
|
ua = ParsedUserAgent(cache.user_agent)
|
||||||
ua = ParsedUserAgent(ct.root_hartree.user_agent)
|
|
||||||
meta['user_agent'] = ua.string
|
meta['user_agent'] = ua.string
|
||||||
if ua.platform:
|
if ua.platform:
|
||||||
meta['os'] = ua.platform
|
meta['os'] = ua.platform
|
||||||
|
|
Loading…
Reference in New Issue