From e88f2dc8e2ee41014b3f80808efc5591ca645d59 Mon Sep 17 00:00:00 2001 From: ihatespawn <168680471+ihatespawn@users.noreply.github.com> Date: Fri, 31 May 2024 13:18:26 +0200 Subject: [PATCH] odysee support --- src/modules/processing/match.js | 6 +++++ src/modules/processing/matchActionDecider.js | 1 + src/modules/processing/services/odysee.js | 27 +++++++++++++++++++ src/modules/processing/servicesConfig.json | 7 ++++- .../processing/servicesPatternTesters.js | 3 +++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/modules/processing/services/odysee.js diff --git a/src/modules/processing/match.js b/src/modules/processing/match.js index 3e38c4db..9c9dd80c 100644 --- a/src/modules/processing/match.js +++ b/src/modules/processing/match.js @@ -25,6 +25,7 @@ import twitch from "./services/twitch.js"; import rutube from "./services/rutube.js"; import dailymotion from "./services/dailymotion.js"; import loom from "./services/loom.js"; +import odysee from "./services/odysee.js"; let freebind; @@ -193,6 +194,11 @@ export default async function(host, patternMatch, lang, obj) { id: patternMatch.id }); break; + case "odysee": + r = await odysee({ + id: patternMatch.id + }); + break; default: return createResponse("error", { t: loc(lang, 'ErrorUnsupported') diff --git a/src/modules/processing/matchActionDecider.js b/src/modules/processing/matchActionDecider.js index f7ed3da9..b18bea42 100644 --- a/src/modules/processing/matchActionDecider.js +++ b/src/modules/processing/matchActionDecider.js @@ -130,6 +130,7 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di case "pinterest": case "streamable": case "loom": + case "odysee": responseType = "redirect"; break; } diff --git a/src/modules/processing/services/odysee.js b/src/modules/processing/services/odysee.js new file mode 100644 index 00000000..50640a9b --- /dev/null +++ b/src/modules/processing/services/odysee.js @@ -0,0 +1,27 @@ +import { genericUserAgent } from "../../config.js"; + +export default async function({ id }) { + const req = await fetch(`https://odysee.com/${id}`, { + method: "GET", + headers: { + "user-agent": genericUserAgent + } + }) + .then(req => {return req.text()}) + .catch(() => {}); + + // i couldn't find any other way to do this + var reqlines = req.split('\n'); + var contentline = reqlines[reqlines.length - 32]; + var videoUrl = contentline.split('"')[3]; + + if (videoUrl?.includes('.mp4')) { + return { + urls: videoUrl, + filename: `odysee_${id}.mp4`, + audioFilename: `odysee_${id}_audio` + } + } + + return { error: 'ErrorEmptyDownload' } +} diff --git a/src/modules/processing/servicesConfig.json b/src/modules/processing/servicesConfig.json index ae4cd9f0..c84035fc 100644 --- a/src/modules/processing/servicesConfig.json +++ b/src/modules/processing/servicesConfig.json @@ -1,5 +1,5 @@ { - "audioIgnore": ["vk", "ok", "loom"], + "audioIgnore": ["vk", "ok", "loom", "odysee"], "hlsExceptions": ["dailymotion", "vimeo", "rutube"], "config": { "bilibili": { @@ -117,6 +117,11 @@ "alias": "loom videos", "patterns": ["share/:id"], "enabled": true + }, + "odysee": { + "alias": "odysee videos", + "patterns": [":creator/:id", ":id"], + "enabled": true } } } diff --git a/src/modules/processing/servicesPatternTesters.js b/src/modules/processing/servicesPatternTesters.js index ddeea31f..ee389420 100644 --- a/src/modules/processing/servicesPatternTesters.js +++ b/src/modules/processing/servicesPatternTesters.js @@ -15,6 +15,9 @@ export const testers = { "ok": (patternMatch) => patternMatch.id?.length <= 16, + "odysee": (patternMatch) => + patternMatch.id?.length <= 255, + "pinterest": (patternMatch) => patternMatch.id?.length <= 128 || patternMatch.shortLink?.length <= 32,