processing: add loom support (#530)

This commit is contained in:
wukko 2024-05-29 13:12:52 +06:00 committed by GitHub
parent 2a2183aa84
commit e4d42fa86a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 89 additions and 5 deletions

View file

@ -19,7 +19,8 @@ this list is not final and keeps expanding over time. if support for a service y
| bilibili.com & bilibili.tv | ✅ | ✅ | ✅ | | | | bilibili.com & bilibili.tv | ✅ | ✅ | ✅ | | |
| dailymotion | ✅ | ✅ | ✅ | ✅ | ✅ | | dailymotion | ✅ | ✅ | ✅ | ✅ | ✅ |
| instagram posts & reels | ✅ | ✅ | ✅ | | | | instagram posts & reels | ✅ | ✅ | ✅ | | |
| ok video | ✅ | ❌ | ❌ | ✅ | ✅ | | loom | ✅ | ❌ | ✅ | ✅ | |
| ok video | ✅ | ❌ | ✅ | ✅ | ✅ |
| pinterest | ✅ | ✅ | ✅ | | | | pinterest | ✅ | ✅ | ✅ | | |
| reddit | ✅ | ✅ | ✅ | ❌ | ❌ | | reddit | ✅ | ✅ | ✅ | ❌ | ❌ |
| rutube | ✅ | ✅ | ✅ | ✅ | ✅ | | rutube | ✅ | ✅ | ✅ | ✅ | ✅ |
@ -31,7 +32,7 @@ this list is not final and keeps expanding over time. if support for a service y
| twitter/x | ✅ | ✅ | ✅ | | | | twitter/x | ✅ | ✅ | ✅ | | |
| vimeo | ✅ | ✅ | ✅ | ✅ | ✅ | | vimeo | ✅ | ✅ | ✅ | ✅ | ✅ |
| vine archive | ✅ | ✅ | ✅ | | | | vine archive | ✅ | ✅ | ✅ | | |
| vk videos & clips | ✅ | ❌ | | ✅ | ✅ | | vk videos & clips | ✅ | ❌ | | ✅ | ✅ |
| youtube videos, shorts & music | ✅ | ✅ | ✅ | ✅ | ✅ | | youtube videos, shorts & music | ✅ | ✅ | ✅ | ✅ | ✅ |
| emoji | meaning | | emoji | meaning |

View file

@ -24,6 +24,7 @@ import streamable from "./services/streamable.js";
import twitch from "./services/twitch.js"; import twitch from "./services/twitch.js";
import rutube from "./services/rutube.js"; import rutube from "./services/rutube.js";
import dailymotion from "./services/dailymotion.js"; import dailymotion from "./services/dailymotion.js";
import loom from "./services/loom.js";
let freebind; let freebind;
@ -187,6 +188,11 @@ export default async function(host, patternMatch, lang, obj) {
case "dailymotion": case "dailymotion":
r = await dailymotion(patternMatch); r = await dailymotion(patternMatch);
break; break;
case "loom":
r = await loom({
id: patternMatch.id
});
break;
default: default:
return createResponse("error", { return createResponse("error", {
t: loc(lang, 'ErrorUnsupported') t: loc(lang, 'ErrorUnsupported')

View file

@ -129,6 +129,7 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
case "tumblr": case "tumblr":
case "pinterest": case "pinterest":
case "streamable": case "streamable":
case "loom":
responseType = "redirect"; responseType = "redirect";
break; break;
} }

View file

@ -0,0 +1,39 @@
import { genericUserAgent } from "../../config.js";
export default async function({ id }) {
const gql = await fetch(`https://www.loom.com/api/campaigns/sessions/${id}/transcoded-url`, {
method: "POST",
headers: {
"user-agent": genericUserAgent,
origin: "https://www.loom.com",
referer: `https://www.loom.com/share/${id}`,
cookie: `loom_referral_video=${id};`,
"apollographql-client-name": "web",
"apollographql-client-version": "14c0b42",
"x-loom-request-source": "loom_web_14c0b42",
},
body: JSON.stringify({
force_original: false,
password: null,
anonID: null,
deviceID: null
})
})
.then(r => r.status === 200 ? r.json() : false)
.catch(() => {});
if (!gql) return { error: 'ErrorEmptyDownload' };
const videoUrl = gql?.url;
if (videoUrl?.includes('.mp4?')) {
return {
urls: videoUrl,
filename: `loom_${id}.mp4`,
audioFilename: `loom_${id}_audio`
}
}
return { error: 'ErrorEmptyDownload' }
}

View file

@ -1,5 +1,5 @@
{ {
"audioIgnore": ["vk", "ok"], "audioIgnore": ["vk", "ok", "loom"],
"hlsExceptions": ["dailymotion", "vimeo", "rutube"], "hlsExceptions": ["dailymotion", "vimeo", "rutube"],
"config": { "config": {
"bilibili": { "bilibili": {
@ -112,6 +112,11 @@
"alias": "dailymotion videos", "alias": "dailymotion videos",
"patterns": ["video/:id"], "patterns": ["video/:id"],
"enabled": true "enabled": true
},
"loom": {
"alias": "loom videos",
"patterns": ["share/:id"],
"enabled": true
} }
} }
} }

View file

@ -9,6 +9,9 @@ export const testers = {
patternMatch.postId?.length <= 12 patternMatch.postId?.length <= 12
|| (patternMatch.username?.length <= 30 && patternMatch.storyId?.length <= 24), || (patternMatch.username?.length <= 30 && patternMatch.storyId?.length <= 24),
"loom": (patternMatch) =>
patternMatch.id?.length <= 32,
"ok": (patternMatch) => "ok": (patternMatch) =>
patternMatch.id?.length <= 16, patternMatch.id?.length <= 16,

View file

@ -1131,5 +1131,34 @@
"code": 200, "code": 200,
"status": "stream" "status": "stream"
} }
}],
"loom": [{
"name": "1080p video",
"url": "https://www.loom.com/share/313bf71d20ca47b2a35b6634cefdb761",
"params": {},
"expected": {
"code": 200,
"status": "redirect"
}
}, {
"name": "1080p video (muted)",
"url": "https://www.loom.com/share/313bf71d20ca47b2a35b6634cefdb761",
"params": {
"isAudioMuted": true
},
"expected": {
"code": 200,
"status": "stream"
}
}, {
"name": "1080p video (audio only)",
"url": "https://www.loom.com/share/313bf71d20ca47b2a35b6634cefdb761",
"params": {
"isAudioOnly": true
},
"expected": {
"code": 200,
"status": "stream"
}
}] }]
} }