|
|
@ -2,6 +2,7 @@ import { |
|
|
|
MWMediaProvider, |
|
|
|
MWMediaProvider, |
|
|
|
MWMediaType, |
|
|
|
MWMediaType, |
|
|
|
MWPortableMedia, |
|
|
|
MWPortableMedia, |
|
|
|
|
|
|
|
MWMediaStream, |
|
|
|
MWQuery, |
|
|
|
MWQuery, |
|
|
|
} from "providers/types"; |
|
|
|
} from "providers/types"; |
|
|
|
|
|
|
|
|
|
|
@ -13,6 +14,7 @@ import { |
|
|
|
|
|
|
|
|
|
|
|
import { getDataFromPortableSearch } from "providers/list/theflix/portableToMedia"; |
|
|
|
import { getDataFromPortableSearch } from "providers/list/theflix/portableToMedia"; |
|
|
|
import { MWProviderMediaResult } from "providers"; |
|
|
|
import { MWProviderMediaResult } from "providers"; |
|
|
|
|
|
|
|
import { CORS_PROXY_URL } from "mw_constants"; |
|
|
|
|
|
|
|
|
|
|
|
export const theFlixScraper: MWMediaProvider = { |
|
|
|
export const theFlixScraper: MWMediaProvider = { |
|
|
|
id: "theflix", |
|
|
|
id: "theflix", |
|
|
@ -43,4 +45,29 @@ export const theFlixScraper: MWMediaProvider = { |
|
|
|
|
|
|
|
|
|
|
|
return results; |
|
|
|
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" }; |
|
|
|
|
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|