def _upload(
        self,
        source: str,
        source_type: str,
        media_type: str,
        name: str = None,
    ):
        """Upload the media with the given URL."""
        try:
            if media_type == "video":
                content = VideoContent(
                    agent_name=self.agent_name, status=MsgStatus.progress
                )
            else:
                content = TextContent(
                    agent_name=self.agent_name, status=MsgStatus.progress
                )
            self.output_message.content.append(content)
            content.status_message = f"Uploading {media_type}..."
            self.output_message.push_update()

            upload_data = self.videodb_tool.upload(
                source, source_type, media_type, name=name
            )

            content.status_message = f"{upload_data['name']} uploaded successfully"
            if media_type == "video":
                content.video = VideoData(**upload_data)
                # emit event to update the videos list
                self.session.emit_event(
                    VideosUpdateEvent(collection_id=upload_data.get("collection_id"))
                )
            else:
                content.text = (
                    f"\n ID: {upload_data['id']}, Title: {upload_data['name']}"
                )
            content.status = MsgStatus.success
            self.output_message.publish()
            return AgentResponse(
                status=AgentStatus.SUCCESS,
                message="Upload successful",
                data=upload_data,
            )

        except Exception as e:
            logger.exception(f"error in {self.agent_name} agent: {e}")
            content.status = MsgStatus.error
            content.status_message = f"Error in uploading {media_type}"
            self.output_message.publish()
            return AgentResponse(status=AgentStatus.ERROR, message=str(e))
Upload the media with the given URL.
backend/director/agents/upload.py