Skip to main content

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

Project description

wagtail-webradio

Manage your web radio - e.g. podcasts, 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 (4.1 LTS, 5.0)
  • Django (3.2 LTS, 4.2 LTS)
  • Python 3 (3.8, 3.9, 3.10, 3.11)

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

Usage

Configuration

WEBRADIO_PODCAST_SOUND_FILE

Default: True

When set to False, the sound file field of a podcast is disabled and it is only possible to set the sound by its URL.

WEBRADIO_ALLOWED_AUDIO_MIME_TYPES

Default:

['audio/ogg', 'audio/mpeg', 'audio/flac', 'audio/opus']

A list of audio MIME types which are allowed when uploading a podcast's sound file.

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 and its requirements:
    (venv)$ pip install -r requirements-dev.txt
    

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

pip install --upgrade build twine

Contributing

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

  • make test: run the tests and output a quick report of code coverage
  • make test-wip: only run the tests marked as 'wip'
  • make test-all: run the tests on all supported versions of Django and Wagtail with nox

The Python code is formatted and linted thanks to flake8, isort and black. All of these tools are configured in pre-commit and you should consider to install its git hook scripts by running:

(venv)$ pre-commit install

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

License

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

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

wagtail-webradio-0.6.2.tar.gz (236.9 kB view details)

Uploaded Source

Built Distribution

wagtail_webradio-0.6.2-py3-none-any.whl (177.4 kB view details)

Uploaded Python 3

File details

Details for the file wagtail-webradio-0.6.2.tar.gz.

File metadata

  • Download URL: wagtail-webradio-0.6.2.tar.gz
  • Upload date:
  • Size: 236.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for wagtail-webradio-0.6.2.tar.gz
Algorithm Hash digest
SHA256 284f470b3bb8a17831be62837cb737e9b53d2e09150534762e806676df052f35
MD5 5e7a01b44fa251679a6516aa15f28a68
BLAKE2b-256 7d4d70d587720359136bb22884a4405e3ce8eeacfe93c3d8e9c58ab43e6c33a0

See more details on using hashes here.

File details

Details for the file wagtail_webradio-0.6.2-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_webradio-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d167adc5435fb4bcbcea83081d8b651783c7c9c663555c0c057d5e41a488424f
MD5 07b521449a405e64db19963261960371
BLAKE2b-256 d548e9ee24990fc82de10ff5e75bb51576ab3aba0b25994616a5710ea8a9089c

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