django-embed-video/README.rst

127 lines
2.6 KiB
ReStructuredText
Raw Normal View History

2013-05-31 11:22:44 +00:00
django-embed-video
==================
2013-06-26 10:54:56 +00:00
Django app for easy embeding YouTube and Vimeo videos and music from SoundCloud.
.. image:: https://travis-ci.org/yetty/django-embed-video.png?branch=master
2013-06-27 08:12:00 +00:00
:target: https://travis-ci.org/yetty/django-embed-video
2013-07-30 21:31:31 +00:00
.. image:: https://coveralls.io/repos/yetty/django-embed-video/badge.png?branch=master
:target: https://coveralls.io/r/yetty/django-embed-video?branch=master
.. image:: https://pypip.in/v/django-embed-video/badge.png
:target: https://crate.io/packages/django-embed-video/
.. image:: https://pypip.in/d/django-embed-video/badge.png
:target: https://crate.io/packages/django-embed-video/
2013-05-31 11:22:44 +00:00
2013-06-01 13:01:52 +00:00
Installation
2013-06-01 13:21:01 +00:00
************
::
2013-06-01 13:01:52 +00:00
pip install django-embed-video
2013-06-01 13:38:53 +00:00
or from sources
::
pip install git+https://github.com/yetty/django-embed-video.git
2013-06-01 13:21:01 +00:00
Add ``embed_video`` to ``INSTALLED_APPS`` in your Django settings.
2013-06-01 13:01:52 +00:00
Examples
2013-06-01 13:21:01 +00:00
********
2013-06-01 13:01:52 +00:00
2013-06-01 13:21:01 +00:00
Template examples
-----------------
2013-06-01 13:01:52 +00:00
First you have to load the `embed_video_tags` template tags in your template:
2013-06-01 13:21:01 +00:00
::
2013-06-01 13:01:52 +00:00
{% load embed_video_tags %}
Simple embeding of video:
2013-06-01 13:21:01 +00:00
::
2013-06-27 08:01:06 +00:00
{% video item.video as my_video %}
{{ my_video|embed:'small' }}
2013-06-01 13:01:52 +00:00
{% endvideo %}
2013-06-01 13:21:01 +00:00
Default sizes are ``tiny`` (420x315), ``small`` (480x360), ``medium`` (640x480),
``large`` (960x720) and ``huge`` (1280x960). You can set your own size:
::
2013-06-01 13:01:52 +00:00
2013-06-27 08:01:06 +00:00
{{ my_video|embed:'800x600' }}
2013-06-01 13:01:52 +00:00
Usage of variables:
2013-06-01 13:21:01 +00:00
::
2013-06-27 08:10:27 +00:00
{% video item.video as my_video %}
URL: {{ my_video.url }}
Thumbnail: {{ my_video.thumbnail }}
Backend: {{ my_video.backend }}
2013-06-01 13:01:52 +00:00
{% endvideo %}
2013-06-27 08:10:27 +00:00
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' }}
2013-06-01 13:21:01 +00:00
Model examples
---------------
2013-06-01 13:01:52 +00:00
Using the EmbedVideoField provides you validation of URLs.
2013-06-01 13:01:52 +00:00
2013-06-01 13:21:01 +00:00
::
2013-06-01 13:01:52 +00:00
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 <http://www.python.org/dev/peps/pep-0008/>`_
rules and `Zen <http://www.python.org/dev/peps/pep-0020/>`_.
2013-06-01 13:01:52 +00:00
TODO
2013-06-01 13:21:01 +00:00
*****
2013-06-01 13:01:52 +00:00
- provide AdminEmbedVideoMixin
- Vimeo thumbnail
Websites using django-embed-video
*********************************
- `Tchorici.cz <http://www.tchorici.cz>`_ (`sources
<https://github.com/yetty/Tchorici/>`_)
*Are you using django-embed-video? Send pull request!*
2013-06-01 13:01:52 +00:00
.. vim: set tw=80: