forked from LBRYCommunity/lbry-sdk
no api yet
This commit is contained in:
parent
9d3c401abb
commit
85474ae381
4 changed files with 0 additions and 95 deletions
|
@ -3030,59 +3030,6 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
}
|
}
|
||||||
return base58.b58encode(json.dumps(export, separators=(',', ':')))
|
return base58.b58encode(json.dumps(export, separators=(',', ':')))
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT)
|
|
||||||
def jsonrpc_channel_subscription_list(self):
|
|
||||||
"""
|
|
||||||
List subscribed channels and modes.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
channel_subscription_list
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
(list) [(channel_id, download_latest, download_all)]
|
|
||||||
"""
|
|
||||||
return self.storage.get_subscriptions()
|
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT)
|
|
||||||
def jsonrpc_channel_subscribe(self, channel_id, download_latest=None, download_all=False):
|
|
||||||
"""
|
|
||||||
Subscribe to a channel and optionally start downloading streams proactively.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
channel_subscribe (<channel_id> | --channel_id=<channel_id>) [--download_latest=<download_latest>]
|
|
||||||
[--download_all]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--channel_id=<channel_id> : (str) claim id of channel to subscribe.
|
|
||||||
--download_latest=<download_latest> : (int) amount of newest streams to ensure download.
|
|
||||||
--download_all : (bool) download all streams from the channel.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
(bool) Subscription successful? (False only if channel doesn't exist)
|
|
||||||
"""
|
|
||||||
if download_all and download_latest is not None:
|
|
||||||
raise ConflictingInputValueError("download_latest", "download_all")
|
|
||||||
return self.storage.add_subscription(channel_id, download_latest, download_all)
|
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT)
|
|
||||||
def jsonrpc_channel_unsubscribe(self, channel_id):
|
|
||||||
"""
|
|
||||||
Subscribe to a channel and optionally start downloading streams proactively.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
channel_subscribe (<channel_id> | --channel_id=<channel_id>) [--download=<download>]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--channel_id=<channel_id> : (str) claim id of channel to subscribe
|
|
||||||
--download=<download> : (str) which strategy to use for downloads: 'all' for everything.
|
|
||||||
'latest-X' for the latest X streams. None (default) for nothing.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
(bool) Subscription successful? (False only if channel doesn't exist)
|
|
||||||
"""
|
|
||||||
return self.storage.remove_subscription(channel_id)
|
|
||||||
|
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT)
|
@requires(WALLET_COMPONENT)
|
||||||
async def jsonrpc_channel_import(self, channel_data, wallet_id=None):
|
async def jsonrpc_channel_import(self, channel_data, wallet_id=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -235,12 +235,6 @@ class SQLiteStorage(SQLiteMixin):
|
||||||
pragma foreign_keys=on;
|
pragma foreign_keys=on;
|
||||||
pragma journal_mode=WAL;
|
pragma journal_mode=WAL;
|
||||||
|
|
||||||
create table if not exists subscription (
|
|
||||||
channel_id char(40) primary key not null,
|
|
||||||
download_latest integer not null default 0,
|
|
||||||
download_all integer not null default 0
|
|
||||||
);
|
|
||||||
|
|
||||||
create table if not exists blob (
|
create table if not exists blob (
|
||||||
blob_hash char(96) primary key not null,
|
blob_hash char(96) primary key not null,
|
||||||
blob_length integer not null,
|
blob_length integer not null,
|
||||||
|
@ -545,19 +539,6 @@ class SQLiteStorage(SQLiteMixin):
|
||||||
async def delete_torrent(self, bt_infohash: str):
|
async def delete_torrent(self, bt_infohash: str):
|
||||||
return await self.db.run(delete_torrent, bt_infohash)
|
return await self.db.run(delete_torrent, bt_infohash)
|
||||||
|
|
||||||
# # # # # # # # # subscriptions # # # # # # # # #
|
|
||||||
|
|
||||||
def add_subscription(self, channel_id, download_latest=None, download_all=None):
|
|
||||||
return self.db.execute_fetchall(
|
|
||||||
"insert or replace into subscription(channel_id, download_latest, download_all) values (?, ?, ?)",
|
|
||||||
(channel_id, download_latest or 0, 1 if download_all else 0))
|
|
||||||
|
|
||||||
def remove_subscription(self, channel_id):
|
|
||||||
return self.db.execute_fetchall("delete from subscription where channel_id=?", (channel_id,))
|
|
||||||
|
|
||||||
def get_subscriptions(self):
|
|
||||||
return self.db.execute_fetchall("select channel_id, download_latest, download_all from subscription")
|
|
||||||
|
|
||||||
# # # # # # # # # file stuff # # # # # # # # #
|
# # # # # # # # # file stuff # # # # # # # # #
|
||||||
|
|
||||||
def save_downloaded_file(self, stream_hash: str, file_name: typing.Optional[str],
|
def save_downloaded_file(self, stream_hash: str, file_name: typing.Optional[str],
|
||||||
|
|
|
@ -246,10 +246,6 @@ class ManagedStream(ManagedDownloadSource):
|
||||||
handle.write(data)
|
handle.write(data)
|
||||||
handle.flush()
|
handle.flush()
|
||||||
|
|
||||||
async def save_blobs(self):
|
|
||||||
async for _ in self._aiter_read_stream(0, connection_id=self.STREAMING_ID):
|
|
||||||
pass
|
|
||||||
|
|
||||||
async def _save_file(self, output_path: str):
|
async def _save_file(self, output_path: str):
|
||||||
log.info("save file for lbry://%s#%s (sd hash %s...) -> %s", self.claim_name, self.claim_id, self.sd_hash[:6],
|
log.info("save file for lbry://%s#%s (sd hash %s...) -> %s", self.claim_name, self.claim_id, self.sd_hash[:6],
|
||||||
output_path)
|
output_path)
|
||||||
|
|
|
@ -616,22 +616,3 @@ class TestProactiveDownloaderComponent(CommandTestCase):
|
||||||
self.assertEqual(0, len(await self.file_list()))
|
self.assertEqual(0, len(await self.file_list()))
|
||||||
await self.daemon.blob_manager.delete_blobs(list(self.daemon.blob_manager.completed_blob_hashes), True)
|
await self.daemon.blob_manager.delete_blobs(list(self.daemon.blob_manager.completed_blob_hashes), True)
|
||||||
self.assertEqual(0, len((await self.daemon.jsonrpc_blob_list())['items']))
|
self.assertEqual(0, len((await self.daemon.jsonrpc_blob_list())['items']))
|
||||||
|
|
||||||
await proactive_downloader.stop()
|
|
||||||
await self.daemon.jsonrpc_channel_subscribe(channel_id, 1)
|
|
||||||
await proactive_downloader.start()
|
|
||||||
await proactive_downloader.finished_iteration.wait()
|
|
||||||
await self.assertBlobs(content1)
|
|
||||||
await self.daemon.jsonrpc_file_delete(delete_all=True)
|
|
||||||
|
|
||||||
await self.daemon.jsonrpc_channel_subscribe(channel_id, download_all=True)
|
|
||||||
await proactive_downloader.stop()
|
|
||||||
await proactive_downloader.start()
|
|
||||||
await proactive_downloader.finished_iteration.wait()
|
|
||||||
await self.assertBlobs(content1, content2)
|
|
||||||
|
|
||||||
self.assertEqual(0, len(await self.file_list()))
|
|
||||||
|
|
||||||
self.assertEqual([(channel_id, 0, 1)], await self.daemon.jsonrpc_channel_subscription_list())
|
|
||||||
await self.daemon.jsonrpc_channel_unsubscribe(channel_id)
|
|
||||||
self.assertEqual([], await self.daemon.jsonrpc_channel_subscription_list())
|
|
||||||
|
|
Loading…
Reference in a new issue