diff --git a/app/core/background/convert_service.py b/app/core/background/convert_service.py index b41b181..05fa99a 100644 --- a/app/core/background/convert_service.py +++ b/app/core/background/convert_service.py @@ -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 - - unprocessed_encrypted_content.meta = { - **unprocessed_encrypted_content.meta, - 'ffprobe_meta': ffprobe_meta - } + 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 + } 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 diff --git a/app/core/models/node_storage.py b/app/core/models/node_storage.py index eb1e5d4..32824c1 100644 --- a/app/core/models/node_storage.py +++ b/app/core/models/node_storage.py @@ -29,7 +29,7 @@ class StoredContent(AlchemyBase, AudioContentMixin): user_id = Column(Integer, ForeignKey('users.id'), nullable=True) owner_address = Column(String(1024), nullable=True) - + btfs_cid = Column(String(1024), nullable=True) # На самом деле это CID контента в High качестве ipfs_cid = Column(String(1024), nullable=True) # На самом деле это CID контента в Low качестве telegram_cid = Column(String(1024), nullable=True) @@ -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