This commit is contained in:
Valeria Fadeeva 2024-01-04 23:42:45 +05:00
parent 472dc7a224
commit f831d4fa94
1 changed files with 20 additions and 0 deletions

View File

@ -28,6 +28,26 @@ async function fetchData(log, tpl) {
}
if(key == "content") {
let text = value;
let youtube_frame_arr = [];
let spl_arr = text.split('"');
let youtube_link_start = 'https://www.youtube.com/watch?v=';
for (i = 0; i < spl_arr.length; i++) {
if (spl_arr[i].indexOf(youtube_link_start) === 0) {
let id = spl_arr[i].replace(youtube_link_start, '');
let text_frame = `<iframe width="560" height="315" src="https://www.youtube.com/embed/${id}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>`;
youtube_frame_arr.push(text_frame);
}
}
youtube_frame_arr.forEach(function(elem) {
text += elem;
});
value = text;
post_tpl = post_tpl.replace('{content}', `${value}`);
}