Moode Forum
[PROBLEM] Radio information does not display appropriately - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [PROBLEM] Radio information does not display appropriately (/showthread.php?tid=6265)

Pages: 1 2


Radio information does not display appropriately - stevenoh0908 - 02-26-2024

Good day everyone in the community,

I'm having my best days with the moOde audio system but recently I've found that for some internet radio addresses in South Korea, seems like the information about the radio does not display on the webpage appropriately.

The list of URLs of trouble-marking internet radios is the following: Most of you may doubt the validity of the addresses listed above firstly, but I've double-checked every URL is working, those are accessible directly from the web browser(tested with Chrome).

Explaining the problem in detail, it seems like if I try to add and play those internet radio streams, while mpd plays the stream correctly, the webpage does not update the information itself. The title and the station information are stuck with what I've played just right before adding that troublemaker, and also the station entry was not added to the queue. The only way to get the queue and the information about the station displayed correctly is by adding another element after this tricky radio stream.

I've inspected what's going on the web UI with the developer tool of the Chrome browser, then found that there's an unhandled exception on playerlib.js, which seems like the code tries to access the non-existing MPD.json['file']['format'] field. Not sure but in my opinion, it might be related to the characteristics of the stream pls files listed above, which all try to broker continuously changing streaming URLs due to the ever-changing security keys of the radio station.

There might be more works to inspect, but I think this is a simple problem that can handled by adding an exception handler in the failing section of the playerlib.js.

I've attached screenshots and console error logs from the developer tool below, feel free to ask me for more details regarding this problem.

Best regards,
Stephen

Console Log
Code:
Uncaught TypeError: Cannot read properties of undefined (reading 'format')
   at Object.success (playerlib.js:1044:75)
   at u (jquery-1.8.2.js:974:30)
   at Object.fireWith [as resolveWith] (jquery-1.8.2.js:1082:7)
   at N (jquery-1.8.2.js:7788:14)
   at XMLHttpRequest.n (jquery-1.8.2.js:8500:8)

Screenshots

1. Everyting clean and okay.
[Image: WH6hJD0.png]

2. When I try to add (or play) the tricky one...
[Image: uJM7ADF.png]

3. The page is not displaying information of the radio stream correctly. (lookng same with the first screenshot, but the audio is playing!)
[Image: YwiiS1F.png]

4. Only way to display the information correctly is adding another element just right after...
[Image: rXMqx0g.png]

5. Then as you can see the information of the failing element is showing up on the queue.
[Image: ezJrIOP.png]


RE: Radio information does not display appropriately - Tim Curtis - 02-26-2024

Couple things:

The links you provided are to playlist files and not the "Playable URL" thats required when creating or editing a Radio Station.

Here's the contents of the first .pls file. You can use your Browser to "Download linked file" or something similar.

Code:
[playlist]
File1=https://1fm.gscdn.kbs.co.kr/1fm_192_2.m3u8?Expires=1709126294&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly8xZm0uZ3NjZG4ua2JzLmNvLmtyLzFmbV8xOTJfMi5tM3U4IiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNzA5MTI2Mjk0fX19XX0_&Signature=Mck3OtdC8Kp8zwPs7XSot-jfxr9aGjfNzBcgvgTzGP36KxtcBQVcFdpGVmAmOA8R2Pnavhr1ChBL8zkmqA011ZhEI1bE0LG1rDmUw9-OcLGcGy7deDBPismF4kFcipfsw30acERAGjhtqahnfiQVwKwJasioL8~Lqv7tEpADoFd7I0~b54oV~hOwiJK6rjsdZg8t6wrjD1pJb-QV~Fx5sOBDhOB1dhfolJIf6PHXWLrJ7ja1nkXNdcCfSb8XpTP1OWLf2ERa1j4juCqRaOItbxTgAzLtNorAZHwJ7bEnLvyTQLi2Y3OqzhJr2ZlAXo-oTQX62uN-iuWeokbkAR17xQ__&Key-Pair-Id=APKAICDSGT3Y7IXGJ3TA
Title1=KBS Classic FM
Length1=-1

NumberOfEntries=1

File1= is the playable url which in this case is:

