Libtorrent made easy
This is pythonic high-level libtorrent API, inspired on the for-humans trend set by Kenneth Reitz (https://github.com/not-kennethreitz).
TorrentStream is centered around the principle of streaming a torrent (sequential download, buffering and playing).
TorrentStream exposes a CLI command, intended as an example usage.
Torrent objects are context managers that can clean up torrent content after you finish using them.
add_torrent method of a TorrentSession returns a Torrent object, thus can be used directly as a context manager.
async def stream_torrent(hash_torrent):
session = TorrentSession()
# By default this will cleanup torrent contents after playing
with session.add_torrent(magnet_link=hash_torrent, remove_after=True) as torrent:
# Force sequential mode
torrent.sequential(True)
# Wait for torrent to be started
await torrent.wait_for('started')
# Get first match of a media file
try:
media = next(a for a in torrent
if a.is_media and not 'sample' in a.path.lower())
except StopIteration:
raise Exception('Could not find a playable source')
with timeout(5 * 60): # Abort if we can't fill 5% in 5 minutes
await media.wait_for_completion(5)
return await asyncio.gather(media.wait_for_completion(100),
media.launch())
Metadata
Release files for torrentstream 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torrentstream-0.3.1.tar.gz | 5.7 kB | Without provenance | Details for torrentstream-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torrentstream-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for torrentstream-0.3.1-py3-none-any.whl |
Total release size: 12.1 kB
Release files / torrentstream-0.3.1.tar.gz
| Download URL | torrentstream-0.3.1.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b514fedaf3500386f665cdf22454286871d99eb983f5551b2a9afd212fa04c0
|
|
BLAKE2b-256 checksum How to use checksums |
067d126f242f9128f3b18bfe51ec20d394bdca96b0f3241764021b7529a109c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.5 Linux/5.12.11-arch1-1
|
Release files / torrentstream-0.3.1-py3-none-any.whl
| Download URL | torrentstream-0.3.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11ee5743e63ea8e0d499b26fd9874125f603636050d4df9b39fcf2566d664ce1
|
|
BLAKE2b-256 checksum How to use checksums |
414881bcb9521faa018f86b35e0dfd9a9f3005a5c067881f62924b3a2e4f8014
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.5 Linux/5.12.11-arch1-1
|
Security for torrentstream 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.