mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
refactor: remove unused extractors and clean up code
This commit is contained in:
@@ -3,10 +3,6 @@ const cheerio = require("cheerio");
|
|||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const { z } = require("zod");
|
const { z } = require("zod");
|
||||||
const { getBaseUrl } = require("./dist/getBaseUrl.js");
|
const { getBaseUrl } = require("./dist/getBaseUrl.js");
|
||||||
const { hubcloudExtracter } = require("./dist/hubcloudExtractor.js");
|
|
||||||
const { gofileExtracter } = require("./dist/gofileExtracter.js");
|
|
||||||
const { superVideoExtractor } = require("./dist/superVideoExtractor.js");
|
|
||||||
const { gdFlixExtracter } = require("./dist/gdFlixExtractor.js");
|
|
||||||
|
|
||||||
// Create readline interface
|
// Create readline interface
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
@@ -32,13 +28,7 @@ const providerContext = {
|
|||||||
"User-Agent":
|
"User-Agent":
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||||
},
|
},
|
||||||
extractors: {
|
Aes: {},
|
||||||
hubcloudExtracter: hubcloudExtracter,
|
|
||||||
gofileExtracter: gofileExtracter,
|
|
||||||
superVideoExtractor: superVideoExtractor,
|
|
||||||
gdFlixExtracter: gdFlixExtracter,
|
|
||||||
},
|
|
||||||
Crypto: {},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function parameter definitions based on README and types
|
// Function parameter definitions based on README and types
|
||||||
@@ -159,7 +149,7 @@ async function getParameters(functionName, providerName) {
|
|||||||
const sampleValue = sampleValues[functionName]?.[paramName] || "";
|
const sampleValue = sampleValues[functionName]?.[paramName] || "";
|
||||||
|
|
||||||
let value = await prompt(
|
let value = await prompt(
|
||||||
`${promptText}${sampleValue ? `[sample: ${sampleValue}] ` : ""}`
|
`${promptText}${sampleValue ? `[sample: ${sampleValue}] ` : ""}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!value && sampleValue) {
|
if (!value && sampleValue) {
|
||||||
@@ -207,7 +197,7 @@ async function testProvider(providerName, functionName) {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(
|
console.log(
|
||||||
`❌ Provider '${providerName}' not found or built. Make sure to run 'npm run build' first.`
|
`❌ Provider '${providerName}' not found or built. Make sure to run 'npm run build' first.`,
|
||||||
);
|
);
|
||||||
console.log(`Error: ${error.message}`);
|
console.log(`Error: ${error.message}`);
|
||||||
return;
|
return;
|
||||||
@@ -217,7 +207,7 @@ async function testProvider(providerName, functionName) {
|
|||||||
if (!module[functionName]) {
|
if (!module[functionName]) {
|
||||||
console.log(`❌ Function '${functionName}' not found in ${providerName}`);
|
console.log(`❌ Function '${functionName}' not found in ${providerName}`);
|
||||||
const availableFunctions = Object.keys(module).filter(
|
const availableFunctions = Object.keys(module).filter(
|
||||||
(key) => typeof module[key] === "function"
|
(key) => typeof module[key] === "function",
|
||||||
);
|
);
|
||||||
console.log(`Available functions: ${availableFunctions.join(", ")}`);
|
console.log(`Available functions: ${availableFunctions.join(", ")}`);
|
||||||
return;
|
return;
|
||||||
@@ -249,7 +239,7 @@ async function testProvider(providerName, functionName) {
|
|||||||
|
|
||||||
if (!validationResult.isValid) {
|
if (!validationResult.isValid) {
|
||||||
console.log(
|
console.log(
|
||||||
"\n💡 Tip: Check your provider implementation to ensure it returns the correct format."
|
"\n💡 Tip: Check your provider implementation to ensure it returns the correct format.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -281,7 +271,7 @@ const StreamSchema = z.object({
|
|||||||
language: z.string(),
|
language: z.string(),
|
||||||
type: z.string(),
|
type: z.string(),
|
||||||
uri: z.string().url(),
|
uri: z.string().url(),
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.optional(),
|
.optional(),
|
||||||
headers: z.any().optional(),
|
headers: z.any().optional(),
|
||||||
@@ -297,7 +287,7 @@ const LinkSchema = z.object({
|
|||||||
title: z.string().min(1, "Direct link title cannot be empty"),
|
title: z.string().min(1, "Direct link title cannot be empty"),
|
||||||
link: z.string().url("Direct link must be a valid URL"),
|
link: z.string().url("Direct link must be a valid URL"),
|
||||||
type: z.enum(["movie", "series"]).optional(),
|
type: z.enum(["movie", "series"]).optional(),
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.optional(),
|
.optional(),
|
||||||
});
|
});
|
||||||
@@ -421,7 +411,7 @@ async function main() {
|
|||||||
console.log("\nFlags:");
|
console.log("\nFlags:");
|
||||||
console.log(" --rebuild Rebuild TypeScript files before testing");
|
console.log(" --rebuild Rebuild TypeScript files before testing");
|
||||||
console.log(
|
console.log(
|
||||||
"\nNote: Run with --rebuild flag if you've made changes to TypeScript files!"
|
"\nNote: Run with --rebuild flag if you've made changes to TypeScript files!",
|
||||||
);
|
);
|
||||||
rl.close();
|
rl.close();
|
||||||
return;
|
return;
|
||||||
@@ -430,16 +420,15 @@ async function main() {
|
|||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
console.log("❌ Please provide both provider name and function name");
|
console.log("❌ Please provide both provider name and function name");
|
||||||
console.log(
|
console.log(
|
||||||
"Usage: node test-provider.js <provider> <function> [--rebuild]"
|
"Usage: node test-provider.js <provider> <function> [--rebuild]",
|
||||||
);
|
);
|
||||||
rl.close();
|
rl.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const providerName = args[0];
|
const providerName = args[0];
|
||||||
const functionName = args[1];
|
|
||||||
|
|
||||||
// Validate function name
|
// Validate function name (case-insensitive)
|
||||||
const validFunctions = [
|
const validFunctions = [
|
||||||
"getPosts",
|
"getPosts",
|
||||||
"getSearchPosts",
|
"getSearchPosts",
|
||||||
@@ -447,8 +436,11 @@ async function main() {
|
|||||||
"getEpisodes",
|
"getEpisodes",
|
||||||
"getStream",
|
"getStream",
|
||||||
];
|
];
|
||||||
|
const functionName =
|
||||||
|
validFunctions.find((f) => f.toLowerCase() === args[1].toLowerCase()) ??
|
||||||
|
args[1];
|
||||||
if (!validFunctions.includes(functionName)) {
|
if (!validFunctions.includes(functionName)) {
|
||||||
console.log(`❌ Invalid function name: ${functionName}`);
|
console.log(`❌ Invalid function name: ${args[1]}`);
|
||||||
console.log(`Valid functions: ${validFunctions.join(", ")}`);
|
console.log(`Valid functions: ${validFunctions.join(", ")}`);
|
||||||
rl.close();
|
rl.close();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user