made sdk docs up to date

This commit is contained in:
2026-11-15 21:05:56 -08:00
parent 03d468cb8a
commit cd487cb189
5 changed files with 370 additions and 125 deletions

View File

@@ -1,6 +1,6 @@
# Vyla SDK Quickstart
<p class="page-description">Get up and running with the Vyla SDK in under five minutes. Learn how to resolve movies, television episodes, subtitles, and downloads.</p>
<p class="page-description">Get up and running with the Vyla SDK in under five minutes. Learn how to resolve movies, television episodes, embed URLs, subtitles, and downloads.</p>
## Prerequisites
@@ -49,9 +49,8 @@ const tmdbId = 155;
try {
const result = await sdk.getStream(sourceKey, tmdbId);
console.log('Stream Candidate URL:', result.url);
console.log('Container Type:', result.type);
console.log('Video Quality:', result.quality);
console.log('Upstream Server:', result.server);
console.log('All Candidates:', result.allUrls.length);
console.log('Headers:', result.headers);
} catch (error) {
console.error(`Failed to resolve ${sourceKey}:`, error.message);
}
@@ -78,7 +77,24 @@ try {
---
## 4. Multi-Source Concurrent Resolution with Fallbacks
## 4. Filtering Dedicated vs. Aggregator Sources
Sources in `config.js` mark single-host/dedicated providers with `dedicated: true`, while multi-provider aggregators omit it:
```javascript
import { DEDICATED_SOURCES, AGGREGATOR_SOURCES } from '@vyla-entertainment/sdk/src/config.js';
const activeSources = sdk.getSources(true);
const dedicatedActive = activeSources.filter(cfg => cfg.dedicated);
const aggregatorActive = activeSources.filter(cfg => !cfg.dedicated);
console.log(`Dedicated: ${DEDICATED_SOURCES.length}, Aggregators: ${AGGREGATOR_SOURCES.length}`);
console.log(`Active Dedicated: ${dedicatedActive.length}, Active Aggregators: ${aggregatorActive.length}`);
```
---
## 5. Multi-Source Concurrent Resolution with Fallbacks
In production, you should query multiple active providers concurrently and select the fastest viable stream:
@@ -90,10 +106,11 @@ async function resolveFastestStream(tmdbId, s = null, e = null) {
try {
const stream = await Promise.race([
sdk.getStream(cfg.key, tmdbId, s, e),
new Promise((_, reject) =>
new Promise((_, reject) =>
setTimeout(() => reject(new Error('Timeout')), cfg.timeout || 10000)
)
]);
if (!stream?.url) return null;
return { source: cfg.key, label: cfg.label, stream };
} catch {
return null;
@@ -117,9 +134,39 @@ console.log('Primary Source:', sources[0].label, sources[0].stream.url);
---
## 5. Fetching Subtitles and Downloads
## 6. Using Embed Player Configurations
Subtitles and direct download links can be fetched in parallel:
Use `EMBEDS` or `EMBED_MAP` from `embed_config.js` to build iframe player URLs for movies and TV episodes, and filter by `ads === false` when you only want ad-free embeds:
```javascript
import EMBEDS, { EMBED_MAP } from '@vyla-entertainment/sdk/src/embed_config.js';
const adFreeEmbeds = EMBEDS.filter(embed => embed.ads === false);
console.log('Ad-free embeds:', adFreeEmbeds.map(e => e.label).join(', '));
function buildEmbedUrl(key, tmdbId, season = null, episode = null) {
const cfg = EMBED_MAP[key];
if (!cfg) return null;
if (season != null && episode != null) {
return cfg.tv
.replace('{id}', encodeURIComponent(tmdbId))
.replace('{s}', encodeURIComponent(season))
.replace('{e}', encodeURIComponent(episode));
}
return cfg.movie.replace('{id}', encodeURIComponent(tmdbId));
}
console.log('Movie Embed:', buildEmbedUrl('cinezo', 155));
console.log('TV Embed:', buildEmbedUrl('cinesrc', 1396, 1, 1));
```
---
## 7. Fetching Subtitles and Downloads
Subtitles and direct MP4 download links can be fetched in parallel:
```javascript
const [subtitles, downloads] = await Promise.all([
@@ -132,15 +179,15 @@ subtitles.slice(0, 5).forEach((sub) => {
console.log(`[${sub.type.toUpperCase()}] ${sub.label}: ${sub.file}`);
});
console.log('--- Download Packages ---');
console.log('--- Download Links ---');
downloads.forEach((dl) => {
console.log(`[${dl.quality}] Size: ${dl.size ? (dl.size / (1024**3)).toFixed(2) + ' GB' : 'Unknown'} -> ${dl.url}`);
console.log(`[${dl.source}] ${dl.label} -> ${dl.url}`);
});
```
---
## 6. Live Source Health Probing
## 8. Live Source Health Probing
To check which providers are operational in your network environment:
@@ -149,7 +196,7 @@ const healthReport = await sdk.probeAllSources();
for (const [key, status] of Object.entries(healthReport)) {
const icon = status.ok ? 'OK' : 'FAIL';
console.log(`[${icon}] ${key}: ${status.ok ? status.ms + 'ms' : 'offline'}`);
console.log(`[${icon}] ${key}: ${status.ok ? `${status.ms}ms (movie=${status.movie}, tv=${status.tv})` : 'offline'}`);
}
```
@@ -157,6 +204,6 @@ for (const [key, status] of Object.entries(healthReport)) {
## Next Steps
- Consult the [Complete API Reference](reference.md) for exhaustive class and method parameters.
- Consult the [Complete API Reference](reference.md) for exhaustive class, config, and method parameters.
- Learn how to integrate manga reading with the [Manga SDK Guide](manga.md).
- Deploy an HTTP/SSE bridge with the [Stream API Guide](../../stream-api/overview/index.md).
- Deploy an HTTP/SSE bridge with the [Stream API Guide](../../stream-api/overview)