Skip to main content

Django template tags for YouTube and Vimeo

Project description

Django app for easy embeding YouTube and Vimeo videos and music from SoundCloud.

https://travis-ci.org/yetty/django-embed-video.png?branch=master https://coveralls.io/repos/yetty/django-embed-video/badge.png?branch=master https://pypip.in/v/django-embed-video/badge.png https://pypip.in/d/django-embed-video/badge.png

Installation

pip install django-embed-video

or from sources

pip install git+https://github.com/yetty/django-embed-video.git

Add embed_video to INSTALLED_APPS in your Django settings.

Examples

Template examples

First you have to load the embed_video_tags template tags in your template:

{% load embed_video_tags %}

Simple embeding of video:

{% video item.video as my_video %}
    {{ my_video|embed:'small' }}
{% endvideo %}

Default sizes are tiny (420x315), small (480x360), medium (640x480), large (960x720) and huge (1280x960). You can set your own size:

{{ my_video|embed:'800x600' }}

Usage of variables:

{% video item.video as my_video %}
    URL: {{ my_video.url }}
    Thumbnail: {{ my_video.thumbnail }}
    Backend: {{ my_video.backend }}
{% endvideo %}

There is a simplier way, if you don’t need work with parameters as my_video.url or my_video.thumbnail and you want to use just embed tag.

{{ 'http://www.youtube.com/watch?v=guXyvo2FfLs'|embed:'large' }}

Model examples

Using the EmbedVideoField provides you validation of URLs.

from django.db import models
from embed_video.fields import EmbedVideoField

class Item(models.Model):
    video = EmbedVideoField()  # same like models.URLField()

Contributing

I will be really pleased if you will provide patch to this Django app. Feel free in changing source code, but please keep PEP8 rules and Zen.

TODO

  • provide AdminEmbedVideoMixin

  • Vimeo thumbnail

Changes

0.3

  • Security fix: faked urls are treated as invalid. See this page for more details.

  • Fixes:

    • allow of empty video field.

    • requirements in setup.py

  • Added simplier way to embed video in one-line template tag:

    {{ 'http://www.youtube.com/watch?v=guXyvo2FfLs'|embed:'large' }}
  • backend variable in video template tag.

    Usage:

    {% video item.video as my_video %}
        Backend: {{ my_video.backend }}
    {% endvideo %}

0.2

  • Support of SoundCloud

0.1

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-embed-video-0.3.tar.gz (9.1 kB view details)

Uploaded Source

File details

Details for the file django-embed-video-0.3.tar.gz.

File metadata

File hashes

Hashes for django-embed-video-0.3.tar.gz
Algorithm Hash digest
SHA256 7fb16c70d44312ad941f3263491d92434909bc5e2e8d7d0d35dc2183550f98b7
MD5 fab0f2066bfc4da032231322ac693225
BLAKE2b-256 8f09ccdb0b585d0661165b986444f1603f79080c9b649430ee7b247e60168c52

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page