mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
fix: update axios request to include base URL in getMeta function and refactor decodeHtml function in posts
This commit is contained in:
@@ -9,8 +9,10 @@ export const getMeta = async function ({
|
|||||||
}): Promise<Info> {
|
}): Promise<Info> {
|
||||||
try {
|
try {
|
||||||
const { axios, cheerio, getBaseUrl } = providerContext;
|
const { axios, cheerio, getBaseUrl } = providerContext;
|
||||||
|
const baseUrl = await getBaseUrl("protonMovies");
|
||||||
|
|
||||||
console.log("all", link);
|
console.log("all", link);
|
||||||
const res = await axios.get(link);
|
const res = await axios.get(`${baseUrl}${link}`);
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
|
|
||||||
function decodeHtml(encodedArray: string[]): string {
|
function decodeHtml(encodedArray: string[]): string {
|
||||||
@@ -62,7 +64,6 @@ export const getMeta = async function ({
|
|||||||
.slice(0, 3)
|
.slice(0, 3)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
const baseUrl = await getBaseUrl("protonMovies");
|
|
||||||
const links: Link[] = [];
|
const links: Link[] = [];
|
||||||
|
|
||||||
if (type === "movie") {
|
if (type === "movie") {
|
||||||
|
|||||||
@@ -49,29 +49,29 @@ async function posts({
|
|||||||
axios: ProviderContext["axios"];
|
axios: ProviderContext["axios"];
|
||||||
cheerio: ProviderContext["cheerio"];
|
cheerio: ProviderContext["cheerio"];
|
||||||
}): Promise<Post[]> {
|
}): Promise<Post[]> {
|
||||||
function decodeHtml(encodedArray: string[]): string {
|
|
||||||
// Join array elements into a single string
|
|
||||||
const joined = encodedArray.join("");
|
|
||||||
|
|
||||||
// Replace escaped quotes
|
|
||||||
const unescaped = joined.replace(/\\"/g, '"').replace(/\\'/g, "'");
|
|
||||||
|
|
||||||
// Remove remaining escape characters
|
|
||||||
const cleaned = unescaped
|
|
||||||
.replace(/\\n/g, "\n")
|
|
||||||
.replace(/\\t/g, "\t")
|
|
||||||
.replace(/\\r/g, "\r");
|
|
||||||
|
|
||||||
// Convert literal string representations back to characters
|
|
||||||
const decoded = cleaned
|
|
||||||
.replace(/"/g, '"')
|
|
||||||
.replace(/</g, "<")
|
|
||||||
.replace(/>/g, ">")
|
|
||||||
.replace(/&/g, "&");
|
|
||||||
|
|
||||||
return decoded;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
function decodeHtml(encodedArray: string[]): string {
|
||||||
|
// Join array elements into a single string
|
||||||
|
const joined = encodedArray.join("");
|
||||||
|
|
||||||
|
// Replace escaped quotes
|
||||||
|
const unescaped = joined.replace(/\\"/g, '"').replace(/\\'/g, "'");
|
||||||
|
|
||||||
|
// Remove remaining escape characters
|
||||||
|
const cleaned = unescaped
|
||||||
|
.replace(/\\n/g, "\n")
|
||||||
|
.replace(/\\t/g, "\t")
|
||||||
|
.replace(/\\r/g, "\r");
|
||||||
|
|
||||||
|
// Convert literal string representations back to characters
|
||||||
|
const decoded = cleaned
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/&/g, "&");
|
||||||
|
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
const res = await axios.get(url, {
|
const res = await axios.get(url, {
|
||||||
headers: {
|
headers: {
|
||||||
referer: baseUrl,
|
referer: baseUrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user