From 443725690859ea065c0995a6de38b149ff7522e9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 8 Oct 2022 15:53:07 +0100 Subject: [PATCH] Create embeds for tiktok video links --- webapp_media.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/webapp_media.py b/webapp_media.py index 776a46e21..f502418f7 100644 --- a/webapp_media.py +++ b/webapp_media.py @@ -37,6 +37,33 @@ def _add_embedded_video_from_sites(translate: {}, content: str, domain: str) -> str: """Adds embedded videos """ + if 'www.tiktok.com/@' in content and \ + 'www.tiktok.com/embed.js' not in content: + url = content.split('www.tiktok.com/@')[1] + if '<' in url: + url = url.split('<')[0] + if '/video/' in url: + channel = url.split('/')[0] + video_id = url.split('/')[1] + if '?' in video_id: + video_id = video_id.split('?')[0] + content += \ + '
\n\n' + \ + '
\n' + \ + '
\n' + \ + '@' + channel + '\n' + \ + '
\n
\n' + \ + '
\n
\n' + return content + if '