If you can wait a couple more days I should have Python scripts ready for prime time which do the following:
in export mode, scan the moOde database for user-defined radio station entries; for each one extract the db info along with the corresponding .pls file, the station logo .jpg file and its thumbnail .jpg file (if the image files exist); save all to a tarball (e.g., a tar file).
in import mode, untar the tarball to a temp directory and, for each station, first check if it clashes with a station already present in the moOde database; if not, extract the station entry to the database and the corresponding files to their proper places.
These are just utility scripts (but I suppose they could be combined into one). I'm not tackling any kind of automated player-to-player transfer or any integration with the moOde UI. The user has to run the export script, transfer the tarball, run the import script, all from the command line. Further these scripts are all or none; I'm not tackling any kind of user selection of the stations to export or import.
I starting developing these scripts for my own use but they may be useful to others to:
Deal with upgrading to a new major release of moOde
Copy stations from one player to another player whether it's running the same release or a different release
Share favorites to another user
I'll have to spend some time reading Tim's release notes to see how far back in moOde releases these scripts will work. IIRC, radio logo thumbnails were introduced mid 4.x. Don't recall if the database schema for radio stations or the location of the file directories has changed since 4.0.
Regards,
Kent
Hi Kent,
User added Radio logos were introduced in the 5.0 release and i think thats also when the type column was added to cfg_radio to help differentiate between user added and system pre-defined stations.
To list out the user added stations run the query below. Change 'u; to 's' to list out the system pre-defined stations. User added stations must start at id > 499.
Code:
sqlite3 /var/local/www/db/moode-sqlite3.db "select * from cfg_radio where type='u'"
I think when importing I'd first delete rows where type='u', then do a bulk import from a csv. This might avoid the need to check whether the stations already exist. For example:
Code:
sqlite3 /var/local/www/db/moode-sqlite3.db "DELETE FROM cfg_cfg_radio WHERE type='u'"
sqlite3 /var/local/www/db/moode-sqlite3.db -csv ".import /home/pi/cfg_radio.csv cfg_radio"
even if you addressed this to Kent in a first way - thanks for the explanation and your great support. Even with those SQL statements only, it would be much easier for me to migrate to a new image.
Regarding the import - deleting "u"-type entries first would make a script easier to implement, but then it's always a kind of "initial" import. But if you - like Kent wrote - want to share your favorites also with someone else, deleting the "u" entries first is not an option. This is nothing essential (at least for me) but would be a nice "addon".
But let's wait for Kent's script - I'm pretty sure it will do it's job perfect.
Yeah, I sussed out the schema sometime ago (for a while there was a comment in my code which said "I suppose 's' must stand for system). As it stands now, the script exports all entries tagged 'u'. I don't check the ID on export since that seemed redundant knowing your "add station" functionality. On import, your ID=499 divider as well as existing user-defines are observed en passant since my script lets sqlite3 autoincrement the ID just as yours does. I detest CSV so my script exports and imports the database entries as a JSON file. It's a verbose format but did I mention I detest CSV?
My script doesn't clear out the existing user-defined stations because in my imagined scenarios the user may have already added some stations by hand. Seemed rude to squash them
(08-11-2019, 01:06 PM)Tim Curtis Wrote: lol, CSV format can definitely be a pain.
Tim is there any chance you could alter the permissions in your next release for the folder/var/www/images/radio-logos for the Pi user so that one can manually copy images into that folder, Please. Because at the moment it simply gives permission denied massage.
Thats something I'd leave up to the user. It's not a good practice for me to expand the scope of permissions on a directory unless it solves a generally applicable issue.
(08-21-2019, 07:57 PM)Tim Curtis Wrote: Thats something I'd leave up to the user. It's not a good practice for me to expand the scope of permissions on a directory unless it solves a generally applicable issue.
I tried to change that being the user with no success. Could you direct me how I can accomplish that on my system.
pi@OutdoorSpeakers:/var/www/images $ chmod +rwx radio-logos/
chmod: changing permissions of 'radio-logos/': Operation not permitted
(08-21-2019, 07:57 PM)Tim Curtis Wrote: Thats something I'd leave up to the user. It's not a good practice for me to expand the scope of permissions on a directory unless it solves a generally applicable issue.
I tried to change that being the user with no success. Could you direct me how I can accomplish that on my system.
pi@OutdoorSpeakers:/var/www/images $ chmod +rwx radio-logos/
chmod: changing permissions of 'radio-logos/': Operation not permitted
Well you can't change the permissions on a directory owned by root unless you execute the operation as superuser.
But I'm still trying to figure out your report in the other thread. Are you working just with my scripts or also doing handwork on your own? That's likely to cause confusion.
(08-21-2019, 07:57 PM)Tim Curtis Wrote: Thats something I'd leave up to the user. It's not a good practice for me to expand the scope of permissions on a directory unless it solves a generally applicable issue.
I tried to change that being the user with no success. Could you direct me how I can accomplish that on my system.
pi@OutdoorSpeakers:/var/www/images $ chmod +rwx radio-logos/
chmod: changing permissions of 'radio-logos/': Operation not permitted
Well you can't change the permissions on a directory owned by root unless you execute the operation as superuser.
But I'm still trying to figure out your report in the other thread. Are you working just with my scripts or also doing handwork on your own? That's likely to cause confusion.
Regards,
Kent
I tried your script and since I wasn't having any luck with that I figured a manual way should still be available for me.