Extract mp3 url from page, to play on chromecast

Hi, i'm trying to find a way to play a mp3 file that is updated on a website, to a GoogleHome/Chromecast speaker.

Page: Burgernet

On the page our police posts messages about missing persons or criminal activities in the area. They have some text that is hard to translate to TTS because they use lots of short words. Under the text they post a mp3 file that they have recorded that has all the words in full length. I want to find out a way to extract the url of a new post, and play that file to a speaker. I'm thinking that NodeRed is a good solution for this project, but i have no idea how this will work.

I have NodeRed installed whit in my HomeAssistant. As i use currently some RSS feeds that are translated for TTS to a Chromecast to.

You could try this flow:

[{"id":"70d6f70e70ac2dd7","type":"inject","z":"66b78bdd15430735","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":220,"wires":[["0e1489dbc3fd4d80"]]},{"id":"e915b343def6dcf8","type":"html","z":"66b78bdd15430735","name":"","property":"payload","outproperty":"payload","tag":".c-audio-player","ret":"attr","as":"single","x":440,"y":220,"wires":[["5a4c1505b50a554a"]]},{"id":"0e1489dbc3fd4d80","type":"http request","z":"66b78bdd15430735","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.burgernet.nl/gemeente/Nederland/Roermond","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":270,"y":220,"wires":[["e915b343def6dcf8"]]},{"id":"21225da827bb5be3","type":"debug","z":"66b78bdd15430735","name":"debug 139","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":220,"wires":[]},{"id":"5a4c1505b50a554a","type":"change","z":"66b78bdd15430735","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.{\t    \"mp3\":\"https://www.burgernet.nl/sites/default/files/mp3/\"& $.id &\".mp3\"}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":220,"wires":[["21225da827bb5be3"]]}]

It outputs an array with the links to the mp3's

image

That is great, thanks @bakman2

Have to find a way that triggers the sequence soon as the id-number of the mp3 is changed, so that there is a new mp3 file to play.

For some reason i get an error when forwarding the payload[0].mp3 to Chromecast

[{"id":"f62818677fca259c","type":"tab","label":"Burgernet Roermond","disabled":false,"info":"","env":[]},{"id":"dc5203677dee3b11","type":"inject","z":"f62818677fca259c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":40,"wires":[["3555b484554f50e5"]]},{"id":"948ccb1de0965509","type":"html","z":"f62818677fca259c","name":"","property":"payload","outproperty":"payload","tag":".c-audio-player","ret":"attr","as":"single","x":120,"y":120,"wires":[["a91c22705c917df3"]]},{"id":"3555b484554f50e5","type":"http request","z":"f62818677fca259c","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.burgernet.nl/gemeente/Nederland/Roermond","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":110,"y":80,"wires":[["948ccb1de0965509"]]},{"id":"124fe43b6272b202","type":"debug","z":"f62818677fca259c","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":320,"y":180,"wires":[]},{"id":"a91c22705c917df3","type":"change","z":"f62818677fca259c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.{\t    \"mp3\":\"https://www.burgernet.nl/sites/default/files/mp3/\"& $.id &\".mp3\"}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":120,"y":160,"wires":[["a4308132a6fd171a","124fe43b6272b202"]]},{"id":"a4308132a6fd171a","type":"cast-to-client","z":"f62818677fca259c","name":"CAST RMD","url":"payload[0].mp3","contentType":"audio/mp3","message":"","language":"","ip":"10.0.5.18","port":"8009","volume":"25","x":110,"y":200,"wires":[[]]}]

ERROR

3-1-2023 18:01:21[node: CAST RMD]msg : string[62]

"Not able to load media:Load failed Not able to load the media."

Somehow the tool is not accepting the payload data, as i enter manually a mp3 url, it will play on the device.

Setting "url" to "payload[0].mp3" will not do what you expect. Leave it blank & send the URL in the message

From the readme...

Media Url, msg.url or msg.payload.url url to a media file which should be cast to the cast device. For a chromecast this could be a media or a video file. For a Google Home device without a display this could only a audio file.

Thanks, now i got it working. Have to find a way to trigger all when the id of the link is changed, so i get the last file played soon as a new one comes in.

You will have to store the URL (use flow context) & poll the URL every 30s or so & test it against the value stored in flow context

Good one, need some help with that. I've tried some options/settings, no succes yet

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.