File size: 882 Bytes
11acfd9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import axios from "axios";
import { load, type CheerioAPI } from "cheerio";
import type { Video } from "../types/extractor.js";
class StreamTape {
private serverName = "StreamTape";
private sources: Video[] = [];
async extract(videoUrl: URL): Promise<Video[]> {
try {
const { data } = await axios.get(videoUrl.href).catch(() => {
throw new Error("Video not found");
});
const $: CheerioAPI = load(data);
let [fh, sh] = $.html()
?.match(/robotlink'\).innerHTML = (.*)'/)![1]
.split("+ ('");
sh = sh.substring(3);
fh = fh.replace(/\'/g, "");
const url = `https:${fh}${sh}`;
this.sources.push({
url: url,
isM3U8: url.includes(".m3u8"),
});
return this.sources;
} catch (err) {
throw new Error((err as Error).message);
}
}
}
export default StreamTape;
|