Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding video from vimeo error #7299

Open
danFbach opened this issue Aug 14, 2024 · 0 comments
Open

Embedding video from vimeo error #7299

danFbach opened this issue Aug 14, 2024 · 0 comments

Comments

@danFbach
Copy link
Contributor

danFbach commented Aug 14, 2024

nopCommerce version: 4.6

Vimeo is pretty aggressive in blocking "bot" traffic. It blacklists many datacenter's IP ranges, it fingerprints http clients to try to detect bots among many other methods. If you try to add a vimeo video to a product using Multimedia video tab, you will get either a 429 (too many requests) response or 401 (Unauthorized). This may not always be true, but a simple google search will pull up many reddit and stackoverflow threads about this issue.

I finally got a response from vimeo with a solution using their oembed API to perform this check.

I have changed the PingVideoUrlAsync method:

protected virtual async Task PingVideoUrlAsync(string videoUrl)
{
    var path = videoUrl.StartsWith("/") ? $"{_webHelper.GetStoreLocation()}{videoUrl.TrimStart('/')}" : videoUrl;

    if (path.Contains("vimeo.com"))
        path = "https://vimeo.com/api/oembed.json?url=" + WebUtility.UrlEncode(path);

    var client = _httpClientFactory.CreateClient(NopHttpDefaults.DefaultHttpClient);
    await client.GetStringAsync(path);
}

and I can add vimeo videos again.

see vimeo docs for reference to oembed api.

The suggested approach looks like a workaround. Let's find a better way to allow such video

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants