mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-13 13:15:08 +01:00
Fix some cdn replacement bugs
This commit is contained in:
parent
adddb84417
commit
23c1df5aef
@ -5,6 +5,7 @@ import { playerStatus } from "@/stores/player/slices/source";
|
||||
import { ThumbnailImage } from "@/stores/player/slices/thumbnails";
|
||||
import { usePlayerStore } from "@/stores/player/store";
|
||||
import { LoadableSource, selectQuality } from "@/stores/player/utils/qualities";
|
||||
import { processCdnLink } from "@/utils/cdn";
|
||||
import { isSafari } from "@/utils/detectFeatures";
|
||||
|
||||
function makeQueue(layers: number): number[] {
|
||||
@ -46,11 +47,11 @@ class ThumnbnailWorker {
|
||||
const canvas = document.createElement("canvas");
|
||||
this.hls = new Hls();
|
||||
if (source.type === "mp4") {
|
||||
el.src = source.url;
|
||||
el.src = processCdnLink(source.url);
|
||||
el.crossOrigin = "anonymous";
|
||||
} else if (source.type === "hls") {
|
||||
this.hls.attachMedia(el);
|
||||
this.hls.loadSource(source.url);
|
||||
this.hls.loadSource(processCdnLink(source.url));
|
||||
} else throw new Error("Invalid loadable source type");
|
||||
this.videoEl = el;
|
||||
this.canvasEl = canvas;
|
||||
|
@ -5,7 +5,9 @@ export function processCdnLink(url: string): string {
|
||||
const replacements = conf().CDN_REPLACEMENTS;
|
||||
for (const [before, after] of replacements) {
|
||||
if (parsedUrl.hostname.endsWith(before)) {
|
||||
parsedUrl.host = after;
|
||||
parsedUrl.hostname = after;
|
||||
parsedUrl.port = "";
|
||||
parsedUrl.protocol = "https://";
|
||||
return parsedUrl.toString();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user