Code:
https://1fm.gscdn.kbs.co.kr/1fm_192_2.m3u8?Expires=1709126294&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly8xZm0uZ3NjZG4ua2JzLmNvLmtyLzFmbV8xOTJfMi5tM3U4IiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNzA5MTI2Mjk0fX19XX0_&Signature=Mck3OtdC8Kp8zwPs7XSot-jfxr9aGjfNzBcgvgTzGP36KxtcBQVcFdpGVmAmOA8R2Pnavhr1ChBL8zkmqA011ZhEI1bE0LG1rDmUw9-OcLGcGy7deDBPismF4kFcipfsw30acERAGjhtqahnfiQVwKwJasioL8~Lqv7tEpADoFd7I0~b54oV~hOwiJK6rjsdZg8t6wrjD1pJb-QV~Fx5sOBDhOB1dhfolJIf6PHXWLrJ7ja1nkXNdcCfSb8XpTP1OWLf2ERa1j4juCqRaOItbxTgAzLtNorAZHwJ7bEnLvyTQLi2Y3OqzhJr2ZlAXo-oTQX62uN-iuWeokbkAR17xQ__&Key-Pair-Id=APKAICDSGT3Y7IXGJ3TA

This URL is 634 characters but the input field for "Playable URL" in moOde is coded for max 200 characters which will prevent the entire URL from being entered thus it won't work.

Code:
pi@moode:~ $ echo "https://1fm.gscdn.kbs.co.kr/1fm_192_2.m3u8?Expires=1709126294&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly8xZm0uZ3NjZG4ua2JzLmNvLmtyLzFmbV8xOTJfMi5tM3U4IiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNzA5MTI2Mjk0fX19XX0_&Signature=Mck3OtdC8Kp8zwPs7XSot-jfxr9aGjfNzBcgvgTzGP36KxtcBQVcFdpGVmAmOA8R2Pnavhr1ChBL8zkmqA011ZhEI1bE0LG1rDmUw9-OcLGcGy7deDBPismF4kFcipfsw30acERAGjhtqahnfiQVwKwJasioL8~Lqv7tEpADoFd7I0~b54oV~hOwiJK6rjsdZg8t6wrjD1pJb-QV~Fx5sOBDhOB1dhfolJIf6PHXWLrJ7ja1nkXNdcCfSb8XpTP1OWLf2ERa1j4juCqRaOItbxTgAzLtNorAZHwJ7bEnLvyTQLi2Y3OqzhJr2ZlAXo-oTQX62uN-iuWeokbkAR17xQ__&Key-Pair-Id=APKAICDSGT3Y7IXGJ3TA" | wc -c
634

If you want to patch in a longer length to be able to test the URL then do the following;

1. Edit file /var/www/templates/indextpl.html
2. Update maxlength="200"  to "1000" for the lines 

<input id="new-station-url" and 
<input id="edit-station-url"

If this works I'll add to the TODO list to update those max lengths.


RE: Radio information does not display appropriately - stevenoh0908 - 02-26-2024

Ooh... It's sad to hear that I can't use those playlist files for the moOde audio system.

Modifying maxlength attributes of inputs definitely works well for the actual stream URL. although the actual filename was /var/www/templates/indextpl.min.html. (minified one)

However, if I remember correctly this displaying issue did not occur in the previous moOde audio version 8.3.7 even though .pls files are not supported for the internet radio feature as you've addressed. At that version when I tried to play that tricky station the webpage displayed the specified radio station name and 'Unknown station', without any issues that I currently have.

I can't still give up the stream even coming from the .pls file, because as I mentioned the file1 (actual stream URL) is not a fixed URL, it changes periodically to handle those horribly long queries, 'expires', 'Key-Pair-Id', ... etc.

It would be nice to have an official support for the .pls file for internet radio stations. Or just simply, could you revert front-end scripts that manage information fetching and displaying back to the ones in v8.3.7?

Best Regards,
Stephen


RE: Radio information does not display appropriately - Tim Curtis - 02-26-2024

Nothing in > 8.3.7 changed with respect to pls files so I don't what you mean by "revert"


RE: Radio information does not display appropriately - stevenoh0908 - 02-26-2024

I didn't mean changes with respect to .pls files, but changes in the frontend(especially, javascripts that displays the information about the radio station). Aren't really there any changes in playerlib.js between the current version and v8.3.7? I thought that there were some changes in the playerlib.js file (especially on line 1044) based on the console log that I've presented above.

