Package: rabe-nowplaying
Radio Bern Now PlayingThis repo contains the tool we use to grab, aggregate and publish show, artist and track metadata from various sources.The nowplaying project grabs info from RaBes playout solution and publishes them to broadcast vectors like DAB+ and Webstreams.It also takes care of generating our live ticker at songticker.rabe.ch.OverviewThe nowplaying daemon takes various sources into account:The RaBe playout solution (via thevirtual-saemuboxproject)Input fromKlangbeckenIt then make an informed decision as to what should be our leading PAD data and pushes this to it's track handlers for the following sinks:DAB+ (via theODR-EncoderManagerAPI)Webstream by pushing to ourIcecastinstancesStatically hosted XML output for browsers on songticker.rabe.chThe sources are currently individually implemented and are being replaced with genericRaBe CloudEventsbased sources. In many places the legacy system is underdocumented and this documentation documents the new system.UsageTBDRaBe CloudEventsThe nowplaying projects receives httpdRaBe CloudEventson a dedicated web service. It reacts to them depending on the event type and sourceIt supports the following event types:ch.rabe.api.events.track.v1.trackStartedch.rabe.api.events.track.v1.trackFinishedAn exampletrackStartedevent looks like this:{"specversion":"1.0","type":"ch.rabe.api.events.track.v1.trackStarted","source":"<source>","subject":null,"id":"<id>","time":"2021-12-28T19:31:00Z","datacontenttype":"application/json","data":{"item.artist":"hairmare fusion sounds collective","item.title":"C L O U D E V E N T W A V E","item.length":36000}}It can be sent to the nowplaying service using cURL as follows:curl-vvv-urabe:rabe-H'Content-Type: application/cloudevents+json'-XPOST-d'@event.json'localhost:8080/webhookIn most cases the use of a cloudevents-sdk is recommended. The following example is based on the samepython-sdknowplaying uses.importrequestsfromcloudevents.httpimportCloudEvent,to_structureddefsend_event(url,username,password):# This data defines a cloudeventattributes={"specversion":"1.0",# as defined by the events-spec repo"type":"ch.rabe.api.events.track.v1.trackStarted",# for klangbecken the github link is always used as source (as per events-spec)"source":"https://github.com/radiorabe/klangbecken",# this should be generated and could/should point to a real# URL on either https://klangbecken.service.int.example.org# using a `crid://` URL based on the upcoming crid-spec."id":"uri:demo:12345",}data={"item.title":"Track Title","item.artist":"Artist",# length in seconds, optional if you also implement sending the# not "completely specced yet" trackFinished event"item.length":60,}event=CloudEvent(attributes,data)headers,body=to_structured(event)# send and print eventrequests.post(url,headers=headers,data=body,auth=(username,password))print(f"Sent{event['id']}from{event['source']}with{event.data}")if__name__=="__main__":# local configurl="https://nowplaying.service.int.example.org/webhook"username="rabe"password="rabe"# do worksend_event(url,username,password)Contributingpre-commit hookpipinstallpre-commit
pipinstall-rrequirements-dev.txt-U
pre-commitinstalltestingpytestRelease ManagementThe CI/CD setup uses semantic commit messages following theconventional commits standard.
There is a GitHub Action in.github/workflows/semantic-release.yamlthat usesgo-semantic-committo create new
releases.The commit message should be structured as follows:<type>[optional scope]: <description>

[optional body]

[optional footer(s)]The commit contains the following structural elements, to communicate intent to the consumers of your library:fix:a commit of the typefixpatches gets released with a PATCH version bumpfeat:a commit of the typefeatgets released as a MINOR version bumpBREAKING CHANGE:a commit that has a footerBREAKING CHANGE:gets released as a MAJOR version bumptypes other thanfix:andfeat:are allowed and don't trigger a releaseIf a commit does not contain a conventional commit style message you can fix
it during the squash and merge operation on the PR.Once a commit has landed on themainbranch a release will be created and automatically published topypiusing the GitHub Action in.github/workflows/pypi.yamlwhich usestwineto publish the package to pypi. Additionaly a container image based on theRaBe Python Minimal Base Imageis built and published usingDocker build-push Action.
This is managed in.github/workflows/release.yaml.LicenseThis application is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, version 3 of the License.CopyrightCopyright (c) 2022Radio Bern RaBe