services/ok: fix video data extraction

closes #589
This commit is contained in:
dumbmoron 2024-07-06 08:23:20 +00:00
parent 8276e51dbc
commit 0fefc4ac27
No known key found for this signature in database

View file

@ -20,14 +20,15 @@ export default async function(o) {
}).then(r => r.text()).catch(() => {});
if (!html) return { error: 'ErrorCouldntFetch' };
if (!html.includes(`<div data-module="OKVideo" data-options="{`)) {
let videoData = html.match(/<div data-module="OKVideo" .*? data-options="({.*?})"( .*?)>/)
?.[1]
?.replaceAll("&quot;", '"');
if (!videoData) {
return { error: 'ErrorEmptyDownload' };
}
let videoData = html.split(`<div data-module="OKVideo" data-options="`)[1]
.split('" data-')[0]
.replaceAll("&quot;", '"');
videoData = JSON.parse(JSON.parse(videoData).flashvars.metadata);
if (videoData.provider !== "UPLOADED_ODKL")