diff --git a/CHANGELOG.md b/CHANGELOG.md index 647f1c7bc..238489da5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ at anytime. * Fixed handling decryption error for blobs encrypted with an invalid key * Fixed handling stream with no data blob (https://github.com/lbryio/lbry/issues/905) * Fixed fetching the external ip + * Fixed API call to blob_list with --uri parameter (https://github.com/lbryio/lbry/issues/895) ### Deprecated * `channel_list_mine`, replaced with `channel_list` diff --git a/lbrynet/core/utils.py b/lbrynet/core/utils.py index 3fc867f4e..2d295f718 100644 --- a/lbrynet/core/utils.py +++ b/lbrynet/core/utils.py @@ -134,7 +134,14 @@ def get_sd_hash(stream_info): return None if isinstance(stream_info, ClaimDict): return stream_info.source_hash - return stream_info['stream']['source']['source'] + result = stream_info.get('claim', {}).\ + get('value', {}).\ + get('stream', {}).\ + get('source', {}).\ + get('source') + if not result: + log.warn("Unable to get sd_hash") + return result def json_dumps_pretty(obj, **kwargs): diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index d19ce92b7..e65c76f9a 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -2881,7 +2881,10 @@ class Daemon(AuthJSONRPCServer): if uri: metadata = yield self._resolve_name(uri) sd_hash = utils.get_sd_hash(metadata) - blobs = yield self.get_blobs_for_sd_hash(sd_hash) + try: + blobs = yield self.get_blobs_for_sd_hash(sd_hash) + except NoSuchSDHash: + blobs = [] elif stream_hash: try: blobs = yield self.get_blobs_for_stream_hash(stream_hash) diff --git a/lbrynet/tests/unit/core/test_utils.py b/lbrynet/tests/unit/core/test_utils.py index b7eecea60..9575108be 100644 --- a/lbrynet/tests/unit/core/test_utils.py +++ b/lbrynet/tests/unit/core/test_utils.py @@ -31,3 +31,33 @@ class ObfuscationTest(unittest.TestCase): plain = '☃' obf = utils.obfuscate(plain) self.assertEqual(plain, utils.deobfuscate(obf)) + + +class SdHashTests(unittest.TestCase): + + def test_none_in_none_out(self): + self.assertIsNone(utils.get_sd_hash(None)) + + def test_ordinary_dict(self): + claim = { + "claim": { + "value": { + "stream": { + "source": { + "source": "0123456789ABCDEF" + } + } + } + } + } + self.assertEqual("0123456789ABCDEF", utils.get_sd_hash(claim)) + + def test_old_shape_fails(self): + claim = { + "stream": { + "source": { + "source": "0123456789ABCDEF" + } + } + } + self.assertIsNone(utils.get_sd_hash(claim))