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

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/modules/processing/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import rutube from "./services/rutube.js";
import dailymotion from "./services/dailymotion.js";
import snapchat from "./services/snapchat.js";
import loom from "./services/loom.js";
import videoclip from "./services/videoclip.js";
import facebook from "./services/facebook.js";

let freebind;
Expand Down Expand Up @@ -190,6 +191,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 "snapchat":
r = await snapchat({
hostname: url.hostname,
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 @@ -100,6 +100,13 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di

case "video":
switch (host) {
case "videoclip":
if (r.urls.endsWith(".m3u8")) {
params = { type: "render" }
} 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://" + 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 @@ -125,6 +125,12 @@
"patterns": ["share/:id"],
"enabled": true
},
"videoclip": {
"alias": "videoclip.bg videos",
"tld": "bg",
"patterns": ["watch/:id"],
"enabled": true
},
"facebook": {
"alias": "facebook videos",
"altDomains": ["fb.watch"],
Expand Down
4 changes: 3 additions & 1 deletion src/modules/processing/servicesPatternTesters.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export const testers = {
"bilibili": (patternMatch) =>
"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