Thank you for your donation!


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


Solved: Some songs will not remain set as clock radio
#1
I have an issue where certain tracks will not remain set as clock radio.


I set the problematic track as clock radio through the UI.
The info box pops up and says "clock radio updated"
The moode.log shows  "worker updclockradio"
If I check the clk panel immediately the setting appears to be updated properly.
Within a few minutes however or after a reboot the clock radio panel has reverted to the previous set track.

I know this would be difficult to reproduce.
What logs can I look at to try and identify the problem?
I have had a look at the id3 tags but cant see anything strange. 
I have taken a problematic track and removed id3v1 tags leaving only v2 tags but this had no effect.
I wonder has anybody else had this problem?
Does anybody have any advice on how to proceed with troubleshooting this issue?

How does the clock radio work? Is there a script or section of code I can inspect?

Thanks.
Reply
#2
Hi,

I would start by first examining the sql values which are written when you update clock radio.

Code:
sqlite3 /var/local/www/db/moode-sqlite3.db "select param, value from cfg_system where param='ckradname' or param='ckraditem'"

Then have a look at the code.

In file below search for "setforclockradio" and "clockradio-update"
/var/www/js/playerlib/js

In file below search for "getplitemfile"
/var/www/command/moode.php

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(08-13-2018, 06:25 PM)Tim Curtis Wrote: Hi,

I would start by first examining the sql values which are written when you update clock radio.

Code:
sqlite3 /var/local/www/db/moode-sqlite3.db "select param, value from cfg_system where param='ckradname' or param='ckraditem'"

Then have a look at the code.

In file below search for "setforclockradio" and "clockradio-update"
/var/www/js/playerlib/js

In file below search for "getplitemfile"
/var/www/command/moode.php

-Tim

It appears that the new clock radio setting is never written to the sql db. However the UI shows the change in the panel. When the UI is reloaded the old setting is shown in the panel which makes sense if it is the value in the db.
Reply
#4
OK, so I think this may have something to do with apostrophes in directory and filenames...

I will investigate further and get back.

Thanks.
Reply
#5
(08-13-2018, 08:28 PM)FizzyTea Wrote: OK, so I think this may have something to do with apostrophes in directory and filenames...

I will investigate further and get back.

Thanks.

I thought it might be to do with apostrophes in the file path but now I believe it is likely to be apostrophes in the id3 tags. Or perhaps both.
I will need to do some experimenting.
Reply
#6
Ya, that will cause the sql update to fail.

You can try adding the code below in playerlib.js

First find the code block that does the clock radio update

// update clock radio settings
$('.btn-clockradio-update').click(function(){

Then add .replace to the line below

Code:
'ckraditem': SESSION.json['ckraditem'].replace("'", "''"),

Don't forget to refresh Browser to reload the JS.

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#7
(08-13-2018, 08:57 PM)Tim Curtis Wrote: Ya, that will cause the sql update to fail.

You can try adding the code below in playerlib.js

First find the code block that does the clock radio update

// update clock radio settings
$('.btn-clockradio-update').click(function(){

Then add .replace to the line below

Code:
'ckraditem': SESSION.json['ckraditem'].replace("'", "''"),

Don't forget to refresh Browser to reload the JS.

-Tim

From my experimenting it appears that setting the clock radio does not write to the sql db if there is an apostrophe in either the file path or the track title tag.
Making the above change seems to account for apostrophes in the file path but not in the track title tag.
Reply
#8
The Title tag should already be handled in the code

'ckradname': SESSION.json['ckradname'].replace("'", "''"), // just in case, use escaped single quotes for sql i.e., two single quotes,
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#9
(08-14-2018, 11:04 AM)Tim Curtis Wrote: The Title tag should already be handled in the code

'ckradname': SESSION.json['ckradname'].replace("'", "''"), // just in case, use escaped single quotes for sql i.e., two single quotes,

You seem to be correct about that.
I no longer think the tag is an issue.
It looks like the filename is the issue. Though I had assumed that was the same as the file path!?

My directory structure is Artist Name -> Album Name -> tracks.

The albums causing the issue have an apostrophe in the album title. Some of the tracks also have an apostrophe in the track title.

Making the edit to the code allows tracks without apostrophes in their title but contained in album directories with apostrophes to be set as clock radio. However tracks with apostrophes in the title cannot be set as clock radio.

Seeming cause - apostrophes in the mp3 filename.
Reply
#10
@FizzyTea


I'll let Tim have the final word on the solution but here's what happened to me.

I also failed to set the clock radio when I tried to replicate your problem with a track from a Miles Davis album which is stored on my NAS with the filename

Quote:NAS/OMV-HC1/DBPowerAmp/Miles Davis/'Four' & More/02 Miles Davis - Walkin'.flac

and which in its metadata tags has the album and title (from the mediainfo utility)

Quote:Album                                    : 'Four' & More
Track name                             : Walkin'

After a sidebar exchange with Tim and some probing I discovered his fix did not handle the case of multiple occurances of single apostrophes in the filename string (the album name isn't used to set the clock radio).

I changed the two replace clauses to read

Code:
'ckraditem': SESSION.json['ckraditem'].replace(/'/g, "''"), // globally use escaped single quotes for sql i.e., two single quotes
'ckradname': SESSION.json['ckradname'].replace(/'/g, "''"), // globally use escaped single quotes for sql i.e., two single quotes


Now I can set my clock radio to this track. Here are the resulting values in the cfg_system table in moode-sqlite3.db

Code:
19|ckrad|Clock Radio
20|ckraditem|NAS/OMV-HC1/DBPowerAmp/Miles Davis/'Four' & More/02 Miles Davis - Walkin'.flac
21|ckradname|Walkin', Miles Davis
22|ckradstart|0700 AM
23|ckradstop|0800 AM
24|ckradvol|10
25|ckradshutdn|No


See if this change works for your case too.

Regards,
Kent
Reply


Forum Jump: