lbrytools
A library of functions that can be used to manage the download of claims from the LBRY network. It includes methods to download claims by URI (canonical url), claim ID, or from specific channels.
It also includes methods to clean up older files and free space, so the functions are suitable for use in a headless computer that will download files, and seed them to the network with little user intervention.
This libary is released as free software under the MIT license.
Motivation
The LBRY Desktop application provides basic functionality to manage downloaded claims. Real control of the system is achieved with the lbrynet
headless client, also called the lbry-sdk.
This library provides convenience functions that wrap around lbrynet
in order to search, download, and delete many claims easier.
This library is inspired by tuxfoo's lbry-seedit script, which provides basic functions, and a configuration file to download and seed claims. Initially tuxfoo's code was extended slightly but eventually an entire library was written from scratch to provide more functionality.
Installation
You must have the LBRY Desktop application or the lbrynet
client. Get them from lbry.com/get.
You must have Python installed. Most Linux distributions come with Python ready to use; for Windows you may need to get the official package, or a full featured distribution such as Anaconda.
Copy the internal lbrytools directory, and place it inside a site-packages
directory that is searched by Python. This can be in the user's home directory,
/home/user/.local/lib/python3.8/site-packages/lbrytools
or in a system-wide directory:
/usr/local/lib/python3.8/dist-packages/lbrytools
/usr/lib/python3/dist-packages/lbrytools
You can also modify the PYTHONPATH
environmental variable to include the parent directory where lbrytools
is located:
PYTHONPATH=/opt/git/lbrytools:$PYTHONPATH
This library was developed and tested with Python 3.8 but it may also work with earlier versions with small changes. It uses standard modules such as importlib
, os
, random
, requests
, sys
, and time
.
Usage
Make sure the lbrynet
daemon is running either by launching the full LBRY Desktop application, or by starting the console lbrynet
program.
lbrynet start
Then open a Python console, import the module, and use its methods.
import lbrytools as lbryt
lbryt.download_single(...)
lbryt.ch_download_latest(...)
lbryt.ch_download_latest_multi(...)
lbryt.redownload_latest(...)
lbryt.download_claims(...)
lbryt.print_summary()
lbryt.print_channels()
lbryt.delete_single(...)
lbryt.ch_cleanup(...)
lbryt.ch_cleanup_multi(...)
lbryt.remove_claims(...)
lbryt.measure_usage(...)
lbryt.cleanup_space(...)
lbryt.remove_media()
lbryt.count_blobs(...)
lbryt.count_blobs_all(...)
lbryt.analyze_blobs(...)
lbryt.download_missing_blobs(...)
lbryt.analyze_channel(...)
lbryt.print_channel_analysis(...)
lbryt.blobs_move(...)
lbryt.blobs_move_all(...)
lbryt.claims_bids(...)
lbryt.channel_subs(...)
lbryt.list_accounts(...)
lbryt.list_playlists(...)
lbryt.list_supports(...)
lbryt.print_blobs_ratio(...)
lbryt.create_support(...)
lbryt.abandon_support(...)
lbryt.target_support(...)
Read the lbrytools.md file for a short explanation on the most useful functions in the library.
Zeedit script
This script uses the lbrytools
methods to achieve the same objective as tuxfoo's original lbry-seedit. It downloads content from various channels, and then seeds the blobs to the network. This script should be run periodically to constantly download new content, and remove the older files if they take too much space. See zeedit.py.
If lbrytools
is correctly installed in the Python path, the script can be executed directly, or through the Python interpreter.
python zeedit.py [config.py]
A configuration file should be passed as the first argument.
python zeedit.py funny_config.py
python zeedit.py tech_channels_config.py
python zeedit.py cooking_conf.py
The configuration file specifies the channels to download content from, the download directory, the limit in gigabytes before cleanup of older files is started, and whether to write a summary of all downloaded claims. Modify the zeedit_config_example.py to your liking, and read the comments in it to understand what each variable does. Only the channels
variable is mandatory, all others have a default value if they are missing in the configuration file.
If no argument is given, or if the provided configuration file does not exist, it will default to loading a configuration under the name zeedit_config.py
; if this is not available, it will simply exit.
To keep everything contained, the lbrytools
package can be placed in the same directory as zeedit.py
and zeedit_config.py
.
zeedit/
zeedit.py
zeedit_config.py
lbrytools/
__init___.py
blobs.py
...
Development
Ideally, this collection of tools can be merged into the official LBRY sources so that everybody has access to them. Where possible, the tools should also be available from a graphical interface such as the LBRY Desktop application.
If you wish to support this work you can send a donation:
LBC: bY38MHNfE59ncq3Ch3zLW5g41ckGoHMzDq
XMR: 8565RALsab2cWsSyLg4v1dbLkd3quc7sciqFJ2mpfip6PeVyBt4ZUbZesAAVpKG1M31Qi5k9mpDSGSDpb3fK5hKYSUs8Zff