mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-18 08:01:43 +00:00
init
This commit is contained in:
33
providers/tokyoInsider/tokyoGetStream.ts
Normal file
33
providers/tokyoInsider/tokyoGetStream.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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