change metadata structure to use sources key
This commit is contained in:
parent
6c733f84e9
commit
e91f34f09b
1 changed files with 19 additions and 5 deletions
|
@ -297,10 +297,19 @@ class LBRYWallet(object):
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
return Failure(InvalidStreamInfoError(name))
|
return Failure(InvalidStreamInfoError(name))
|
||||||
known_fields = ['stream_hash', 'name', 'description', 'key_fee', 'key_fee_address', 'thumbnail',
|
known_fields = ['stream_hash', 'name', 'description', 'key_fee', 'key_fee_address', 'thumbnail',
|
||||||
'content_license']
|
'content_license', 'sources']
|
||||||
|
known_sources = ['lbry_sd_hash']
|
||||||
for field in known_fields:
|
for field in known_fields:
|
||||||
if field in value_dict:
|
if field in value_dict:
|
||||||
r_dict[field] = value_dict[field]
|
if field == 'sources':
|
||||||
|
for source in known_sources:
|
||||||
|
if source in value_dict[field]:
|
||||||
|
if source == 'lbry_sd_hash':
|
||||||
|
r_dict['stream_hash'] = value_dict[field][source]
|
||||||
|
else:
|
||||||
|
r_dict[source] = value_dict[field][source]
|
||||||
|
else:
|
||||||
|
r_dict[field] = value_dict[field]
|
||||||
if 'stream_hash' in r_dict and 'txid' in result:
|
if 'stream_hash' in r_dict and 'txid' in result:
|
||||||
d = self._save_name_metadata(name, r_dict['stream_hash'], str(result['txid']))
|
d = self._save_name_metadata(name, r_dict['stream_hash'], str(result['txid']))
|
||||||
else:
|
else:
|
||||||
|
@ -312,8 +321,8 @@ class LBRYWallet(object):
|
||||||
return Failure(UnknownNameError(name))
|
return Failure(UnknownNameError(name))
|
||||||
|
|
||||||
def claim_name(self, name, sd_hash, amount, description=None, key_fee=None,
|
def claim_name(self, name, sd_hash, amount, description=None, key_fee=None,
|
||||||
key_fee_address=None, thumbnail=None, content_license=None):
|
key_fee_address=None, thumbnail=None, content_license=None):
|
||||||
value = {"stream_hash": sd_hash}
|
value = {"sources": {'lbry_sd_hash': sd_hash}}
|
||||||
if description is not None:
|
if description is not None:
|
||||||
value['description'] = description
|
value['description'] = description
|
||||||
if key_fee is not None:
|
if key_fee is not None:
|
||||||
|
@ -397,7 +406,12 @@ class LBRYWallet(object):
|
||||||
value_dict = json.loads(claim['value'])
|
value_dict = json.loads(claim['value'])
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
return None
|
return None
|
||||||
if 'stream_hash' in value_dict and str(value_dict['stream_hash']) == sd_hash:
|
claim_sd_hash = None
|
||||||
|
if 'stream_hash' in value_dict:
|
||||||
|
claim_sd_hash = str(value_dict['stream_hash'])
|
||||||
|
if 'sources' in value_dict and 'lbrynet_sd_hash' in value_dict['sources']:
|
||||||
|
claim_sd_hash = str(value_dict['sources']['lbry_sd_hash'])
|
||||||
|
if claim_sd_hash is not None and claim_sd_hash == sd_hash:
|
||||||
if 'is controlling' in claim and claim['is controlling']:
|
if 'is controlling' in claim and claim['is controlling']:
|
||||||
return name, "valid"
|
return name, "valid"
|
||||||
if claim['in claim trie']:
|
if claim['in claim trie']:
|
||||||
|
|
Loading…
Reference in a new issue