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

Allow loading of higher resolution thumbnail #43

Closed emyller closed 8 years ago

emyller commented 9 years ago

By default, embed-video loads thumbnails from YouTube based on the following format: '{protocol}://img.youtube.com/vi/{code}/hqdefault.jpg'.

It would be very good if I could load a higher-res thumbnail. The following string format could be used: '{protocol}://img.youtube.com/vi/{code}/maxresdefault.jpg'.

yetty commented 9 years ago

Great improvement, thank you.

yetty commented 9 years ago

It seems maxresdefault is not available for all video.

https://img.youtube.com/vi/f-5wKbynvD0/maxresdefault.jpg https://img.youtube.com/vi/f-5wKbynvD0/hqdefault.jpg

emyller commented 9 years ago

Thanks for the change. :)

Sad fact. Do you think it's worthy to check HTTP status code on maxresdefault - without downloading! - then fallback to hqdefault?

yetty commented 9 years ago

I am not sure, if status code can be resolved without downloading whole response. If there is a way, feel free to implement it or give some information, how to do it. Downloading whole image is quite heavy solution for getting only thumbnail url.

emyller commented 9 years ago

Okay, I'll try to find/do something.

DiogoMarques29 commented 8 years ago

Hi How about this? http://stackoverflow.com/questions/6471275/python-script-to-see-if-a-web-page-exists-without-downloading-the-whole-page?answertab=active#tab-top

This is a way to check if status code is < 400 without downloading the whole page.

DiogoMarques29 commented 8 years ago

Hi again

I have found a better solution that works like this:

def checkUrl(url):
    import requests
    r = requests.head(url)
    return int(r.status_code) < 400
yetty commented 8 years ago

Great! Can you create a pull request with this improvement?

DiogoMarques29 commented 8 years ago

I will as soon as i have some time. Got any ideia when a new release will be available?

yetty commented 8 years ago

As soon as the support for Django 1.9 will be added + this functionality, too.