Package: wagtail-webradio
wagtail-webradioManage 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.RequirementsThis 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)InstallationInstall usingpip:pipinstallwagtail-webradioAddwagtail_webradioto yourINSTALLED_APPSsetting:INSTALLED_APPS=[# ...'wagtail_webradio',# ...]Runpython manage.py migrateto create the modelsUsageConfigurationWEBRADIO_PODCAST_SOUND_FILEDefault:TrueWhen set toFalse, 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_TYPESDefault:['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 componentsA player with a playlist management is provided to be easily included into your
frontend. Under the hood, it usesdjango-unicornwith a bit of JavaScript to
manipulate the audio from the Web browser. It is currently unstyled but you can
find anexamplewhen using Bootstrap. You should also have a look to thetemplateof this component to know how to extend it.To make use of it:Install theplayerextra of this package:pipinstallwagtail-webradio[player]IntegrateUnicornin your project byfollowing the documentationConfigureUnicornsettings to look for this package's components:UNICORN={'APPS':['wagtail_webradio'],}Then, e.g. inbase.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 adata-player-add-podcastordata-player-addattribute on an
element, and optionallydata-player-autoplayto play the song once added:<buttondata-player-add-podcast="10"data-player-autoplay>Add a podcast by id</button><buttondata-player-add="{'title': 'Title', 'subtitle': 'Subtitle', 'url': 'http://example.org/song.ogg', 'thumbnail_url': 'http://example.org/thumb.png'}">Add a song</button>DevelopmentQuick startTo set up a development environment, ensure that Python 3 is installed on your
system. Then:Clone this repositoryCreate a virtual environment and activate it:python3-mvenvvenvsourcevenv/bin/activateInstall this package and its requirements:(venv)$pipinstall-rrequirements-dev.txtIf you plan to upload the package on PyPi, you will also need to run:pipinstall--upgradebuildtwineContributingThe tests are written withpytestand code coverage is measured withcoverage.
You can use the following commands while developing:make test: run the tests and output a quick report of code coveragemake test-wip: only run the tests marked as 'wip'make test-all: run the tests on all supported versions of Django and
Wagtail withnoxThe Python code is formatted and linted thanks toflake8,isortandblack.
All of these tools are configured inpre-commitand you should consider to
install its git hook scripts by running:(venv)$pre-commitinstallWhen submitting a pull-request, please ensure that the code is well formatted
and covered, and that all the tests pass.LicenseThis extension is mainly developed byCliss XXIand
licensed under theAGPLv3+. Any contribution is welcome!