mirror of
https://gitlab.com/vyla-entertainment/sdk.git
synced 2026-11-14 06:07:34 -05:00
Merge branch 'main' of https://github.com/vyla-entertainment/sdk
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@vyla-entertainment/sdk",
|
||||
"version": "1.5.0",
|
||||
"version": "1.6.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@vyla-entertainment/sdk",
|
||||
"version": "1.5.0",
|
||||
"version": "1.6.0",
|
||||
"license": "CC-BY-NC-4.0",
|
||||
"devDependencies": {
|
||||
"dotenv": "^17.4.2"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vyla-entertainment/sdk",
|
||||
"version": "1.5.0",
|
||||
"version": "1.6.0",
|
||||
"scripts": {
|
||||
"test": "node test/index.js"
|
||||
},
|
||||
@@ -29,4 +29,4 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
src/sdk.d.ts
vendored
2
src/sdk.d.ts
vendored
@@ -94,7 +94,7 @@ export default class VylaSDK {
|
||||
s?: number | null,
|
||||
e?: number | null,
|
||||
clientIP?: string | null
|
||||
): Promise<{allUrls: StreamResult[]}>;
|
||||
): Promise<StreamResult | {allUrls: StreamResult[]}>;
|
||||
|
||||
/**
|
||||
* Get subtitles for a movie or TV episode.
|
||||
|
||||
@@ -7,103 +7,6 @@ import VylaSDK from "../src/sdk.js";
|
||||
import dotenv from "dotenv";
|
||||
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({
|
||||
tmdbApiKey: process.env.TMDB_API_KEY
|
||||
});
|
||||
@@ -182,4 +85,4 @@ if (CONFIG.TEST_TV) {
|
||||
}
|
||||
} else {
|
||||
console.log("\nSkipped Stream Test");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user