mirror of
https://gitlab.com/vyla-entertainment/sdk.git
synced 2026-11-20 00:57:30 -05:00
Fixed merge conflicts
This commit is contained in:
3
src/sdk.d.ts
vendored
3
src/sdk.d.ts
vendored
@@ -59,6 +59,7 @@ export interface VylaSDKOptions {
|
|||||||
tmdbApiKey?: string;
|
tmdbApiKey?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Descriptions written with Claude.
|
||||||
export default class VylaSDK {
|
export default class VylaSDK {
|
||||||
tmdbApiKey?: string;
|
tmdbApiKey?: string;
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@ export default class VylaSDK {
|
|||||||
s?: number | null,
|
s?: number | null,
|
||||||
e?: number | null,
|
e?: number | null,
|
||||||
clientIP?: string | null
|
clientIP?: string | null
|
||||||
): Promise<StreamResult | {allUrls: StreamResult[]}>;
|
): Promise<StreamResult | { allUrls: StreamResult[] }>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get subtitles for a movie or TV episode.
|
* Get subtitles for a movie or TV episode.
|
||||||
|
|||||||
@@ -7,6 +7,103 @@ import VylaSDK from "../src/sdk.js";
|
|||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
const CONFIG = {
|
||||||
|
DEBUG: true, // Set to true to print outgoing requests, headers, formats, and responses
|
||||||
|
|
||||||
|
MOVIE_ID: "550", // Movie TMDB ID to test
|
||||||
|
TV_ID: "37854", // TV TMDB ID to test, for anime I recommend using a random ID like 37854
|
||||||
|
TV_SEASON: "1", // TV Season to test
|
||||||
|
TV_EPISODE: "1", // TV Episode to test
|
||||||
|
STREAM_SOURCE: "", // Source key to test
|
||||||
|
|
||||||
|
TEST_SUBTITLE: false, // Toggle subtitle testing
|
||||||
|
TEST_DOWNLOAD: false, // Toggle download testing
|
||||||
|
TEST_MOVIE: false, // Toggle movie testing
|
||||||
|
TEST_TV: true // Toggle TV testing
|
||||||
|
};
|
||||||
|
|
||||||
|
// debug
|
||||||
|
if (CONFIG.DEBUG) {
|
||||||
|
const originalFetch = globalThis.fetch;
|
||||||
|
|
||||||
|
const debugFile = path.resolve("test/debug-output.json");
|
||||||
|
fs.mkdirSync(path.dirname(debugFile), { recursive: true });
|
||||||
|
|
||||||
|
const logs = [];
|
||||||
|
|
||||||
|
const save = () => {
|
||||||
|
fs.writeFileSync(debugFile, JSON.stringify(logs, null, 2));
|
||||||
|
};
|
||||||
|
|
||||||
|
globalThis.fetch = async (input, init) => {
|
||||||
|
const url = typeof input === "string" ? input : input?.url || String(input);
|
||||||
|
|
||||||
|
const request = {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
request: {
|
||||||
|
url,
|
||||||
|
method: init?.method || "GET",
|
||||||
|
headers: init?.headers || {},
|
||||||
|
body: init?.body || null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("\nRequest:");
|
||||||
|
console.log(`URL: ${url}`);
|
||||||
|
console.log(`Method: ${request.request.method}`);
|
||||||
|
if (init?.headers) console.log("Headers:", JSON.stringify(init.headers, null, 2));
|
||||||
|
if (init?.body) console.log("Body:", init.body);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await originalFetch(input, init);
|
||||||
|
|
||||||
|
request.response = {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("\nResponse:");
|
||||||
|
console.log(`URL: ${url}`);
|
||||||
|
console.log(`Status: ${response.status} ${response.statusText}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const clone = response.clone();
|
||||||
|
const text = await clone.text();
|
||||||
|
|
||||||
|
try {
|
||||||
|
request.response.format = "json";
|
||||||
|
request.response.body = JSON.parse(text);
|
||||||
|
|
||||||
|
console.log("Format: JSON");
|
||||||
|
console.log(JSON.stringify(request.response.body, null, 2));
|
||||||
|
} catch {
|
||||||
|
request.response.format = "text";
|
||||||
|
request.response.body = text;
|
||||||
|
|
||||||
|
console.log("Format: Text/HTML");
|
||||||
|
console.log(text.substring(0, 800) + (text.length > 800 ? "..." : ""));
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
request.response.body = `<Failed to read response body: ${err.message}>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
logs.push(request);
|
||||||
|
save();
|
||||||
|
|
||||||
|
return response;
|
||||||
|
} catch (err) {
|
||||||
|
request.error = err.message;
|
||||||
|
logs.push(request);
|
||||||
|
save();
|
||||||
|
|
||||||
|
console.log(`URL: ${url}`);
|
||||||
|
console.log(`Error: ${err.message}`);
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const sdk = new VylaSDK({
|
const sdk = new VylaSDK({
|
||||||
tmdbApiKey: process.env.TMDB_API_KEY
|
tmdbApiKey: process.env.TMDB_API_KEY
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user