# frozen_string_literal: true module Onebox module Engine class TiktokOnebox include Engine include StandardEmbed matches_regexp(%r{^https?://((?:m|www)\.)?tiktok\.com(?:/@(.+)\/video/|/v/)\d+(/\w+)?/?}) requires_iframe_origins "https://www.tiktok.com" always_https def placeholder_html <<-HTML HTML end def to_html video_height = oembed_data.thumbnail_height < 1024 ? 998 : oembed_data.thumbnail_height height = (323.0 / 576) * video_height <<-HTML HTML end private def oembed_data @oembed_data = get_oembed end def get_oembed_url "https://www.tiktok.com/oembed?url=#{url}" end end end end