From 52e6a406417518f4ba2991fd02a9e83e456a5b3f Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Mon, 4 Mar 2024 23:26:14 +0000 Subject: [PATCH] vimeo: add support for private videos --- src/modules/processing/match.js | 1 + src/modules/processing/services/vimeo.js | 9 ++++++++- src/modules/processing/servicesConfig.json | 2 +- src/modules/processing/servicesPatternTesters.js | 3 ++- src/test/tests.json | 8 ++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/modules/processing/match.js b/src/modules/processing/match.js index f1641baa..16f48afc 100644 --- a/src/modules/processing/match.js +++ b/src/modules/processing/match.js @@ -104,6 +104,7 @@ export default async function(host, patternMatch, url, lang, obj) { case "vimeo": r = await vimeo({ id: patternMatch.id.slice(0, 11), + password: patternMatch.password, quality: obj.vQuality, isAudioOnly: isAudioOnly, forceDash: isAudioOnly ? true : obj.vimeoDash diff --git a/src/modules/processing/services/vimeo.js b/src/modules/processing/services/vimeo.js index 7c6aab94..f51f7220 100644 --- a/src/modules/processing/services/vimeo.js +++ b/src/modules/processing/services/vimeo.js @@ -28,7 +28,14 @@ export default async function(obj) { let quality = obj.quality === "max" ? "9000" : obj.quality; if (!quality || obj.isAudioOnly) quality = "9000"; - let api = await fetch(`https://player.vimeo.com/video/${obj.id}/config`).then((r) => { return r.json() }).catch(() => { return false }); + const url = new URL(`https://player.vimeo.com/video/${obj.id}/config`); + if (obj.password) { + url.searchParams.set('h', obj.password); + } + + let api = await fetch(url) + .then(r => r.json()) + .catch(() => {}); if (!api) return { error: 'ErrorCouldntFetch' }; let downloadType = "dash"; diff --git a/src/modules/processing/servicesConfig.json b/src/modules/processing/servicesConfig.json index 40bc1530..b92f5751 100644 --- a/src/modules/processing/servicesConfig.json +++ b/src/modules/processing/servicesConfig.json @@ -64,7 +64,7 @@ "enabled": false }, "vimeo": { - "patterns": [":id", "video/:id"], + "patterns": [":id", "video/:id", ":id/:password"], "enabled": true, "bestAudio": "mp3" }, diff --git a/src/modules/processing/servicesPatternTesters.js b/src/modules/processing/servicesPatternTesters.js index 393a9c99..f4dee15b 100644 --- a/src/modules/processing/servicesPatternTesters.js +++ b/src/modules/processing/servicesPatternTesters.js @@ -42,7 +42,8 @@ export const testers = { patternMatch.id?.length < 20, "vimeo": (patternMatch) => - patternMatch.id?.length <= 11, + patternMatch.id?.length <= 11 + && (!patternMatch.password || patternMatch.password.length < 16), "vine": (patternMatch) => patternMatch.id?.length <= 12, diff --git a/src/test/tests.json b/src/test/tests.json index 94fc43a4..e404859f 100644 --- a/src/test/tests.json +++ b/src/test/tests.json @@ -847,6 +847,14 @@ "code": 200, "status": "stream" } + }, { + "name": "private video", + "url": "https://vimeo.com/903115595/f14d06da38", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } }], "reddit": [{ "name": "video with audio",