
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
@webtor/platform-sdk-js
Advanced tools
SDK for online torrent streaming
Before moving further we must be sure that webtor backend api is already installed. Just follow this guide to setup all the things.
npm install @webtor/platform-sdk-js
or
yarn add @webtor/platform-sdk-js
Just a simple example of fetching torrent by magnet-uri, getting streaming url and stats:
import webtor from '@webtor/platform-sdk-js';
const sdk = webtor({
apiUrl: '...',
});
const magnetUri = '...';
const torrent = await sdk.magnet.fetchTorrent(magnetUri);
const expire = 60*60*24;
await sdk.torrent.push(torrent, expire);
const seeder = sdk.seeder.get(torrent.infoHash);
const filePath = torrent.files[0].path;
const url = await seeder.streamUrl(filePath);
console.log(url);
// NOTE: stats will become available only after content url access
seeder.stats(filePath, (path, data) => {
console.log(data);
});
You can find fully working example here!
const sdk = webtor(options)
options
should be the following:
{
apiUrl: String, // API url (required)
apiKey: String, // API key
downloadUrl: String, // All download urls will contain this location
tokenUrl: String, // API will get access-token from this location
tokenRenewInterval: Number, // Renews access-token after specific period in ms
grpcDebug: Boolean, // If enabled shows grpc-web debug output
statsRetryInterval: Number, // If stats not available for this file it will retry after specific period in ms (default=3000)
getToken: function() Promise // If defined custom token-function will be used
}
Provides functions for storing and retriving torrent-files.
sdk.torrent.fromUrl(url)
Fetches parsed torrent from specific url. Be sure that appropriate CORS-headers are set on server-side in case of cross-site request (Access-Control-Allow-Origin: *
).
sdk.torrent.pull(infoHash)
Pulls parsed torrent by infoHash from torrent-store.
sdk.torrent.push(torrent, expire)
Pushes parsed torrent to torrent-store with specific expiration time in seconds. We can use any parsed torrent generated by parse-torrent there.
sdk.torrent.touch(torrent, expire)
Just renews expiration date of torrent-file.
Provides functions for working with magnet-urls.
sdk.magnet.fetchTorrent(magnet)
Fetches parsed torrent by magnet-uri.
Provides functions for retriving and streaming torrent-content.
const seeder = sdk.seeder.get(infoHash)
Returns seeder instance for the specific torrent stored in torrent-store.
seeder.url(path)
Returns url
for original source file.
seeder.streamUrl(path, viewSettings = {})
Returns url capable for web-streaming.
viewSettings
should be provided only in case of content trnascoding.
Possible viewSettings
:
{
a: Number, // Selected audio channel
s: Number, // Selected subtitle channel
}
seeder.streamSubtitleUrl(path, viewSettings = {})
Returns subtitle-url capable for web-streaming. Can be used only for hls-transcoded content.
viewSettings
should be provided only in case of content trnascoding.
Possible viewSettings
:
{
a: Number, // Selected audio channel
s: Number, // Selected subtitle channel
}
seeder.mediaInfo(path)
Returns FFmpeg probing data. If content should not be transcoded only empty object {}
will be returned.
seeder.downloadUrl(path)
Returns download url.
seeder.zipUrl(path)
Returns download url of zip-archive. Generates zip-archive of all files under directory and subdirectories specified by the path
.
seeder.openSubtitles(path)
Returns object that includes all subtitles from OpenSubtitles.org. Automatically generates streaming urls for every subtitle (srt => vtt encoding).
const statClient = seeder.stats(path, function(path, data) { ... })
Receives status of specific file. Possible data:
{
total: Number // Number of total bytes
completed: Number // Number of completed bytes
peers: Number // Total number of peers
piecesList: [] // Array of pieces
}
Also returns instance of stat client.
statClient.close()
Closes stat client
Provides functions for retriving and streaming external resources.
sdk.ext.url(url)
Returns url
for original external file proxied by the api. Can resolve CORS-issues.
sdk.ext.streamUrl(url, viewSettings = {})
Same as seeder.streamUrl
but for external resource.
sdk.ext.streamSubtitleUrl(url, viewSettings = {})
Same as seeder.streamSubtitleUrl
but for external resource.
sdk.ext.mediaInfo(url)
Same as seeder.mediaInfo
but for external resource.
sdk.ext.openSubtitles(url)
Same as seeder.openSubtitles
but for external resource.
FAQs
SDK for online torrent streaming
The npm package @webtor/platform-sdk-js receives a total of 7 weekly downloads. As such, @webtor/platform-sdk-js popularity was classified as not popular.
We found that @webtor/platform-sdk-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.