Well, if so it will be very odd.

Anyways, even if there's nothing can be 'reverted', why don't we just add some support for those playlists-based internet radio stations for the continuously changing stream URLs at least?

Best Regards,
Stephen


RE: Radio information does not display appropriately - philrandal - 02-26-2024

+1 for some form of .pls file parsing. But... Aren't playlists mpd-related? If so, I can't see how this can be easily done.

Oh well, it looked a good idea. Still possibly worthwhile having the ability to enter a playlist url for radio stations and set up accordingly. Would need an extra field for pls url, decoding into the stream url when station is saved. Or something.

Haven't the time to play with this one myself, alas, so no pressure.


RE: Radio information does not display appropriately - Tim Curtis - 02-26-2024

These station dot pls files usually contain a bunch of playable URL's, typically different servers for the same station and often the broadcaster changes the links. They are incompatible with moOde's Radio feature which is designed for curating a set of stations with rich metadata, high quality covers and persistent playable URL's.


RE: Radio information does not display appropriately - TheOldPresbyope - 02-26-2024

Folks, MPD does parse .pls files. If you look at the way moOde saves radio stations, it is indeed in .pls files. However, the FILE1= parameter in each .pls file has to be a playable URL for the .pls file to be parsed and played by MPD.

The problem here is that these Korean stations' .pls files don't specify a playable URL. As can be seen in the posts above, they specify a .m3u file once all the extra niff-naff about expiry, policy, key-pair, etc., is dealt with.

I just dug deeper on the first KBS entry provided by the OP and I ended up with an extended M3U file containing


Code:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:25056273
#EXTINF:4.011,
1fm_192_2_25056273.aac?m=1657519452
#EXTINF:3.989,
1fm_192_2_25056274.aac?m=1657519452
#EXTINF:4.011,
1fm_192_2_25056275.aac?m=1657519452
#EXTINF:3.989,
1fm_192_2_25056276.aac?m=1657519452
#EXTINF:4.011,
1fm_192_2_25056277.aac?m=1657519452

I recognize this markup. It represents an HTTP Live Stream (HLS). The protocol and format was developed by Apple and submitted to the IETF as a draft specification 15 odd years ago. You can google the topic.

I can't find any mention of HLS in the MPD docs but it does have a plugin "extm3u" which the docs say "reads extended ,m3u playlist files".  I know nothing about this plugin but it's included in moOde's MPD build. You may want to experiment with it directly.

Just so you know, I have no experience creating or using HLS-specified streams.

Regards,
Kent


RE: Radio information does not display appropriately - Tim Curtis - 02-26-2024

Right, MPD only loads playable URL's into the Queue and moOde's Radio feature uses the playable URL as a key for retrieving the cover, metadata etc from the radio database. Specifying a pls file as the playable URL in the station form breaks all this.


RE: Radio information does not display appropriately - stevenoh0908 - 02-27-2024

Okay, just understood the philosophy regarding the moOde audio radio stations. Agreeing with you that officially allowing the pls file as the playable URL in the station will end up as the break of the orientation therefore no further plan to make a support regarding the playlist file.

But at least, even though the provided playable URLs are not compatible with retrieving the cover and other metadata as designed in the system, can't we just add an exception handler if we cannot load up the metadata from the provided stream URL for managing this?

In my opinion, just adding the try-catch clause around the MPD json load part in the playerlib.js line 1044 would likely be the solution to this issue, as below:
Code:
if (MPD.json['artist'] == 'Radio station') {
               try {
                     var format = typeof(RADIO.json[MPD.json['file']]['format']) == 'undefined' ?
                           'Variable bps' : RADIO.json[MPD.json['file']]['format'];
                } catch (exception_if_we_cant_load_up_json_metadata_or_its_undefined) {
                     var format = 'Variable bps'
                }
                    var bitRate = MPD.json['bitrate'] ? format + ' ' + MPD.json['bitrate'] : format;
                       $('#extra-tags-display').text(bitRate + ' • ' + MPD.json['output']);
                    $('#countdown-sample-rate, #songsand-sample-rate, #ss-extra-metadata').text(bitRate);
} else { // ...


This might be not very accurate or even close to the problem since I do not really know about how things work in the system, but I'm pretty sure that this would be enough to present the basic idea.