Skip to content

Commit

Permalink
processing: add loom support (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
wukko authored May 29, 2024
1 parent 2a2183a commit e4d42fa
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ this list is not final and keeps expanding over time. if support for a service y
| bilibili.com & bilibili.tv ||||||
| dailymotion ||||||
| instagram posts & reels ||||||
| ok video ||||||
| loom ||||||
| ok video ||||||
| pinterest ||||||
| reddit ||||||
| rutube ||||||
Expand All @@ -31,7 +32,7 @@ this list is not final and keeps expanding over time. if support for a service y
| twitter/x ||||||
| vimeo ||||||
| vine archive ||||||
| vk videos & clips ||| |||
| vk videos & clips ||| |||
| youtube videos, shorts & music ||||||

| emoji | meaning |
Expand Down
6 changes: 6 additions & 0 deletions src/modules/processing/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import streamable from "./services/streamable.js";
import twitch from "./services/twitch.js";
import rutube from "./services/rutube.js";
import dailymotion from "./services/dailymotion.js";
import loom from "./services/loom.js";

let freebind;

Expand Down Expand Up @@ -187,6 +188,11 @@ export default async function(host, patternMatch, lang, obj) {
case "dailymotion":
r = await dailymotion(patternMatch);
break;
case "loom":
r = await loom({
id: patternMatch.id
});
break;
default:
return createResponse("error", {
t: loc(lang, 'ErrorUnsupported')
Expand Down
1 change: 1 addition & 0 deletions src/modules/processing/matchActionDecider.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
case "tumblr":
case "pinterest":
case "streamable":
case "loom":
responseType = "redirect";
break;
}
Expand Down
39 changes: 39 additions & 0 deletions src/modules/processing/services/loom.js
Original file line number Diff line number Diff line change
@@ -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' }
}
7 changes: 6 additions & 1 deletion src/modules/processing/servicesConfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"audioIgnore": ["vk", "ok"],
"audioIgnore": ["vk", "ok", "loom"],
"hlsExceptions": ["dailymotion", "vimeo", "rutube"],
"config": {
"bilibili": {
Expand Down Expand Up @@ -112,6 +112,11 @@
"alias": "dailymotion videos",
"patterns": ["video/:id"],
"enabled": true
},
"loom": {
"alias": "loom videos",
"patterns": ["share/:id"],
"enabled": true
}
}
}
7 changes: 5 additions & 2 deletions src/modules/processing/servicesPatternTesters.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export const testers = {
"instagram": (patternMatch) =>
patternMatch.postId?.length <= 12
|| (patternMatch.username?.length <= 30 && patternMatch.storyId?.length <= 24),


"loom": (patternMatch) =>
patternMatch.id?.length <= 32,

"ok": (patternMatch) =>
patternMatch.id?.length <= 16,

Expand All @@ -29,7 +32,7 @@ export const testers = {

"streamable": (patternMatch) =>
patternMatch.id?.length === 6,

"tiktok": (patternMatch) =>
patternMatch.postId?.length <= 21 || patternMatch.id?.length <= 13,

Expand Down
29 changes: 29 additions & 0 deletions src/test/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -1131,5 +1131,34 @@
"code": 200,
"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"
}
}]
}

0 comments on commit e4d42fa

Please sign in to comment.