From 139a760be0e3333a7ea37ec80cd39b6ab068f199 Mon Sep 17 00:00:00 2001 From: cloud <62519659+lem6ns@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:34:54 -0700 Subject: [PATCH 1/3] fix(netfilm): use different cdn --- .gitattributes | 1 + .vscode/settings.json | 3 +++ src/backend/providers/netfilm.ts | 20 ++++++++------------ 3 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..6313b56c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.vscode/settings.json b/.vscode/settings.json index 279011fe..a2b8691f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,8 @@ "eslint.format.enable": true, "[json]": { "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "vscode.typescript-language-features" } } diff --git a/src/backend/providers/netfilm.ts b/src/backend/providers/netfilm.ts index 777c77cd..e979f7b6 100644 --- a/src/backend/providers/netfilm.ts +++ b/src/backend/providers/netfilm.ts @@ -1,6 +1,6 @@ import { proxiedFetch } from "../helpers/fetch"; import { registerProvider } from "../helpers/register"; -import { MWStreamQuality, MWStreamType } from "../helpers/streams"; +import { MWCaptionType, MWStreamQuality, MWStreamType } from "../helpers/streams"; import { MWMediaType } from "../metadata/types"; const netfilmBase = "https://net-film.vercel.app"; @@ -18,7 +18,6 @@ registerProvider({ displayName: "NetFilm", rank: 15, type: [MWMediaType.MOVIE, MWMediaType.SERIES], - disabled: true, // https://github.com/lamhoang1256/netfilm/issues/25 async scrape({ media, episode, progress }) { // search for relevant item @@ -41,12 +40,9 @@ registerProvider({ // get stream info from media progress(75); - const watchInfo = await proxiedFetch( - `/api/episode?id=${netfilmId}`, - { - baseURL: netfilmBase, - } - ); + const watchInfo = await proxiedFetch(`/api/episode?id=${netfilmId}`, { + baseURL: netfilmBase, + }); const { qualities } = watchInfo.data; @@ -58,7 +54,7 @@ registerProvider({ return { embeds: [], stream: { - streamUrl: source.url, + streamUrl: source.url.replace("akm-cdn", "aws-cdn").replace("gg-cdn", "aws-cdn"), quality: qualityMap[source.quality as QualityInMap], type: MWStreamType.HLS, captions: [], @@ -109,17 +105,17 @@ registerProvider({ } ); - const { qualities } = episodeStream.data; + const data = episodeStream.data; // get best quality source - const source = qualities.reduce((p: any, c: any) => + const source = data.qualities.reduce((p: any, c: any) => c.quality > p.quality ? c : p ); return { embeds: [], stream: { - streamUrl: source.url, + streamUrl: source.url.replace("akm-cdn", "aws-cdn").replace("gg-cdn", "aws-cdn"), quality: qualityMap[source.quality as QualityInMap], type: MWStreamType.HLS, captions: [], From 25e32a14b749263f22d728912daf6900be9a8f3d Mon Sep 17 00:00:00 2001 From: cloud <62519659+lem6ns@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:35:39 -0700 Subject: [PATCH 2/3] feat(netfilm): add captions --- src/backend/providers/netfilm.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/backend/providers/netfilm.ts b/src/backend/providers/netfilm.ts index e979f7b6..ff25fbf8 100644 --- a/src/backend/providers/netfilm.ts +++ b/src/backend/providers/netfilm.ts @@ -44,20 +44,27 @@ registerProvider({ baseURL: netfilmBase, }); - const { qualities } = watchInfo.data; + const data = watchInfo.data; // get best quality source - const source = qualities.reduce((p: any, c: any) => + const source = data.qualities.reduce((p: any, c: any) => c.quality > p.quality ? c : p ); + const mappedCaptions = data.subtitles.map((sub: Record) => ({ + needsProxy: false, + url: sub.url.replace("https://convert-srt-to-vtt.vercel.app/?url=", ""), + type: MWCaptionType.SRT, + langIso: sub.language, + })) + return { embeds: [], stream: { streamUrl: source.url.replace("akm-cdn", "aws-cdn").replace("gg-cdn", "aws-cdn"), quality: qualityMap[source.quality as QualityInMap], type: MWStreamType.HLS, - captions: [], + captions: mappedCaptions, }, }; } @@ -112,13 +119,20 @@ registerProvider({ c.quality > p.quality ? c : p ); + const mappedCaptions = data.subtitles.map((sub: Record) => ({ + needsProxy: false, + url: sub.url.replace("https://convert-srt-to-vtt.vercel.app/?url=", ""), + type: MWCaptionType.SRT, + langIso: sub.language, + })) + return { embeds: [], stream: { streamUrl: source.url.replace("akm-cdn", "aws-cdn").replace("gg-cdn", "aws-cdn"), quality: qualityMap[source.quality as QualityInMap], type: MWStreamType.HLS, - captions: [], + captions: mappedCaptions, }, }; }, From 5e97a195d9b99d9980416bb399624a78628331c5 Mon Sep 17 00:00:00 2001 From: cloud <62519659+lem6ns@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:37:06 -0700 Subject: [PATCH 3/3] fix: vscode settings file --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a2b8691f..279011fe 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,8 +4,5 @@ "eslint.format.enable": true, "[json]": { "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[typescript]": { - "editor.defaultFormatter": "vscode.typescript-language-features" } }