Thank you for your donation!


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


Solved: How to import radio stations
#3
ETA: To add to what Kent mentioned.

M3U files are only used for playlists and are stored in /var/lib/mpd/playlists. You could use system Backup to export just the Playlists, modify the backup zip to contain your playlists, re-zip the file and then do a Restore.

If you want to do bulk import of radio stations into the Radio feature then read below.

1. SQL table cfg_radio in /var/local/www/db/moode-sqlite3.db

This table contains metadata for each station and is referenced by the station URL which is what MPD loads into the Queue from a station .pls file.

Code:
moodeutl -q "select * from cfg_radio"

2. Station .pls files in /var/lib/mpd/music/RADIO/

These files are what MPD indexes into its database and what MPD reads to load a station URL into the Queue. These files are generated from the cfg_radio table during the image build process using the station_manager.py utility

Code:
pi@moode:~ $ cat /var/lib/mpd/music/RADIO/FluxFM.pls 
[playlist]
File1=https://fluxmusic.api.radiosphere.io/channels/FluxFM/stream.aac?quality=4
Title1=FluxFM
Length1=-1
NumberOfEntries=1
Version=2

3. Station cover logos in /var/local/www/imagesw/radio-logos/ and radio-logos/thumbs/

Code:
radio-logos/stationName.jpg             Full sized logo displayed in Playback view
radio-logos/thumbs/statioName.jpg       Thumbnail (200px) displayed in Radio view
radio-logos/thumbs/stationName_sm.jpg   Small thumbnail (80px) displayed in the Queue and Playbar

4. Station manager utility
https://github.com/moode-player/moode/bl...manager.py

Code:
pi@moode:~ $ /var/www/util/station_manager.py -h
usage: station_manager.py [-h] [--version] (--import | --export | --clear | --compare | --diff DIFF | --regeneratepls) [--scope {all,moode,other}]
                         [--type {favorite,regular,hidden,nothidden}] [--how {clear,merge}] [--db DB] [--logopath LOGOPATH]
                         [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.
 --diff DIFF           Create a diff backup with the difference between the old (=backup) and new (=db) to this files.
 --regeneratepls       Regenerate the radio .pls files from db.
 --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
 --logopath LOGOPATH   Location of the radio logos. (default: /var/local/www/imagesw/radio-logo

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

The station manager utility can be used to bulk import stations into the Radio feature by the following process:

- Export the already bundled stations
- Unzip the export file
- Modify radio-logos/ and station_data.json to only include the stations to be imported
- Re-zip 
- Import the zip which will add the stations to cfg_radio starting at id=500, add the radio logos and create the .pls files.
sudo /var/www/util/station_manager.py --scope other --import ./tim.zip

Code:
pi@moode:~ $ /var/www/util/station_manager.py --scope all --export ./tim.zip
SQL database location is '/var/local/www/db/moode-sqlite3.db'
Station logos location is '/var/local/www/imagesw/radio-logos'
Export station data
Export station logos

pi@moode:~ $ ls
devutl.sh  piano.sh  tim.zip

pi@moode:~ $ unzip -q tim.zip

pi@moode:~ $ ls
devutl.sh  piano.sh  radio-logos  station_data.json  tim.zip
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Messages In This Thread
How to import radio stations - by haeckse - 06-11-2023, 09:13 AM
RE: Import radio stations - by TheOldPresbyope - 06-11-2023, 12:24 PM
RE: Import radio stations - by Tim Curtis - 06-11-2023, 01:18 PM
RE: Import radio stations - by haeckse - 06-11-2023, 04:20 PM

Forum Jump: