convert fix

This commit is contained in:
user 2025-02-27 10:25:53 +03:00
parent a40e04943a
commit 17b0d37143
2 changed files with 21 additions and 24 deletions

View File

@ -152,24 +152,25 @@ async def convert_loop():
# Process output.json: read its contents and update meta['ffprobe_meta']
output_json_path = os.path.join(output_dir.replace("/Storage/storedContent", "/app/data"), "output.json")
if os.path.exists(output_json_path) and unprocessed_encrypted_content.meta.get('ffprobe_meta') is None:
try:
with open(output_json_path, "r") as f:
output_json_content = f.read()
except Exception as e:
make_log("ConvertProcess", f"Error reading output.json for option {option}: {e}", level="error")
return
if os.path.exists(output_json_path):
if unprocessed_encrypted_content.meta.get('ffprobe_meta') is None:
try:
with open(output_json_path, "r") as f:
output_json_content = f.read()
except Exception as e:
make_log("ConvertProcess", f"Error reading output.json for option {option}: {e}", level="error")
return
try:
ffprobe_meta = json.loads(output_json_content)
except Exception as e:
make_log("ConvertProcess", f"Error parsing output.json for option {option}: {e}", level="error")
return
try:
ffprobe_meta = json.loads(output_json_content)
except Exception as e:
make_log("ConvertProcess", f"Error parsing output.json for option {option}: {e}", level="error")
return
unprocessed_encrypted_content.meta = {
**unprocessed_encrypted_content.meta,
'ffprobe_meta': ffprobe_meta
}
unprocessed_encrypted_content.meta = {
**unprocessed_encrypted_content.meta,
'ffprobe_meta': ffprobe_meta
}
else:
make_log("ConvertProcess", f"output.json not found for option {option}", level="error")
@ -184,10 +185,10 @@ async def convert_loop():
unprocessed_encrypted_content.btfs_cid = ContentId(
version=2, content_hash=b58decode(converted_content['high'])
)
).serialize_v2()
unprocessed_encrypted_content.ipfs_cid = ContentId(
version=2, content_hash=b58decode(converted_content['low'])
)
).serialize_v2()
unprocessed_encrypted_content.meta = {
**unprocessed_encrypted_content.meta,
'converted_content': converted_content

View File

@ -98,10 +98,6 @@ class StoredContent(AlchemyBase, AudioContentMixin):
def json_format(self):
extra_fields = {}
if self.btfs_cid:
extra_fields['btfs_cid'] = self.btfs_cid
if self.ipfs_cid:
extra_fields['ipfs_cid'] = self.ipfs_cid
if self.type.startswith('local'):
extra_fields['filename'] = self.filename
extra_fields['encrypted'] = self.encrypted