mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-13 08:35:08 +01:00
Added stream scraping
Co-authored-by: James Hawkins <jhawki2005@gmail.com>
This commit is contained in:
parent
c763cfe0f0
commit
32b36e047d
@ -5,7 +5,7 @@ import {
|
||||
MWQuery,
|
||||
} from "providers/types";
|
||||
|
||||
import { MWProviderMediaResult } from "providers";
|
||||
import { MWMediaStream, MWProviderMediaResult } from "providers";
|
||||
|
||||
export const tempScraper: MWMediaProvider = {
|
||||
id: "temp",
|
||||
@ -24,6 +24,14 @@ export const tempScraper: MWMediaProvider = {
|
||||
},
|
||||
|
||||
async searchForMedia(query: MWQuery): Promise<MWProviderMediaResult[]> {
|
||||
return [];
|
||||
return [
|
||||
];
|
||||
},
|
||||
|
||||
async getStream(media: MWPortableMedia): Promise<MWMediaStream> {
|
||||
return {
|
||||
url: "hi",
|
||||
type: "mp4",
|
||||
};
|
||||
},
|
||||
};
|
||||
|
@ -2,6 +2,7 @@ import {
|
||||
MWMediaProvider,
|
||||
MWMediaType,
|
||||
MWPortableMedia,
|
||||
MWMediaStream,
|
||||
MWQuery,
|
||||
} from "providers/types";
|
||||
|
||||
@ -13,6 +14,7 @@ import {
|
||||
|
||||
import { getDataFromPortableSearch } from "providers/list/theflix/portableToMedia";
|
||||
import { MWProviderMediaResult } from "providers";
|
||||
import { CORS_PROXY_URL } from "mw_constants";
|
||||
|
||||
export const theFlixScraper: MWMediaProvider = {
|
||||
id: "theflix",
|
||||
@ -43,4 +45,29 @@ export const theFlixScraper: MWMediaProvider = {
|
||||
|
||||
return results;
|
||||
},
|
||||
|
||||
async getStream(media: MWPortableMedia): Promise<MWMediaStream> {
|
||||
let url = "";
|
||||
|
||||
if (media.mediaType === MWMediaType.MOVIE) {
|
||||
url = `${CORS_PROXY_URL}https://theflix.to/movie/${media.mediaId}?movieInfo=${media.mediaId}`;
|
||||
} else if (media.mediaType === MWMediaType.SERIES) {
|
||||
url = `${CORS_PROXY_URL}https://theflix.to/tv-show/${media.mediaId}/season-${media.season}/episode-${media.episode}`;
|
||||
}
|
||||
|
||||
const res = await fetch(url).then((d) => d.text());
|
||||
|
||||
const prop: HTMLElement | undefined = Array.from(
|
||||
new DOMParser()
|
||||
.parseFromString(res, "text/html")
|
||||
.querySelectorAll("script")
|
||||
).find((e) => e.textContent?.includes("theflixvd.b-cdn"));
|
||||
|
||||
if (!prop || !prop.textContent) {
|
||||
throw new Error("Could not find stream");
|
||||
}
|
||||
|
||||
const data = JSON.parse(prop.textContent);
|
||||
return { url: data.props.pageProps.videoUrl, type: "mp4" };
|
||||
},
|
||||
};
|
||||
|
@ -12,6 +12,12 @@ export interface MWPortableMedia {
|
||||
episode?: number;
|
||||
}
|
||||
|
||||
export type MWMediaStreamType = "m3u8" | "mp4";
|
||||
export interface MWMediaStream {
|
||||
url: string;
|
||||
type: MWMediaStreamType;
|
||||
}
|
||||
|
||||
export interface MWMedia extends MWPortableMedia {
|
||||
title: string;
|
||||
year: string;
|
||||
@ -32,17 +38,18 @@ export interface MWMediaProvider {
|
||||
|
||||
getMediaFromPortable(media: MWPortableMedia): Promise<MWProviderMediaResult>;
|
||||
searchForMedia(query: MWQuery): Promise<MWProviderMediaResult[]>;
|
||||
getStream(media: MWPortableMedia): Promise<MWMediaStream>;
|
||||
}
|
||||
|
||||
export interface MWMassProviderOutput {
|
||||
providers: {
|
||||
id: string,
|
||||
success: boolean,
|
||||
id: string;
|
||||
success: boolean;
|
||||
}[];
|
||||
results: MWMedia[],
|
||||
results: MWMedia[];
|
||||
stats: {
|
||||
total: number,
|
||||
failed: number,
|
||||
succeeded: number,
|
||||
}
|
||||
total: number;
|
||||
failed: number;
|
||||
succeeded: number;
|
||||
};
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { MWMedia, MWMediaProvider, MWPortableMedia, MWQuery } from "./types";
|
||||
import { MWMedia, MWMediaProvider, MWMediaStream, MWPortableMedia, MWQuery } from "./types";
|
||||
|
||||
export interface MWWrappedMediaProvider extends MWMediaProvider {
|
||||
getMediaFromPortable(media: MWPortableMedia): Promise<MWMedia>;
|
||||
searchForMedia(query: MWQuery): Promise<MWMedia[]>;
|
||||
getStream(media: MWPortableMedia): Promise<MWMediaStream>;
|
||||
}
|
||||
|
||||
export function WrapProvider(
|
||||
|
Loading…
Reference in New Issue
Block a user