diff --git a/src/modules/processing/match.js b/src/modules/processing/match.js index 267fc258..75ce5b78 100644 --- a/src/modules/processing/match.js +++ b/src/modules/processing/match.js @@ -13,6 +13,7 @@ import reddit from "./services/reddit.js"; import twitter from "./services/twitter.js"; import youtube from "./services/youtube.js"; import vk from "./services/vk.js"; +import ok from "./services/ok.js"; import tiktok from "./services/tiktok.js"; import tumblr from "./services/tumblr.js"; import vimeo from "./services/vimeo.js"; @@ -43,19 +44,25 @@ export default async function(host, patternMatch, url, lang, obj) { break; case "vk": r = await vk({ - userId: patternMatch["userId"], - videoId: patternMatch["videoId"], + userId: patternMatch.userId, + videoId: patternMatch.videoId, + quality: obj.vQuality + }); + break; + case "ok": + r = await ok({ + id: patternMatch.id, quality: obj.vQuality }); break; case "bilibili": r = await bilibili({ - id: patternMatch["id"].slice(0, 12) + id: patternMatch.id.slice(0, 12) }); break; case "youtube": let fetchInfo = { - id: patternMatch["id"].slice(0, 11), + id: patternMatch.id.slice(0, 11), quality: obj.vQuality, format: obj.vCodec, isAudioOnly: isAudioOnly, @@ -73,16 +80,16 @@ export default async function(host, patternMatch, url, lang, obj) { break; case "reddit": r = await reddit({ - sub: patternMatch["sub"], - id: patternMatch["id"] + sub: patternMatch.sub, + id: patternMatch.id }); break; case "douyin": case "tiktok": r = await tiktok({ host: host, - postId: patternMatch["postId"], - id: patternMatch["id"], + postId: patternMatch.postId, + id: patternMatch.id, noWatermark: obj.isNoTTWatermark, fullAudio: obj.isTTFullAudio, isAudioOnly: isAudioOnly @@ -97,7 +104,7 @@ export default async function(host, patternMatch, url, lang, obj) { break; case "vimeo": r = await vimeo({ - id: patternMatch["id"].slice(0, 11), + id: patternMatch.id.slice(0, 11), quality: obj.vQuality, isAudioOnly: isAudioOnly, forceDash: isAudioOnly ? true : obj.vimeoDash @@ -107,10 +114,10 @@ export default async function(host, patternMatch, url, lang, obj) { isAudioOnly = true; r = await soundcloud({ url, - author: patternMatch["author"], - song: patternMatch["song"], - shortLink: patternMatch["shortLink"] || false, - accessKey: patternMatch["accessKey"] || false + author: patternMatch.author, + song: patternMatch.song, + shortLink: patternMatch.shortLink || false, + accessKey: patternMatch.accessKey || false }); break; case "instagram": @@ -121,31 +128,31 @@ export default async function(host, patternMatch, url, lang, obj) { break; case "vine": r = await vine({ - id: patternMatch["id"] + id: patternMatch.id }); break; case "pinterest": r = await pinterest({ - id: patternMatch["id"] + id: patternMatch.id }); break; case "streamable": r = await streamable({ - id: patternMatch["id"], + id: patternMatch.id, quality: obj.vQuality, isAudioOnly: isAudioOnly, }); break; case "twitch": r = await twitch({ - clipId: patternMatch["clip"] || false, + clipId: patternMatch.clip || false, quality: obj.vQuality, isAudioOnly: obj.isAudioOnly }); break; case "rutube": r = await rutube({ - id: patternMatch["id"], + id: patternMatch.id, quality: obj.vQuality, isAudioOnly: isAudioOnly }); diff --git a/src/modules/processing/services/ok.js b/src/modules/processing/services/ok.js new file mode 100644 index 00000000..bde163f6 --- /dev/null +++ b/src/modules/processing/services/ok.js @@ -0,0 +1,56 @@ +import { genericUserAgent, maxVideoDuration } from "../../config.js"; +import { cleanString } from "../../sub/utils.js"; + +const resolutions = { + "ultra": "2160", + "quad": "1440", + "full": "1080", + "hd": "720", + "sd": "480", + "low": "360", + "lowest": "240", + "mobile": "144" +} + +export default async function(o) { + let quality = o.quality === "max" ? "2160" : o.quality; + + let html = await fetch(`https://ok.ru/video/${o.id}`, { + headers: { "user-agent": genericUserAgent } + }).then((r) => { return r.text() }).catch(() => { return false }); + + if (!html) return { error: 'ErrorCouldntFetch' }; + if (!html.includes(`