Giter Club home page Giter Club logo

djangocms-video's Introduction

django CMS Video

pypi build coverage

django CMS Video is a set of plugins for django CMS that allow you to publish video content on your site (using an HTML5 player by default, but you can override this in your own templates if required).

It uses files managed by Django Filer.

Note

This project is endorsed by the django CMS Association. That means that it is officially accepted by the dCA as being in line with our roadmap vision and development/plugin policy. Join us on Slack.

preview.gif

Contribute to this project and win rewards

Because this is a an open-source project, we welcome everyone to get involved in the project and receive a reward for their contribution. Become part of a fantastic community and help us make django CMS the best CMS in the world.

We'll be delighted to receive your feedback in the form of issues and pull requests. Before submitting your pull request, please review our contribution guidelines.

We're grateful to all contributors who have helped create and maintain this package. Contributors are listed at the contributors section.

Documentation

See REQUIREMENTS in the setup.py file for additional dependencies:

python django djangocms

  • Django Filer 1.7 or higher

Make sure django-filer is installed and configured appropriately.

Installation

For a manual install:

  • run pip install djangocms-video
  • add djangocms_video to your INSTALLED_APPS
  • run python manage.py migrate djangocms_video

Configuration

Note that the provided templates are very minimal by design. You are encouraged to adapt and override them to your project's requirements.

This addon provides a default template for all instances. You can provide additional template choices by adding a DJANGOCMS_VIDEO_TEMPLATES setting:

from django.utils.translation import gettext_lazy as _

DJANGOCMS_VIDEO_TEMPLATES = [
    ('feature', _('Featured Version')),
]

You'll need to create the feature folder inside templates/djangocms_video/ otherwise you will get a template does not exist error. You can do this by copying the default folder inside that directory and renaming it to feature.

MP4, WEBM and OGV files are allowed by default. We recommend adding all 3 source files for full browser compatibility. You can change the default setting by overriding:

DJANGOCMS_VIDEO_ALLOWED_EXTENSIONS = ['mp4', 'webm', 'ogv']

The plugin detects YouTube URLs using a regular expression and canonicalizes them to //www.youtube.com/embed/{} where the placeholder is replaced by the video id.

The canonical URL can be reconfigured with a configuration setting:

DJANGOCMS_VIDEO_YOUTUBE_EMBED_URL = '//www.youtube-nocookie.com/embed/{}'

Running Tests

You can run tests by executing:

virtualenv env
source env/bin/activate
pip install -r tests/requirements.txt
python setup.py test

djangocms-video's People

Contributors

bplociennik avatar chive avatar crydotsnake avatar digi604 avatar filwaitman avatar finalangel avatar fsbraun avatar jandd avatar jsma avatar kaushal-dhungel avatar mammuth avatar mkoistinen avatar mogoh avatar nffdiogosilva avatar nicolairidani avatar pevar avatar ron8mcr avatar skirsdeda avatar stefanfoulis avatar vthaian avatar wfehr avatar yakky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

djangocms-video's Issues

Youku

I just tried integrating a Youku video into a post using djangocms-video (==2.0.3). I couldn't get it work. Have any of you tried that at all? Does this plugin only work with Youtube and Vimeo? No matter how I amend the embed code url, I just can't get it to show up properly.

2.0.4 is not on pypi

Like the title says, it seems like you've forgotten to release the 2.0.4 version on PyPi. Could you please do so? :)

swfobject.min.js no longer exists in `cms/js/libs`

In the latest version of Django-cms, v3.3.0, the swfobject.min.js file has been removed from the included cms/js/lib static files. Djangocms-video depends on this the file to work, so it needs to be added back in to be compatible.

It's quite hard to embed a YouTube video

The steps required for an end-user to actually embed a YouTube video seem quite hard:

  • Find the video on YouTube
  • Click on 'share'
  • Go to the 'embed' tab
  • Extract the 'src' attribute from the generated iframe code

Especially the last step is in my opinion way too hard for the average user.

My suggestion would be to either extract the src attribute if the whole iframe code is pasted into the embed field, or even better, to accept the URL of the video (in the format https://www.youtube.com/watch?v=XXXXXXXXXXX) and convert that to an embed link.

If I remember correctly, Django Embed Video uses the last option, which IMHO greatly enhances usability.

Setting for default template

There should be an option to conveniently set the template that is selected by default.

The filer image plugin is doing it like this:

CMSPLUGIN_FILER_IMAGE_STYLE_CHOICES = (
    ('default', 'Default'),
    ('boxed', 'Boxed'),
)
CMSPLUGIN_FILER_IMAGE_DEFAULT_STYLE = 'boxed'

It looks like there is currently no way to make someones template the default template, is this correct?

Don't really understand your instructions

After installing djangocms-video with pip, and trying to add the codes, however, I don't know which files I should modify, as I can't see from your instructions. e.g. you may simply say:

you can provide additional template choices by adding a DJANGOCMS_VIDEO_TEMPLATES setting:

DJANGOCMS_VIDEO_TEMPLATES = [
('feature', _('Featured Version')),
]

but I don't know which file I should modify.

Can you please provide the file names and the relevant paths? Thanks.

aldryn_search indexing incompatibility

As aldryn_search is trying to index the contents of every plugin the VideoSourcePlugin (and I suppose it's the same with the VideoTrackPlugin) breaks when trying to publish a page.
Both plugins are trying to access the template through the context in the get_render_template method which does not work when a page is published and aldryn_search is trying to render it.
Line in the plugin:
https://github.com/divio/djangocms-video/blob/master/djangocms_video/cms_plugins.py#L72
Line in aldryn_search:
https://github.com/aldryn/aldryn-search/blob/master/aldryn_search/helpers.py#L48

If I got the problem right I guess it would help to add search_fields to the models.

Bug with non-local storage.

If project uses non-local storage (S3 for example with storages.backends.s3boto.S3BotoStorage) there is a bug on models.Video.__str__() (here) caused that not all storages backends support absolute paths.

Support youku

We have Chinese content on developer.ubuntu.com and it'd be great if we could embed youku videos, as youtube is blocked in China and youku very popular there.

south migrations

Had problem with south migration:

In the README you wrote:

Add 'djangocms_video': 'djangocms_video.migrations_django', to SOUTH_MIGRATION_MODULES

But I had to write:
'djangocms_video': 'djangocms_video.south_migrations',

See pull request:
#17

Migration issue with PostgreSQL

See django-cms/djangocms-picture#47

I'm getting the following when trying to migrate djangocms-video with PostgreSQL 9.1:

Applying djangocms_video.0004_move_to_attributes...Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 200, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 92, in migrate
    self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 198, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 123, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 121, in database_forwards
    schema_editor.remove_field(from_model, from_model._meta.get_field(self.name))
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 438, in remove_field
    self.execute(sql)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 110, in execute
    cursor.execute(sql, params)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/var/www/mysite/staging/ENV/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.OperationalError: cannot ALTER TABLE "djangocms_video_videoplayer" because it has pending trigger events

I think this migration should be split into 3 different migrations so that the data migration part is in a separate migration. According to the Django docs:

On databases that do support DDL transactions (SQLite and PostgreSQL), RunPython operations do not have any transactions automatically added besides the transactions created for each migration. Thus, on PostgreSQL, for example, you should avoid combining schema changes and RunPython operations in the same migration or you may hit errors like OperationalError: cannot ALTER TABLE "mytable" because it has pending trigger events.

Do not install tests

--- setup.py.orig	2018-11-13 07:48:48.000000000 +0000
+++ setup.py
@@ -41,7 +41,7 @@ setup(
     url='https://github.com/divio/djangocms-video',
     license='BSD',
     long_description=open('README.rst').read(),
-    packages=find_packages(),
+    packages=find_packages(exclude=['tests']),
     include_package_data=True,
     zip_safe=False,
     install_requires=REQUIREMENTS,

Add supporting query parameters for youtube embed link

Hi!
Now you can't add any of allowed parameters you can read https://developers.google.com/youtube/player_parameters
So, I fixed it and want to share my solution.
Sorry, I don't have time to make a pull request, I just put the solution here:

file forms.py

import re
from urllib.parse import urlparse, parse_qs, urlencode

from django import forms

from . import models


YOUTUBE_URL_RE = re.compile(r'(?:(?:http://|https://|//)?(?:www\.)?youtu\.?be.*).*')
# https://stackoverflow.com/a/9102270
YOUTUBE_VIDEO_ID_RE = re.compile(r'(?:[?&]v=|/embed/|/1/|/v/|https?://(?:www\.)?youtu\.be/)([^&\n?#]+)')
YOUTUBE_EMBED_URL = '//www.youtube.com/embed/{}'
YOUTUBE_ALLOW_URL_PARAMS = (
    # see more https://developers.google.com/youtube/player_parameters
    'autoplay', 'cc_load_policy', 'color', 'controls', 'disablekb',
    'enablejsapi', 'end', 'fs', 'hl', 'iv_load_policy', 'list',
    'listType', 'loop', 'modestbranding', 'origin', 'playlist',
    'playsinline', 'rel', 'showinfo', 'start', 'widget_referrer',
)


class VideoPlayerPluginForm(forms.ModelForm):
    class Meta:
        model = models.VideoPlayer
        exclude = []

    def clean_embed_link(self):
        link = self.cleaned_data['embed_link']
        # let's check if it's a youtube url
        # (the low cost version)
        if YOUTUBE_URL_RE.match(link):
            qs = {k: v for k, v in parse_qs(urlparse(link).query).items() if k in self.YOUTUBE_ALLOW_URL_PARAMS and v}
            # try to get the video id
            results = YOUTUBE_VIDEO_ID_RE.findall(link)
            if results:
                link = YOUTUBE_EMBED_URL.format(results[0])
            if qs:
                link = '{}?{}'.format(link, urlencode(qs, doseq=True))
        return link

If the author won't update the package by adding my solution, everyone can use monkey patching:

from urllib.parse import urlparse, parse_qs, urlencode


def form_validator_fix():
    from djangocms_video import forms

    setattr(forms.VideoPlayerPluginForm, 'YOUTUBE_ALLOW_URL_PARAMS', (
        # see more https://developers.google.com/youtube/player_parameters
        'autoplay', 'cc_load_policy', 'color', 'controls', 'disablekb',
        'enablejsapi', 'end', 'fs', 'hl', 'iv_load_policy', 'list',
        'listType', 'loop', 'modestbranding', 'origin', 'playlist',
        'playsinline', 'rel', 'showinfo', 'start', 'widget_referrer',
    ))

    def clean_embed_link(self):
        link = self.cleaned_data['embed_link']
        # let's check if it's a youtube url
        # (the low cost version)
        if forms.YOUTUBE_URL_RE.match(link):
            qs = {k: v for k, v in parse_qs(urlparse(link).query).items() if k in self.YOUTUBE_ALLOW_URL_PARAMS and v}
            # try to get the video id
            results = forms.YOUTUBE_VIDEO_ID_RE.findall(link)
            if results:
                link = forms.YOUTUBE_EMBED_URL.format(results[0])
            if qs:
                link = '{}?{}'.format(link, urlencode(qs, doseq=True))
        return link

    setattr(forms.VideoPlayerPluginForm, 'clean_embed_link', clean_embed_link)

and call the function form_validator_fix in the end of main urls.py.

Good luck!

Error when setting DJANGO_VIDEO_TEMPLATES: NameError: name '_' is not defined

When I add

DJANGOCMS_VIDEO_TEMPLATES = [
    ('feature', _('Featured Version')),
]

to the settings.py it throws an error:

    ('feature', _('Featured Version')),
NameError: name '_' is not defined

What am I missing here? Excuse me if it's something trivial, I just dropped back into python/django after a long time.

I am trying to get working a template with preload="none" to stop videos from preloading (it's a video gallery).

# python --version
Python 3.9.2
# pip list
Package                                     Version
------------------------------------------- --------------
aldryn-boilerplates                         0.8.0
aldryn-forms                                6.2.1
appdirs                                     1.4.4
asgiref                                     3.4.1
attrs                                       20.3.0
blinker                                     1.4
cachetools                                  5.0.0
certifi                                     2020.6.20
chardet                                     4.0.0
cloud-init                                  20.4.1
configobj                                   5.0.6
cryptography                                3.3.2
cssselect                                   1.1.0
cssselect2                                  0.4.1
cssutils                                    2.3.0
distlib                                     0.3.1
Django                                      3.2.10
django-absolute                             0.3
django-analytical                           3.0.0
django-appconf                              1.0.5
django-classy-tags                          2.0.0
django-cms                                  3.8.0
django-emailit                              0.2.4
django-filer                                2.1.2
django-formtools                            2.3
django-js-asset                             1.2.2
django-mptt                                 0.13.4
django-polymorphic                          3.0.0
django-sekizai                              2.0.0
django-sizefield                            2.0.0
django-tablib                               3.2
django-treebeard                            4.4
django-utils-six                            2.0
djangocms-admin-style                       2.0.2
djangocms-aldryn-forms-bootstrap4-templates 1.0.0.2
djangocms-attributes-field                  2.0.0
djangocms-bootstrap4                        2.0.0
djangocms-file                              3.0.0
djangocms-googlemap                         2.0.0
djangocms-icon                              2.0.0
djangocms-link                              3.0.0
djangocms-picture                           3.0.0
djangocms-style                             3.0.0
djangocms-text-ckeditor                     4.0.0
djangocms-video                             3.0.0
easy-thumbnails                             2.8
filelock                                    3.0.12
gunicorn                                    20.1.0
gyp                                         0.1
html5lib                                    1.1
httplib2                                    0.18.1
idna                                        2.10
importlib-metadata                          1.6.0
Jinja2                                      2.11.3
jsonpatch                                   1.25
jsonpointer                                 2.0
jsonschema                                  3.2.0
lxml                                        4.7.1
MarkupSafe                                  1.1.1
more-itertools                              4.2.0
oauthlib                                    3.1.0
Pillow                                      9.0.0
pip                                         21.3.1
premailer                                   3.10.0
psycopg2                                    2.8.6
pycurl                                      7.43.0.6
PyGObject                                   3.38.0
PyJWT                                       1.7.1
pyrsistent                                  0.15.5
PySimpleSOAP                                1.16.2
python-apt                                  2.2.1
python-debian                               0.1.39
python-debianbts                            3.1.0
pytz                                        2021.3
PyYAML                                      5.3.1
reportbug                                   7.10.3+deb11u1
reportlab                                   3.6.5
requests                                    2.25.1
setuptools                                  52.0.0
six                                         1.16.0
sqlparse                                    0.4.2
svglib                                      1.1.0
tablib                                      3.1.0
tinycss2                                    1.1.1
ufw                                         0.36
Unidecode                                   1.1.2
urllib3                                     1.26.5
virtualenv                                  20.4.0+ds
webencodings                                0.5.1
wheel                                       0.34.2
YURL                                        1.0.0
zipp                                        1.0.0

YouTube Video not working

Hello, I'm having issues with YouTube Embed. I already had YouTube videos embedded on my Django-CMS website, but suddenly they stop working, becoming white spaces on my pages.

When I try to manage them and update the YouTube links I see them working into the admin panel, but when I publish them they disappear.

Is this due to an update of your video plugin?

Permission does not exist for adding a video

I'm using django-cms==3.0.1 and djangocms-video==0.0.1 from PyPI. I have a non-superuser user and for testing, I have made them part of a group which has all permissions Django knows about. I then go to the Structure front-end editor whilst logged in as that user. When I try to add a Video as that logged-in user I get the message "You do not have permission to add a plugin".

I believe this is to do with plugins like video being separate applications now in 3.0. I put a pdb in cms/utils/permissions.py in the method has_plugin_permission and I can see that the user is being check to see if they have the permission djangocms_video.add_video. This permission doesn't seem to exist. The only video permission my Django knows about is video.add_video which is presumably left over from the older version of Django-CMS.

I can't find anywhere in this plugins source code that tries to create these permissions. This could also be a problem with the other plugins that were split out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.