Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide Exporting/Importing Radio Stations
#1
Background

The Radio Manager was introduced in the moOde 6.6.0 release. Clicking on the gear icon in the Library > Radio view takes one to the Radio Manager panel. 
  • Clicking the Export button causes moOde to create a zip file of all the radio station information in the player and download it to one's local host (default filename "stations.zip"). 
  • Going in the reverse direction, clicking the Import button causes moOde to ask the user to select the file to be imported, then uploads it and replaces all the existing radio station information with the content of the file.
This functionality works fine for many users but there are some issues:
  • Because of a change in the underlying database schema for radio stations, a station file exported from moOde 6.6.0 through 6.7.1 cannot be imported into moOde 7.0.0 or 7.0.1.
  • One may wish, say, to preserve all the curated stations in a fresh player and import only the user-created stations from a previous player.
  • It's possible to create so many stations that the resulting file is larger than 50MB. The file will be exported but it can't be imported again. This is a somewhat arbitrary limitation imposed on the in-browser file-transfer method but there will always be some limit and modifying it is complicated for many users.
The upcoming moOde 7.1.0 release will include a new, improved Radio Manager functionality thanks to a superb Python script contributed by @bitlab. It solves the first issue. It solves the second issue when used stand-alone but as of 7.1.0TR2 such alternatives are not available via the Radio Manager. Future modifications to the moOde WebUI may allow more flexibility. The third issue deserves its own thread but the script solves it too when used stand-alone (within the limits of available memory, of course).

Meanwhile here's guidance on using the script stand-alone in moOde 7.0.1 and previous releases.

Procedure

1. On the destination player, log into the command line as user "pi" and download a copy of the script stationmanager.py from the github repo (I suggest you stay in the home directory /home/pi but the choice is yours)

Code:
wget https://raw.githubusercontent.com/moode-player/moode/develop/www/command/stationmanager.py

2. Mark the downloaded script as executable

Code:
chmod +x stationmanager.py

3. Take a moment to check out all the wonderful options

Code:
./stationmanager.py -h


4. As illustration, here's the dialogue I see on my moOde 7.0.1 player named moode701t for the preceding steps

Code:
pi@moode701t:~ $ wget https://raw.githubusercontent.com/moode-player/moode/develop/www/command/stationmanager.py
--2021-02-21 11:28:01--  https://raw.githubusercontent.com/moode-player/moode/develop/www/command/stationmanager.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.111.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26562 (26K) [text/plain]
Saving to: ‘stationmanager.py’

stationmanager.py           100%[===========================================>]  25.94K  --.-KB/s    in 0.009s  

2021-02-21 11:28:01 (2.77 MB/s) - ‘stationmanager.py’ saved [26562/26562]

pi@moode701t:~ $ chmod +x stationmanager.py
pi@moode701t:~ $ ./stationmanager.py -h
usage: stationmanager.py [-h] [--version]
                        (--import | --export | --clear | --compare)
                        [--scope {all,moode,other}]
                        [--type {favorite,regular,hidden,nothidden}]
                        [--how {clear,merge}] [--db DB]
                        [backupfile]

Manages import and export of moOde radiostations.

positional arguments:
 backupfile            Filename of the station backup. Required by the
                       import, export and compare.

