Open oleole39 opened 2 weeks ago
1.Would you consider a PR for this ?
Yes. I am happy to support you, but you should be aware that it is not an easy task to implement.
I am still unsure on which basis querying the JSON file - how and where to have the user indicate the JSON path in a simple way?
Yes that is a tricky part .I don't think it's feasible to realize this for the user in a simple way without an enormous maintenance effort. When you implement a simple way for a json, than the next user wants a simple way for xml and so on. Also some users might want to combine several fields from a json. What I would do instead is, to allow the users to add a bash script which returns the title. Than you call the bash script in the code eyery 5 seconds or so. For this example, you could add a bashcript with:
curl "https://www.radiofrance.fr/fip/api/live" | jq ".now.secondLine.title"
Then I guess the parsing should happen in src/services/mpv/MpvHandler.ts.
No, I don't think this is the right place because this is not related to Mpv. But you can start adding it here and than later on we can discuss how to improve.
Should the parsing function be added as well to files/radio%40driglu4it/4.6/radio-applet.js ?
Yes, the javascript file is what is used from cinnamon. Typescript is just add an addition to js. But you can build the js file by running: npm install
and npm run build
within the radio applet directory
Should we add cover art support ({ "now": {"visuals": {"card": {"src": COVER_ART_URL} } } }) in addition as an option?
That is something you can think about later. But this is very,very complicated and I don't think it makes sense to implement at the moment.
Thanks for your feedback.
What I would do instead is, to allow the users to add a bash script which returns the title.
So one .sh file per station in a folder ? That could be an option, but thinking more about it, as a user I'd probably like better something like a 5th column in the "My Stations" DB:
{.now.firstLine.title} - {.now.secondLine.title}
(or maybe without curly braces). Or maybe even one column for each variable: title path, album path, year path, cover art path to be filled with a string of this format: .now.firstLine.title
. Then it won't be so difficult to parse the expression and replace the JSON paths with their values using curl
& jq
as you suggested.How do you feel about this way?
We could even imagine a way for users to propose their JSON file URL & JSON Path entries to the central radio file by submitting a PR (adding column to those too). However that would be a second step because format of allStations.json
may not be so convenient for easy collaborative editing.
Than you call the bash script in the code eyery 5 seconds or so.
I am under the impression that currently the title change when listening to a same station is triggered inside activateMprisPropsListener()
in MpvHandler.ts (hence why I thought about adding my functions there, but you are right it is not directly related with mpv
). But I don't get what is the actual trigger - something related to connectSignal method that I have not identified ?
Hi, sorry for not answering before. I currently don`t have much time. I would says, start coding and once we have a first working Version we can discuss how to improve
Nothing too urgent, but that would help if you were able to find time to answer the last question of my last message
I am under the impression that currently the title change when listening to a same station is triggered inside activateMprisPropsListener() in MpvHandler.ts (hence why I thought about adding my functions there, but you are right it is not directly related with mpv). But I don't get what is the actual trigger - something related to connectSignal method that I have not identified ?
Ok I have reviewed it now. In the function activateMprisPropsListener
we are passing an anonymous callback function ((proxy, nameOwner, [interfaceName, props]) => {...}
. The activateMprisPropsListener
function is only called when mpris starts or at the start of the applet. The annoymous callback function is always triggered when a title is changed in the mpv player. The mpv player knows when a title changed when a station set a new title via the mpris standard. Then the mpv player sends this signal via dbus to all listeners e.g. the applet. I am no dbus expert and I don't know exactly how it is working but for us it is only important that the method is called when a title changes in mpris metadata.
But as you want to parse metadata when no metadata are already provided, this is definitely the wrong place. As the radio title is used in multiple places of the applet (in the tooltip, in the popup menu, for the youtube download... and maybe more), I would suggest to provide it first at one place and test that it is working and than also add it to the other place. E.g you could change something in the "createRadioAppletTooltip" function and play around there and test if it is working. Once it is working you can think about how to make it available everywhere. Here you need to provide a function which fetches and parses a json every 5 seconds or so.
Applet name and maintainer
radio@driglu4it
What would you like to see?
Hello @jonath92 ,
Suffering from using audio streams in which the applet does not find title metadata (e.g: https://stream.radiofrance.fr/fip/fip_hifi.m3u8), I am looking for a way in such case to indicate a JSON metadata source to the applet for that stream so that it can parse it (e.g. https://www.radiofrance.fr/fip/api/live at
{ "now": {"firstLine": {"title": SONG_TITLE} } }
).{ "now": {"visuals": {"card": {"src": COVER_ART_URL} } } }
) in addition as an option?Best regards, oleole39