Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

videoclip.bg support #538

Draft
wants to merge 12 commits into
base: current
Choose a base branch
from
6 changes: 6 additions & 0 deletions src/modules/processing/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 videoclip from "./services/videoclip.js";

let freebind;

Expand Down Expand Up @@ -188,6 +189,11 @@ export default async function(host, patternMatch, lang, obj) {
case "dailymotion":
r = await dailymotion(patternMatch);
break;
case "videoclip":
r = await videoclip({
id: patternMatch.id
});
break;
case "loom":
r = await loom({
id: patternMatch.id
Expand Down
7 changes: 7 additions & 0 deletions src/modules/processing/matchActionDecider.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di

case "video":
switch (host) {
case "videoclip":
if (r.urls.endsWith(".m3u8")) {
params = { type: "stream" }
ihatespawn marked this conversation as resolved.
Show resolved Hide resolved
} else {
responseType = "redirect";
}
break;
case "bilibili":
params = { type: "render" };
break;
Expand Down
32 changes: 32 additions & 0 deletions src/modules/processing/services/videoclip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { genericUserAgent } from "../../config.js";

export default async function({ id }) {
const modifiedId = id.split("_")[0]
const requestText = await fetch(`https://www.videoclip.bg/watch/${id}`, {
method: "GET",
headers: {
"user-agent": genericUserAgent
}
})
.then(req => {return req.text()})
.catch(() => {});

var videoTag = requestText.split('<video')[1];
var videoSource = videoTag.split(">")[1].split('<source')[1].split('"')[1].split('//')[1];
if (videoSource.endsWith(".mpd")) {
videoSource = videoTag.split(">")[2].split('<source')[1].split('"')[1].split('//')[1];
} else if (!videoSource.endsWith(".mp4")) {
return { error: 'ErrorCouldntFetch'};
}

if (videoSource) {
return {
urls: "https://www." + videoSource,
isM3U8: videoSource.endsWith(".m3u8"),
filename: `videoclip_${modifiedId}.mp4`,
audioFilename: `videoclip_${modifiedId}_audio`
}
}

return { error: 'ErrorEmptyDownload' }
}
8 changes: 7 additions & 1 deletion src/modules/processing/servicesConfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"audioIgnore": ["vk", "ok", "loom"],
"hlsExceptions": ["dailymotion", "vimeo", "rutube"],
"hlsExceptions": ["dailymotion", "vimeo", "rutube", "videoclip"],
"config": {
"bilibili": {
"alias": "bilibili.com & bilibili.tv",
Expand Down Expand Up @@ -117,6 +117,12 @@
"alias": "loom videos",
"patterns": ["share/:id"],
"enabled": true
},
"videoclip": {
"alias": "videoclip.bg videos",
"tld": "bg",
"patterns": ["watch/:id"],
"enabled": true
}
}
}
2 changes: 2 additions & 0 deletions src/modules/processing/servicesPatternTesters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const testers = {
"videoclip": (patternMatch) => patternMatch.id?.match(/^[0-9]/),
ihatespawn marked this conversation as resolved.
Show resolved Hide resolved

"bilibili": (patternMatch) =>
patternMatch.comId?.length <= 12 || patternMatch.comShortLink?.length <= 16
|| patternMatch.tvId?.length <= 24,
Expand Down