jazzband / django-embed-video

Django app for easy embedding YouTube and Vimeo videos and music from SoundCloud.
http://django-embed-video.rtfd.org
MIT License
382 stars 135 forks source link

Vimeo player doesn't retrieve anything when used from a site using https #11

Closed duy closed 10 years ago

duy commented 10 years ago

https://github.com/duy/django-embed-video/commit/3b24c963610b32d03b8f6df27b9cf5c3a00b377a

yetty commented 10 years ago

Duplicated with #12 .

antonagestam commented 10 years ago

Would be nice with a setting to always convert use HTTPS. E.g. for sites that lets users submit URLs. I'm currently using this as a workaround:

import re

from django import template
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe

from embed_video.templatetags.embed_video_tags import embed as default_embed

register = template.Library()
pattern = re.compile('http://')
replace = 'https://'

def embed(input, args):
    output = default_embed(input, args)
    return mark_safe(pattern.sub(replace, output))

embed.is_safe = True
embed = stringfilter(embed)

register.filter('embed', embed)
antonagestam commented 10 years ago

@duy Let me know if you'd be interested in a pull request.

yetty commented 10 years ago

I am not sure, if it is the best possible solution. No every service provides https protocol, so it should depend on VideoBackend.

I think, that the cleanest way is to not specified protol, like this:

//vimeo.com/72304002

Or if HTTPS is really needed, you can always change pattern_url.

class MyVimeoBackend(VimeoBackend):
    pattern_url = 'https://player.vimeo.com/video/%s'

I am not sure, if https should be strictly default. After all decoding SSL takes some computer time. What do you think about it?

antonagestam commented 10 years ago

I agree that it should not be the default, but if you're trying to embed HTTP on an HTTPS site, it simply breaks and doesn't load anything. It's probably the pattern_url that should be without a specified protocol.

yetty commented 10 years ago

Well, it's quite complicated. First do you run on development version from GitHub? It was changed quite recently (in 3b24c96) and isn't on PyPI yet.

I googled little bit and I am not sure, if it can work safely without specified protocol. More people have troubles with it.

Some links to this topic:

I'll try to play around and find some pretty and safe way. Now I see only possible way - to detect protocol from request. Perhaps the cleanest way, but it is possible only with context (of course) - in other words just in template tag. But it should not be a problem.

What do you think about it? If we don't find better way, I'll update template tag.