mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
renaming
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
export const tokyoCatalogList = [
|
||||
export const catalog = [
|
||||
{
|
||||
title: 'Top Anime',
|
||||
filter: 'anime/search?r=5',
|
||||
title: "Top Anime",
|
||||
filter: "anime/search?r=5",
|
||||
},
|
||||
{
|
||||
title: 'Popular Anime',
|
||||
filter: 'anime/',
|
||||
title: "Popular Anime",
|
||||
filter: "anime/",
|
||||
},
|
||||
];
|
||||
|
||||
export const tokyoGenresList = [];
|
||||
export const genres = [];
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import {tokyoCatalogList, tokyoGenresList} from './catalog';
|
||||
import {tokyoGetInfo} from './tokyoGetInfo';
|
||||
import {tokyoGetPosts, tokyoGetPostsSearch} from './tokyoGetPosts';
|
||||
import {tokyoGetStream} from './tokyoGetStream';
|
||||
import {ProviderType} from '../types';
|
||||
|
||||
export const tokyoInsider: ProviderType = {
|
||||
catalog: tokyoCatalogList,
|
||||
genres: tokyoGenresList,
|
||||
GetMetaData: tokyoGetInfo,
|
||||
GetHomePosts: tokyoGetPosts,
|
||||
GetStream: tokyoGetStream,
|
||||
GetSearchPosts: tokyoGetPostsSearch,
|
||||
blurImage: true,
|
||||
};
|
||||
65
providers/tokyoInsider/meta.ts
Normal file
65
providers/tokyoInsider/meta.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { Info, ProviderContext } from "../types";
|
||||
|
||||
export const getMeta = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const { cheerio } = providerContext;
|
||||
const url = link;
|
||||
const res = await fetch(url);
|
||||
const data = await res.text();
|
||||
const $ = cheerio.load(data);
|
||||
const meta = {
|
||||
title: $('.c_h2:contains("Title(s):")')
|
||||
.text()
|
||||
.replace("Title(s):", "")
|
||||
.trim()
|
||||
.split("\n")[0],
|
||||
synopsis: $('.c_h2b:contains("Summary:"),.c_h2:contains("Summary:")')
|
||||
.text()
|
||||
.replace("Summary:", "")
|
||||
.trim(),
|
||||
image: $(".a_img").attr("src") || "",
|
||||
imdbId: "",
|
||||
type: "series",
|
||||
};
|
||||
const episodesList: { title: string; link: string }[] = [];
|
||||
$(".episode").map((i, element) => {
|
||||
const link =
|
||||
"https://www.tokyoinsider.com" + $(element).find("a").attr("href") ||
|
||||
$(".download-link").attr("href");
|
||||
let title =
|
||||
$(element).find("a").find("em").text() +
|
||||
" " +
|
||||
$(element).find("a").find("strong").text();
|
||||
if (!title.trim()) {
|
||||
title = $(".download-link").text();
|
||||
}
|
||||
if (link && title.trim()) {
|
||||
episodesList.push({ title, link });
|
||||
}
|
||||
});
|
||||
return {
|
||||
...meta,
|
||||
linkList: [
|
||||
{
|
||||
title: meta.title,
|
||||
directLinks: episodesList,
|
||||
},
|
||||
],
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
title: "",
|
||||
synopsis: "",
|
||||
image: "",
|
||||
imdbId: "",
|
||||
type: "series",
|
||||
linkList: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Post, ProviderContext} from '../types';
|
||||
import { Post, ProviderContext } from "../types";
|
||||
|
||||
export const tokyoGetPosts = async function ({
|
||||
export const getPosts = async function ({
|
||||
filter,
|
||||
page,
|
||||
// providerValue,
|
||||
@@ -13,14 +13,14 @@ export const tokyoGetPosts = async function ({
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, axios, cheerio} = providerContext;
|
||||
const baseURL = await getBaseUrl('tokyoinsider');
|
||||
const { getBaseUrl, axios, cheerio } = providerContext;
|
||||
const baseURL = await getBaseUrl("tokyoinsider");
|
||||
const start = page < 2 ? 0 : (page - 1) * 20;
|
||||
const url = `${baseURL}/${filter}&start=${start}`;
|
||||
return posts({baseURL, url, signal, axios, cheerio});
|
||||
return posts({ baseURL, url, signal, axios, cheerio });
|
||||
};
|
||||
|
||||
export const tokyoGetPostsSearch = async function ({
|
||||
export const getSearchPosts = async function ({
|
||||
searchQuery,
|
||||
page,
|
||||
// providerValue,
|
||||
@@ -33,11 +33,11 @@ export const tokyoGetPostsSearch = async function ({
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, axios, cheerio} = providerContext;
|
||||
const baseURL = await getBaseUrl('tokyoinsider');
|
||||
const { getBaseUrl, axios, cheerio } = providerContext;
|
||||
const baseURL = await getBaseUrl("tokyoinsider");
|
||||
const start = page < 2 ? 0 : (page - 1) * 20;
|
||||
const url = `${baseURL}/anime/search?k=${searchQuery}&start=${start}`;
|
||||
return posts({baseURL, url, signal, axios, cheerio});
|
||||
return posts({ baseURL, url, signal, axios, cheerio });
|
||||
};
|
||||
|
||||
async function posts({
|
||||
@@ -50,21 +50,21 @@ async function posts({
|
||||
baseURL: string;
|
||||
url: string;
|
||||
signal: AbortSignal;
|
||||
axios: ProviderContext['axios'];
|
||||
cheerio: ProviderContext['cheerio'];
|
||||
axios: ProviderContext["axios"];
|
||||
cheerio: ProviderContext["cheerio"];
|
||||
}): Promise<Post[]> {
|
||||
try {
|
||||
const res = await axios.get(url, {signal});
|
||||
const res = await axios.get(url, { signal });
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
const catalog: Post[] = [];
|
||||
$('td.c_h2[width="40"]').map((i, element) => {
|
||||
const image = $(element)
|
||||
.find('.a_img')
|
||||
.attr('src')
|
||||
?.replace('small', 'default');
|
||||
const title = $(element).find('a').attr('title');
|
||||
const link = baseURL + $(element).find('a').attr('href');
|
||||
.find(".a_img")
|
||||
.attr("src")
|
||||
?.replace("small", "default");
|
||||
const title = $(element).find("a").attr("title");
|
||||
const link = baseURL + $(element).find("a").attr("href");
|
||||
if (title && link && image) {
|
||||
catalog.push({
|
||||
title: title,
|
||||
33
providers/tokyoInsider/stream.ts
Normal file
33
providers/tokyoInsider/stream.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Stream, ProviderContext } from "../types";
|
||||
|
||||
export const getStream = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
try {
|
||||
const { cheerio } = providerContext;
|
||||
const url = link;
|
||||
const res = await fetch(url);
|
||||
const data = await res.text();
|
||||
const $ = cheerio.load(data);
|
||||
const streamLinks: Stream[] = [];
|
||||
$(".c_h1,.c_h2").map((i, element) => {
|
||||
$(element).find("span").remove();
|
||||
const title = $(element).find("a").text() || "";
|
||||
const link = $(element).find("a").attr("href") || "";
|
||||
if (title && link.includes("media")) {
|
||||
streamLinks.push({
|
||||
server: title,
|
||||
link,
|
||||
type: link.split(".").pop() || "mkv",
|
||||
});
|
||||
}
|
||||
});
|
||||
return streamLinks;
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
@@ -1,65 +0,0 @@
|
||||
import {Info, ProviderContext} from '../types';
|
||||
|
||||
export const tokyoGetInfo = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const {cheerio} = providerContext;
|
||||
const url = link;
|
||||
const res = await fetch(url);
|
||||
const data = await res.text();
|
||||
const $ = cheerio.load(data);
|
||||
const meta = {
|
||||
title: $('.c_h2:contains("Title(s):")')
|
||||
.text()
|
||||
.replace('Title(s):', '')
|
||||
.trim()
|
||||
.split('\n')[0],
|
||||
synopsis: $('.c_h2b:contains("Summary:"),.c_h2:contains("Summary:")')
|
||||
.text()
|
||||
.replace('Summary:', '')
|
||||
.trim(),
|
||||
image: $('.a_img').attr('src') || '',
|
||||
imdbId: '',
|
||||
type: 'series',
|
||||
};
|
||||
const episodesList: {title: string; link: string}[] = [];
|
||||
$('.episode').map((i, element) => {
|
||||
const link =
|
||||
'https://www.tokyoinsider.com' + $(element).find('a').attr('href') ||
|
||||
$('.download-link').attr('href');
|
||||
let title =
|
||||
$(element).find('a').find('em').text() +
|
||||
' ' +
|
||||
$(element).find('a').find('strong').text();
|
||||
if (!title.trim()) {
|
||||
title = $('.download-link').text();
|
||||
}
|
||||
if (link && title.trim()) {
|
||||
episodesList.push({title, link});
|
||||
}
|
||||
});
|
||||
return {
|
||||
...meta,
|
||||
linkList: [
|
||||
{
|
||||
title: meta.title,
|
||||
directLinks: episodesList,
|
||||
},
|
||||
],
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
title: '',
|
||||
synopsis: '',
|
||||
image: '',
|
||||
imdbId: '',
|
||||
type: 'series',
|
||||
linkList: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
import {Stream, ProviderContext} from '../types';
|
||||
|
||||
export const tokyoGetStream = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
try {
|
||||
const {cheerio} = providerContext;
|
||||
const url = link;
|
||||
const res = await fetch(url);
|
||||
const data = await res.text();
|
||||
const $ = cheerio.load(data);
|
||||
const streamLinks: Stream[] = [];
|
||||
$('.c_h1,.c_h2').map((i, element) => {
|
||||
$(element).find('span').remove();
|
||||
const title = $(element).find('a').text() || '';
|
||||
const link = $(element).find('a').attr('href') || '';
|
||||
if (title && link.includes('media')) {
|
||||
streamLinks.push({
|
||||
server: title,
|
||||
link,
|
||||
type: link.split('.').pop() || 'mkv',
|
||||
});
|
||||
}
|
||||
});
|
||||
return streamLinks;
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user