From 378a1696b343583f97679a55ce158bddef71bfd7 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 18:17:37 +0100 Subject: [PATCH 1/4] Update provider package --- package.json | 2 +- pnpm-lock.yaml | 17 +++++------------ .../player/atoms/settings/QualityView.tsx | 1 + .../player/hooks/useSourceSelection.ts | 12 ++++++------ .../player/utils/convertRunoutputToSource.ts | 5 +++-- src/stores/player/utils/qualities.ts | 6 +++++- src/utils/providers.ts | 4 ++-- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 1649434d..e957477a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "@formkit/auto-animate": "^0.8.1", "@headlessui/react": "^1.7.17", - "@movie-web/providers": "^1.1.5", + "@movie-web/providers": "^2.0.0", "@noble/hashes": "^1.3.3", "@react-spring/web": "^9.7.3", "@scure/bip39": "^1.2.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 50176963..c0c2ae78 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ dependencies: specifier: ^1.7.17 version: 1.7.17(react-dom@18.2.0)(react@18.2.0) '@movie-web/providers': - specifier: ^1.1.5 - version: 1.1.5 + specifier: ^2.0.0 + version: 2.0.0 '@noble/hashes': specifier: ^1.3.3 version: 1.3.3 @@ -1912,14 +1912,14 @@ packages: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 - /@movie-web/providers@1.1.5: - resolution: {integrity: sha512-JnqU6nVsEZ83UVcsizqzcr/vtwvHHlZt9vYwGiJEAyaUgaXJPZz3C90qzaRZ8CVWydUTRAmjRP3daRFtC1nKHw==} + /@movie-web/providers@2.0.0: + resolution: {integrity: sha512-+LF7kTLhtpewLdQssnYojW/Dia0UtAkrK9ZvmFSnLIEQoVjVv1vsJUT2JqkjvEC/TM1SnM2N6H+eKLJU4yN2cQ==} dependencies: cheerio: 1.0.0-rc.12 crypto-js: 4.2.0 form-data: 4.0.0 iso-639-1: 3.1.0 - nanoid: 3.3.6 + nanoid: 3.3.7 node-fetch: 2.7.0 unpacker: 1.0.1 transitivePeerDependencies: @@ -5234,17 +5234,10 @@ packages: stylis: 4.3.0 dev: false - /nanoid@3.3.6: - resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==} - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} - hasBin: true - dev: false - /nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - dev: true /nanoid@5.0.4: resolution: {integrity: sha512-vAjmBf13gsmhXSgBrtIclinISzFFy22WwCYoyilZlsrRXNIHSwgFQ1bEdjRwMT3aoadeIF6HMuDRlOxzfXV8ig==} diff --git a/src/components/player/atoms/settings/QualityView.tsx b/src/components/player/atoms/settings/QualityView.tsx index 87f8af9b..d649fb79 100644 --- a/src/components/player/atoms/settings/QualityView.tsx +++ b/src/components/player/atoms/settings/QualityView.tsx @@ -22,6 +22,7 @@ const alwaysVisibleQualities: Record = { "480": true, "720": true, "1080": true, + "4k": false, }; function useIsIosHls() { diff --git a/src/components/player/hooks/useSourceSelection.ts b/src/components/player/hooks/useSourceSelection.ts index 6ae19e51..e28507cf 100644 --- a/src/components/player/hooks/useSourceSelection.ts +++ b/src/components/player/hooks/useSourceSelection.ts @@ -73,8 +73,8 @@ export function useEmbedScraping( setSourceId(sourceId); setCaption(null); setSource( - convertRunoutputToSource({ stream: result.stream }), - convertProviderCaption(result.stream.captions), + convertRunoutputToSource({ stream: result.stream[0] }), + convertProviderCaption(result.stream[0].captions), progress, ); router.close(); @@ -132,8 +132,8 @@ export function useSourceScraping(sourceId: string | null, routerId: string) { if (result.stream) { setCaption(null); setSource( - convertRunoutputToSource({ stream: result.stream }), - convertProviderCaption(result.stream.captions), + convertRunoutputToSource({ stream: result.stream[0] }), + convertProviderCaption(result.stream[0].captions), progress, ); setSourceId(sourceId); @@ -187,8 +187,8 @@ export function useSourceScraping(sourceId: string | null, routerId: string) { setSourceId(sourceId); setCaption(null); setSource( - convertRunoutputToSource({ stream: embedResult.stream }), - convertProviderCaption(embedResult.stream.captions), + convertRunoutputToSource({ stream: embedResult.stream[0] }), + convertProviderCaption(embedResult.stream[0].captions), progress, ); router.close(); diff --git a/src/components/player/utils/convertRunoutputToSource.ts b/src/components/player/utils/convertRunoutputToSource.ts index efc59f20..fba59e63 100644 --- a/src/components/player/utils/convertRunoutputToSource.ts +++ b/src/components/player/utils/convertRunoutputToSource.ts @@ -1,4 +1,4 @@ -import { RunOutput } from "@movie-web/providers"; +import { Stream } from "@movie-web/providers"; import { SourceFileStream, @@ -7,6 +7,7 @@ import { } from "@/stores/player/utils/qualities"; const allowedQualitiesMap: Record = { + "4k": "4k", "1080": "1080", "480": "480", "360": "360", @@ -21,7 +22,7 @@ function isAllowedQuality(inp: string): inp is SourceQuality { } export function convertRunoutputToSource(out: { - stream: RunOutput["stream"]; + stream: Stream; }): SourceSliceSource { if (out.stream.type === "hls") { return { diff --git a/src/stores/player/utils/qualities.ts b/src/stores/player/utils/qualities.ts index dbc7a3d2..cca60bbd 100644 --- a/src/stores/player/utils/qualities.ts +++ b/src/stores/player/utils/qualities.ts @@ -1,6 +1,8 @@ +import { Qualities } from "@movie-web/providers"; + import { QualityStore } from "@/stores/quality"; -export type SourceQuality = "unknown" | "360" | "480" | "720" | "1080"; +export type SourceQuality = Qualities; export type StreamType = "hls" | "mp4"; @@ -30,6 +32,7 @@ const qualitySorting: Record = { "480": 20, "720": 30, "1080": 40, + "4k": 50, }; const sortedQualities: SourceQuality[] = Object.entries(qualitySorting) .sort((a, b) => b[1] - a[1]) @@ -99,6 +102,7 @@ export function selectQuality( } const qualityMap: Record = { + "4k": "4k", "1080": "1080p", "360": "360p", "480": "480p", diff --git a/src/utils/providers.ts b/src/utils/providers.ts index 530495a7..e5c8503c 100644 --- a/src/utils/providers.ts +++ b/src/utils/providers.ts @@ -1,5 +1,5 @@ import { - ProviderBuilderOptions, + Fetcher, ProviderControls, makeProviders, makeSimpleProxyFetcher, @@ -49,7 +49,7 @@ async function fetchButWithApiTokens( } function makeLoadBalancedSimpleProxyFetcher() { - const fetcher: ProviderBuilderOptions["fetcher"] = async (a, b) => { + const fetcher: Fetcher = async (a, b) => { const currentFetcher = makeSimpleProxyFetcher( getLoadbalancedProxyUrl(), fetchButWithApiTokens, From 41f83f4befee26919de4513c97efb2329fcc40c2 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 20:39:53 +0100 Subject: [PATCH 2/4] Fix wrong backendurl being used for meta data fetching --- src/pages/parts/auth/TrustBackendPart.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/parts/auth/TrustBackendPart.tsx b/src/pages/parts/auth/TrustBackendPart.tsx index c2e2325c..595e434c 100644 --- a/src/pages/parts/auth/TrustBackendPart.tsx +++ b/src/pages/parts/auth/TrustBackendPart.tsx @@ -25,7 +25,7 @@ export function TrustBackendPart(props: TrustBackendPartProps) { const backendUrl = useBackendUrl(); const hostname = useMemo(() => new URL(backendUrl).hostname, [backendUrl]); const result = useAsync(() => { - return getBackendMeta(conf().BACKEND_URL); + return getBackendMeta(backendUrl); }, [backendUrl]); const { t } = useTranslation(); From 9dd8f372a61c5cdeed3f99679937661144aab443 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 21:14:02 +0100 Subject: [PATCH 3/4] capitalize 4k --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- src/pages/parts/auth/TrustBackendPart.tsx | 1 - src/stores/player/utils/qualities.ts | 10 +++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index e957477a..62466361 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "@formkit/auto-animate": "^0.8.1", "@headlessui/react": "^1.7.17", - "@movie-web/providers": "^2.0.0", + "@movie-web/providers": "^2.0.1", "@noble/hashes": "^1.3.3", "@react-spring/web": "^9.7.3", "@scure/bip39": "^1.2.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0c2ae78..5efe6ac9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ dependencies: specifier: ^1.7.17 version: 1.7.17(react-dom@18.2.0)(react@18.2.0) '@movie-web/providers': - specifier: ^2.0.0 - version: 2.0.0 + specifier: ^2.0.1 + version: 2.0.1 '@noble/hashes': specifier: ^1.3.3 version: 1.3.3 @@ -1912,8 +1912,8 @@ packages: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 - /@movie-web/providers@2.0.0: - resolution: {integrity: sha512-+LF7kTLhtpewLdQssnYojW/Dia0UtAkrK9ZvmFSnLIEQoVjVv1vsJUT2JqkjvEC/TM1SnM2N6H+eKLJU4yN2cQ==} + /@movie-web/providers@2.0.1: + resolution: {integrity: sha512-PB1OxSsm4zwD6fuWBCmuqwMpt1UnlKssVZ8jGl6gHioS9/qFXR9Rsd8SnWISQWxF6lVRUp0DBXHfCrXGY/jwhA==} dependencies: cheerio: 1.0.0-rc.12 crypto-js: 4.2.0 diff --git a/src/pages/parts/auth/TrustBackendPart.tsx b/src/pages/parts/auth/TrustBackendPart.tsx index 595e434c..3fa818ef 100644 --- a/src/pages/parts/auth/TrustBackendPart.tsx +++ b/src/pages/parts/auth/TrustBackendPart.tsx @@ -14,7 +14,6 @@ import { import { Loading } from "@/components/layout/Loading"; import { MwLink } from "@/components/text/Link"; import { useBackendUrl } from "@/hooks/auth/useBackendUrl"; -import { conf } from "@/setup/config"; interface TrustBackendPartProps { onNext?: (meta: MetaResponse) => void; diff --git a/src/stores/player/utils/qualities.ts b/src/stores/player/utils/qualities.ts index cca60bbd..dbd84b5c 100644 --- a/src/stores/player/utils/qualities.ts +++ b/src/stores/player/utils/qualities.ts @@ -32,7 +32,7 @@ const qualitySorting: Record = { "480": 20, "720": 30, "1080": 40, - "4k": 50, + "4k": 25, // 4k has lower priority, you need faster internet for it }; const sortedQualities: SourceQuality[] = Object.entries(qualitySorting) .sort((a, b) => b[1] - a[1]) @@ -101,8 +101,8 @@ export function selectQuality( throw new Error("couldn't select quality"); } -const qualityMap: Record = { - "4k": "4k", +const qualityNameMap: Record = { + "4k": "4K", "1080": "1080p", "360": "360p", "480": "480p", @@ -110,8 +110,8 @@ const qualityMap: Record = { unknown: "unknown", }; -export const allQualities = Object.keys(qualityMap) as SourceQuality[]; +export const allQualities = Object.keys(qualityNameMap) as SourceQuality[]; export function qualityToString(quality: SourceQuality): string { - return qualityMap[quality]; + return qualityNameMap[quality]; } From ecf1d901a346b1915d384cc2bb02f262f90a0c03 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 21:35:09 +0100 Subject: [PATCH 4/4] Fix issue with current source displaying in scraping screen --- src/hooks/useProviderScrape.tsx | 2 ++ src/pages/parts/player/ScrapingPart.tsx | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hooks/useProviderScrape.tsx b/src/hooks/useProviderScrape.tsx index 44f823da..7e1ab4bf 100644 --- a/src/hooks/useProviderScrape.tsx +++ b/src/hooks/useProviderScrape.tsx @@ -60,8 +60,10 @@ function useBaseScrape() { }, []); const startEvent = useCallback((id: ScraperEvent<"start">) => { + const lastIdTmp = lastId.current; setSources((s) => { if (s[id]) s[id].status = "pending"; + if (lastIdTmp && s[lastIdTmp]) s[lastIdTmp].status = "success"; return { ...s }; }); setCurrentSource(id); diff --git a/src/pages/parts/player/ScrapingPart.tsx b/src/pages/parts/player/ScrapingPart.tsx index ea86ee57..6687d3b1 100644 --- a/src/pages/parts/player/ScrapingPart.tsx +++ b/src/pages/parts/player/ScrapingPart.tsx @@ -75,11 +75,8 @@ export function ScrapingPart(props: ScrapingProps) { })(); }, [startScraping, props, report, isMounted]); - const currentProvider = sourceOrder.find( - (s) => sources[s.id].status === "pending", - ); let currentProviderIndex = sourceOrder.findIndex( - (provider) => currentProvider?.id === provider.id, + (s) => s.id === currentSource || s.children.includes(currentSource ?? ""), ); if (currentProviderIndex === -1) currentProviderIndex = sourceOrder.length - 1;