optional arguments:
 -h, --help            show this help message and exit
 --version             show program's version number and exit
 --import              Import radio stations from backup.
 --export              Export radio stations to backup.
 --clear               Clear radio stations. This will delete the contents of
                       the SQL table, logo images and pls files of the
                       selected stations within the specified scope.
 --compare             Show difference between SQL table and station backup.
 --scope {all,moode,other}
                       Indicate to which stations the specified action
                       applies. (default: other)
 --type {favorite,regular,hidden,nothidden}
                       Indicate the type of station to export.
 --how {clear,merge}   On import, clear stations before action or merge and
                       add. (default: merge)
 --db DB               File name of the SQL database. (default:
                       /var/local/www/db/moode-sqlite3.db

Root privileges required for import or clear.
pi@moode701t:~ $

Note that scope "moode" means the curated stations and "other" means the user-created stations. The "how" option should be self-explanatory.

From this, the remaining steps should be pretty obvious.

5. Using your favorite method, transfer the desired stations.zip file (which was already downloaded to your local host from the source player) into the same directory on the destination moOde player. The file name itself isn't important.

6. Use the script to import the stations from the file into moOde, setting the "scope" and "how" options as desired. The default options should be satisfactory for many users.

Code:
sudo ./stationmanager.py --import stations.zip

As illustration, here's the dialogue I see when I import into moOde 7.0.1 a stations.zip file I had exported from a moOde 6.7.1 player. The file contains all the moOde 6.7.1 curated stations and one user-defined station, Radio BluesFlac. I chose the defaults, so only the Radio BluesFlac station is imported and it is merged with my existing user-created stations.

Code:
pi@moode701t:~ $ sudo ./stationmanager.py --import stations671+.zip
SQL database location is '/var/local/www/db/moode-sqlite3.db'
Station logos location is '/var/local/www/imagesw/radio-logos'
Station pls file location is '/var/lib/mpd/music/RADIO'
Using Station backup file 'stations671+.zip'.
WARNING: Station backup is an old format
import
WARNING: no schema information, guessing moOde 6.7.1 station backup format
WARNING: Source and target differ, correcting used types
Import Radio BluesFlac
WARNING: Missing station logo thumb for 'Radio BluesFlac', generating one
Imported 1 radio stations
Notes
  • If you don't have a stations.zip file from your source player yet, you can either use the existing Radio Manager to create and download it or you can use the above as a guide to download and use the stationmanager.py script to create it. In the latter case, you'll have to transfer the file manually since the script does not automatically download the file to your local host.
  • The new-format stations.zip file exported by the stationmanager.py script can be imported only by the script and not by the original moOde Radio Manager function. The default filename may be the same but the format and contents are different from those of the old-format stations.zip.
  • This stationmanager.py script and the stations.zip files have nothing in common with my older, now deprecated moode-radio-utils (savemystations.py and loadmystations.py) nor the associated myradios.tar.gz file. If that's the only file you have, then loadmystations.py or loadmystations7.py is still the way to reclaim the contents. Except for that, don't use these deprecated scripts and once you've reclaimed the contents, start using only the stationmanager.py script.
  • Once moOde 7.1.0 is officially released, the stationmanager.py script will be found at /var/www/command/stationmanager.py
Reply
#2
Hi Kent, hi "bitlab", THANKS!
I have tried the new RadioManager and I am happy to see that all my saved radios has been imported in 7.0.1 without any problem.
I have a question: is it normal that on the export I don't see any .PLS? In other words the exported .ZIP contains the .json file and the full radio-logos directory, but there is not the RADIO directory.
Best regards and thank you very much again,
Francesco
Reply
#3
(02-22-2021, 11:43 AM)fdealexa Wrote: Hi Kent, hi "bitlab", THANKS!
I have tried the new RadioManager and I am happy to see that all my saved radios has been imported in 7.0.1 without any problem.
I have a question: is it normal that on the export I don't see any .PLS? In other words the exported .ZIP contains the .json file and the full radio-logos directory, but there is not the RADIO directory.
Best regards and thank you very much again,
Francesco

Hi, Franesco.

Thanks for confirming the script (and my instructions!) worked.

Yes, the new-format stations.zip file does not contain playlist (.pls) files. They are necessary for mpd but they can be reconstituted from the information in the database entries exported in the .json file.

Regards,
Kent
Reply
#4
(02-22-2021, 12:37 PM)TheOldPresbyope Wrote:
(02-22-2021, 11:43 AM)fdealexa Wrote: Hi Kent, hi "bitlab", THANKS!
I have tried the new RadioManager and I am happy to see that all my saved radios has been imported in 7.0.1 without any problem.
I have a question: is it normal that on the export I don't see any .PLS? In other words the exported .ZIP contains the .json file and the full radio-logos directory, but there is not the RADIO directory.
Best regards and thank you very much again,
Francesco

Hi, Franesco.

Thanks for confirming the script (and my instructions!) worked.

Yes, the new-format stations.zip file does not contain playlist (.pls) files. They are necessary for mpd but they can be reconstituted from the information in the database entries exported in the .json file.

Regards,
Kent

Thanks again  Big Grin
Francesco
Reply
#5
I have a lot of radiostations that I listen to...
Is it somehow possible to organize your radiostations in a folder hierarchy?

Tried to append the name fiels in the stations.json file with a foldername:

"stations": [
{
...
"name": "Folder1/MyRadiostation",
... }

but it doesn't seem to work.
In moOde < 7.01 it was possible, to just copy the .pls files to a hierarchy, but how is it possible with the adioManager?

TIA

/SØren
Reply
#6
(04-05-2021, 10:47 AM)smolesen Wrote: I have a lot of radiostations that I listen to...
Is it somehow possible to organize your radiostations in a folder hierarchy?

Tried to append the name fiels in the stations.json file with a foldername:

 "stations": [
   {
...
     "name": "Folder1/MyRadiostation",
...    }    

but it doesn't seem to work.
In moOde < 7.01 it was possible, to just copy the .pls files to a hierarchy, but how is it possible with the adioManager?

TIA

/SØren

Hello Soren,
I am using the field genre and I put e.g. "01. Folder Xyz", "02. Folder Wrx", etc.  Of corse the last are real genre because you get "jazz" "Pop", "Rock" for the original moOde radio.
It could be interesting, for the next release,  the possibility to use one of the two spare fields tag: kind request to Tim.
Regards,
Francesco
Reply
#7
Hi Kent,

Thanks for the script and the clear set of instructions. By using your guide, I was able to export my radio stations from 6.7.1, and import them into 7.1.0, although I am experiencing a slight hiccup:

Although I can see that the pls files for all my radio stations have been created in /var/lib/mpd/music/RADIO, I am not able to see them in moOde's web interface. Any idea what I can do to get this fixed?

Thx for your help!
Jan
Reply
#8
(04-10-2021, 03:24 PM)janvda Wrote: Hi Kent,

Thanks for the script and the clear set of instructions. By using your guide, I was able to export my radio stations from 6.7.1, and import them into 7.1.0, although I am experiencing a slight hiccup:

Although I can see that the pls files for all my radio stations have been created in /var/lib/mpd/music/RADIO, I am not able to see them in moOde's web interface. Any idea what I can do to get this fixed?

Thx for your help!
Jan
Hello Jan,
it is my opinion that the best way to help you is to have the .zip file you have created and, then used for the import.
Best regards,
Francesco
Reply
#9
(04-10-2021, 03:24 PM)janvda Wrote: Hi Kent,

Thanks for the script and the clear set of instructions. By using your guide, I was able to export my radio stations from 6.7.1, and import them into 7.1.0, although I am experiencing a slight hiccup:

Although I can see that the pls files for all my radio stations have been created in /var/lib/mpd/music/RADIO, I am not able to see them in moOde's web interface. Any idea what I can do to get this fixed?

Thx for your help!
Jan

If not already tried, you could try to refresh your browser and or try to restart the moOde backend(moodeutl -r or just reboot) to see if something is cached.
Reply
#10
@janvda

Thanks for the compliment but let's not lose track of the fact that @bitlab wrote the script. All I did was explain how it could be used in stand-alone fashion.

I'm not sure I understand how you got the result you report. Here's hoping bitlab's suggestion clears the air. Smile

Regards,
Kent
Reply


Forum Jump: