This project has been migrated to https://framagit.org/cliss21/wagtail-webradio
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 
Go to file
Antoine 01a35e5d5f chore: release 0.5.0 10 months ago
examples/player doc: provide an example of CSS for the player 2 years ago
tests feat(settings): possibility to store sound files in a RadioShow folder 10 months ago
wagtail_webradio feat(settings): possibility to store sound files in a RadioShow folder 10 months ago
.babelrc.json build: configure eslint and rollup.js to bundle scripts 2 years ago
.browserslistrc build: configure eslint and rollup.js to bundle scripts 2 years ago
.editorconfig build: configure eslint and rollup.js to bundle scripts 2 years ago
.eslintignore style: fix the ignore rules for eslint 2 years ago
.eslintrc.json build: configure eslint and rollup.js to bundle scripts 2 years ago
.gitattributes feat(components): add a player component with django-unicorn 2 years ago
.gitignore build: configure eslint and rollup.js to bundle scripts 2 years ago
.prettierrc build: configure eslint and rollup.js to bundle scripts 2 years ago
CHANGELOG.md chore: release 0.5.0 10 months ago
LICENSE feat(build): create a void pip package 2 years ago
MANIFEST.in ref: rename wagtailwebradio to wagtail_webradio 2 years ago
Makefile build: update Makefile rules for build and upload 2 years ago
README.md doc(readme): notes about settings 1 year ago
package-lock.json feat(components): add a player component with django-unicorn 2 years ago
package.json build(js): add a watch rule for rollup 2 years ago
pyproject.toml build: remove setup.py and deprecated setuptools-scm usage 2 years ago
rollup.config.js feat: replace server side validation of sound_url by client side 2 years ago
setup.cfg feat(models): add a sound_file field to upload an audio file 1 year ago
setup.py fix(build): restore setup.py, needed for developpement mode 2 years ago

README.md

wagtail-webradio

Manage your web radio - e.g. podcats, programs - in Wagtail.

Warning! This project is still early on in its development lifecycle. It is possible for breaking changes to occur between versions until reaching a stable 1.0. Feedback and pull requests are welcome.

Requirements

This package requires the following:

  • Wagtail (2.15 LTS)
  • Django (3.1, 3.2)
  • Python 3 (3.7, 3.8, 3.9)

Installation

  1. Install using pip:
    pip install wagtail-webradio
    
  2. Add wagtail_webradio to your INSTALLED_APPS setting:
    INSTALLED_APPS = [
        # ...
        'wagtail_webradio',
        # ...
    ]
    
  3. Run python manage.py migrate to create the models

Configuration

If you want, you can disable the possibility to upload a sound file or restrict to a custom authorized MIME types in your setting file:

# settings.py

WEBRADIO_SOUND_FILE = False  # default to True
WEBRADIO_AUTHORIZED_MIME_TYPES = ['audio/mpeg', 'audio/flac']

default authorized MIME types are audio/ogg, audio/mpeg, audio/flac, and audio/opus.

Usage

Frontend components

A player with a playlist management is provided to be easily included into your frontend. Under the hood, it uses django-unicorn with a bit of JavaScript to manipulate the audio from the Web browser. It is currently unstyled but you can find an example when using Bootstrap. You should also have a look to the template of this component to know how to extend it.

To make use of it:

  1. Install the player extra of this package:
    pip install wagtail-webradio[player]
    
  2. Integrate Unicorn in your project by following the documentation
  3. Configure Unicorn settings to look for this package's components:
    UNICORN = {
        'APPS': ['wagtail_webradio'],
    }
    

Then, e.g. in base.html, load the player scripts in the <head> of your document and the component in the <body>:

<html>
  <head>
    <!-- […] -->

    <script src="{% static "wagtail_webradio/player/js/main.js" %}" defer></script>
  </head>
  <body>
    <! -- […] -->

    {% unicorn "player" %}

    <! -- […] -->
  </body>
</html>

In the case of multi-process production environment, you must switch to redis, memcache or database caching to make Unicorn working correctly. For example with memcache listening through unix socket, you can add in settings.py :

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
        'LOCATION': 'unix:/var/run/memcached/memcached.sock',
    }
}

When the player scripts are loaded, you can simply add a song to the playlist by defining a data-player-add-podcast or data-player-add attribute on an element, and optionally data-player-autoplay to play the song once added:

<button data-player-add-podcast="10" data-player-autoplay>Add a podcast by id</button>

<button data-player-add="{'title': 'Title', 'subtitle': 'Subtitle', 'url': 'http://example.org/song.ogg', 'thumbnail_url': 'http://example.org/thumb.png'}">
  Add a song
</button>

Development

Quick start

To set up a development environment, ensure that Python 3 is installed on your system. Then:

  1. Clone this repository
  2. Create a virtual environment and activate it:
    python3 -m venv venv
    source venv/bin/activate
    
  3. Install this package in develop mode with extra requirements:
    pip install -e .[test]
    

If you plan to upload the package on PyPi, you will also need to run:

pip install --upgrade build twine

Contributing

The Python code is formatted and linted thanks to flake8, isort and black. To ease the use of this tools, the following commands are available:

  • make lint: check the Python code syntax and imports order
  • make format: fix the Python code syntax and imports order

The tests are written with pytest and code coverage is measured with coverage. You can use the following commands for that:

  • make test: run the tests and output a quick report of code coverage
  • make coverage: run the tests and produce an HTML report of code coverage

When submitting a pull-request, please ensure that the code is well formatted and covered, and that all the other tests pass.

License

This extension is mainly developed by Cliss XXI and licensed under the AGPLv3+. Any contribution is welcome!