Author Topic: Export (and Import) Radio Stations  (Read 3470 times)

Darwin4Ever

  • Jr. Member
  • **
  • Posts: 83
It would be great if Export (and eventually Import) Radio Stations would also support at least also M3U (and eventually PLS) next to the OPML (XML)

The M3U #EXTM3U is straightforward and not complicated at all, and all data-elements needed are already available and used in the OPML.

Needed to be compatible with other apps/devices which mainly support M3U. M3U is the de-facto standard.

sveakul

  • Hero Member
  • *****
  • Posts: 3260
+1

darwin4ever: not directly related to the Radio Station interface, but your sig line shows you are using an old version of MusicBee;  the newest ones now support displaying track metadata for streams when added as #EXTM3U playlists in the regular "add playlist" dialog.



wiz_d_kidd

  • Newbie
  • *
  • Posts: 17
I've seen several posts asking for MusicBee to output radio stations in M3U format instead of OPML (XML). I also wanted that, so I wrote a converter in AutoHotKey (see below). It will input an OPML file (*.xml) from MusicBee and output an M3U for use in other applications. I tested it by importing the M3U file into MusicBee as a playlist and it worked as expected. You need AutoHotKey V1 to run this. It won't run under version 2 (although I hear there are converters available).

Code
; This routine will read the radio stations from an OPML (XML) file exported
; by MusicBee, and will create an M3U playlist for import to other applications.
; User is prompted for the name of the OPML file, a name for the created M3U
; file, and a name for the overall playlist (how it will be shown in the target
; application).

#SingleInstance, Force ; Only allow one running instance of script at one time

; Select the input OPML file created by MusicBee
FileSelectFile, SelectedInput, , *.xml, Select a MusicBee OPML file for input, *.xml

; Specify the output M3U file. If it exists, overwrite it
FileSelectFile, SelectedOutput, S, *.m3u, Select an M3U for output, *.m3u
FileDelete, %SelectedOutput%

; Get a name for the M3U playlist (may be different than output filename)
Gui, New, -MaximizeBox -MinimizeBox
Gui, Add, Text,, Name for Playlist:
Gui, Add, Edit, vPlayName
Gui, Add, Button, gOK, OK
Gui, Show,, Playlist Name
return
 
OK:
Gui, Submit

; Read the OPML (XML) file:
FileRead, XMLData, %SelectedInput% ; Read XML file

; Create the M3U output file:
FileAppend, #EXTM3U`r`n#PLAYLIST:%PlayName%`r`n, %SelectedOutput%

; Parse XML file for specific tag values and write them to M3U
start := 1
while (pos1 := RegExMatch(XMLData, "<outline text=\""(.+?)\""", name, start))
{
pos2 := RegExMatch(XMLData, "description=\""(.+?)\""", descr, start)
pos3 := RegExMatch(XMLData, "category=\""(.+?)\""", categ, start)
pos4 := RegExMatch(XMLData, "url=\""(.+?)\""", url, start)
        FileAppend, #EXTINF:-1`,%name1%`r`n, %SelectedOutput%
FileAppend, %url1%`r`n, %SelectedOutput%
        start := pos4 + 1
}

return
Last Edit: June 07, 2025, 02:32:34 PM by wiz_d_kidd

sveakul

  • Hero Member
  • *****
  • Posts: 3260
A nice script, but let's face it "nobody" is going to realistically do this (and check that AHK version!).  We need the originally requested "Import M3U/8 to Station List", and "Export Station List as M3U/8."  I don't know why this has not been added yet, is it some kind of PITA to code?

hiccup

  • Hero Member
  • *****
  • Posts: 9106
A nice script, but let's face it "nobody" is going to realistically do this (and check that AHK version!).
It's a nice script indeed that wiz_d_kidd created and shared with us.
And I don't think there is anything wrong with using and sharing AHK v1 scripts.
Many AHK users (like me) have been sticking with v1 because they don't see benefits in using v2, and/or can't be bothered with checking/testing/updating their existing v1 scripts for v2.

So, thank you wiz_d_kidd for creating and sharing a clever option to accomplish this.
Last Edit: June 08, 2025, 09:18:40 PM by hiccup

sveakul

  • Hero Member
  • *****
  • Posts: 3260
And I don't think there is anything wrong with using and sharing AHK v1 scripts.
Nor do I, and use a simple variety myself.  The comment was meant to point out that many (most?) MusicBee users are not at a technical level to easily substitute using even gifted AHK scripts for a missing context menu choice, like "Export Playlist" would be.

wiz_d_kidd

  • Newbie
  • *
  • Posts: 17
One thing to be aware of is that MusicBee is quite happy with streaming radio links that are, in fact, M3U or PLS playlists that contain the actual URL for the stream. In one case, I had a "stream URL" that was actually a PLS file. The PLS file contained a link to an M3U, and the M3U contained six streams. I don't know which one MusicBee picks, or how it even resolves those redirections, but somehow it does. Other applications that might be using an M3U created by my AHK script, or hand written (which I've also done) might not resolve those redirections and require the actual URL of the stream. So what I've done is to copy the stream URL in MusicBee (via edit radio station), paste it into my web browser, and if it plays, it is OK. If it downloads an M3U or PLS, you have to edit those looking for the actual stream URL.

This makes me wonder if one could take an AHK- or hand-creatded M3U file of radio stations, and "import" it into MusicBee's Radio tab with a URL like: file:///C:/MyData/MusicBeeRadios.M3U ?? If it had multiple entries in it, which one would MusicBee pick? ...sound like an experiment for a rainy day.

hiccup

  • Hero Member
  • *****
  • Posts: 9106
The comment was meant to point out that many (most?) MusicBee users are not at a technical level to easily substitute using even gifted AHK scripts for a missing context menu choice, like "Export Playlist" would be.
OK, thanks for clearing that up.
I must have misinterpreted your comment:
Quote from: sveakul
(and check that AHK version!)