lbryio / lbry-sdk

The LBRY SDK for building decentralized, censorship resistant, monetized, digital content apps.
https://lbry.com
MIT License
7.19k stars 482 forks source link

claim_search: finds livestream claims when `stream_types=['binary']` #3472

Closed belikor closed 2 years ago

belikor commented 2 years ago

This will return livestreams claims and only a few actual binary files (zip files for example).

msg = {'method': 'claim_search',
       'params': {'page': 1,
                  'page_size': 50,
                  'no_totals': True,
                  'order_by': 'trending_mixed',
                  'claim_type': "stream",
                  'stream_types': ['binary']}}
items = requests.post("http://localhost:5279", json=msg).json()["result"]["items"]

for i in items:
    print(i["value_type"], i["value"].get("stream_type", None), i["name"])

In the next example, we specifically search for stream claims with no source, that is, these should be only livestreams.

msg2 = {'method': 'claim_search',
        'params': {'page': 1,
                   'page_size': 50,
                   'no_totals': True,
                   'order_by': 'trending_mixed',
                   'claim_type': "stream",
                   'has_no_source': True}}
items2 = requests.post("http://localhost:5279", json=msg2).json()["result"]["items"]

for i in items2:
    print(i["value_type"], i["value"].get("stream_type", None), i["name"])

So it seems to me that in the first case, it should return only the binary files, and omit livestream claims that don't have a source.

I found a reference in lbry.schema.mime_types that it returns a "binary" if it cannot guess the stream type. So maybe this is the reason the livestreams are reported as "binary". Probably it can be a different default value.

https://github.com/lbryio/lbry-sdk/blob/ddbbb6f1dd9e5117eb503841ef43cb0f2b2fb37a/lbry/schema/mime_types.py#L180-L184