mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-12 21:28:29 +03:00
to_json fix
This commit is contained in:
@@ -19,7 +19,7 @@ class Media:
|
|||||||
urls: List[str] = field(default_factory=list)
|
urls: List[str] = field(default_factory=list)
|
||||||
properties: dict = field(default_factory=dict)
|
properties: dict = field(default_factory=dict)
|
||||||
_mimetype: str = None # eg: image/jpeg
|
_mimetype: str = None # eg: image/jpeg
|
||||||
_stored: bool = field(default=False, repr=False, metadata=config(exclude=True))
|
_stored: bool = field(default=False, repr=False, metadata=config(exclude=lambda _: True)) # always exclude
|
||||||
|
|
||||||
def store(self: Media, override_storages: List = None, url: str = "url-not-available"):
|
def store(self: Media, override_storages: List = None, url: str = "url-not-available"):
|
||||||
# stores the media into the provided/available storages [Storage]
|
# stores the media into the provided/available storages [Storage]
|
||||||
|
|||||||
@@ -100,7 +100,19 @@ class WhisperEnricher(Enricher):
|
|||||||
r_res = requests.get(f'{self.api_endpoint}/jobs/{job_id}/artifacts', headers={'Authorization': f'Bearer {self.api_key}'})
|
r_res = requests.get(f'{self.api_endpoint}/jobs/{job_id}/artifacts', headers={'Authorization': f'Bearer {self.api_key}'})
|
||||||
assert r_res.status_code == 200, f"Job artifacts did not respond with 200, instead with: {r_res.status_code}"
|
assert r_res.status_code == 200, f"Job artifacts did not respond with 200, instead with: {r_res.status_code}"
|
||||||
logger.success(r_res.json())
|
logger.success(r_res.json())
|
||||||
return [artifact.get("data").get("text", "") for artifact in r_res.json()]
|
result = []
|
||||||
|
for artifact in r_res.json():
|
||||||
|
subtitle = []
|
||||||
|
full_text = []
|
||||||
|
for i, d in enumerate(artifact.get("data")):
|
||||||
|
subtitle.append(f"{i+1}\n{d.get('start')} --> {d.get('end')}\n{d.get('text').strip()}")
|
||||||
|
full_text.append(d.get('text').strip())
|
||||||
|
if not len(subtitle): continue
|
||||||
|
result.append({
|
||||||
|
"subtitle": "\n".join(subtitle),
|
||||||
|
"full_text": "\n".join(full_text),
|
||||||
|
})
|
||||||
|
return result
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _get_s3_storage(self) -> S3Storage:
|
def _get_s3_storage(self) -> S3Storage:
|
||||||
|
|||||||
Reference in New Issue
Block a user