lbry-sdk/lbrynet/schema/legacy_schema_v1/stream.py

21 lines
735 B
Python
Raw Normal View History

from copy import deepcopy
from lbrynet.schema.schema.source import Source
2019-02-26 22:26:15 +01:00
from lbrynet.schema.proto2 import stream_pb2 as stream_pb
from lbrynet.schema.schema import VERSION_MAP
from lbrynet.schema.schema.metadata import Metadata
from lbrynet.schema.schema.schema import Schema
class Stream(Schema):
@classmethod
def load(cls, message):
_claim = deepcopy(message)
source = Source.load(_claim.pop('source'))
metadata = Metadata.load(_claim.pop('metadata'))
_message_pb = stream_pb.Stream()
_message_pb.version = VERSION_MAP[_claim.pop("version")]
_message_pb.source.CopyFrom(source)
_message_pb.metadata.CopyFrom(metadata)
return cls._load(_claim, _message_pb)