mopidy-local icon indicating copy to clipboard operation
mopidy-local copied to clipboard

Browsing directories by type 'date' returns incorrect names when format is not YYYY-MM-DD

Open kingosticks opened this issue 5 years ago • 1 comments

As reported in https://github.com/mopidy/mopidy-mpd/issues/31, when browsing by 'Release Years' (or any local:directory query with type=date), tracks with their date tag not in the format YYYY-MM-DD are not displayed correctly.

  • Legitimate dates in format YYYY are returned with name '-470'
  • Any non-null values that cannot be converted by strftime are returned without a name

One way to fix this would be to only insert valid YYYY-MM-DD format SQLite time strings when adding tracks to the database. Then strftime can always handle the value.

kingosticks avatar May 26 '20 15:05 kingosticks

Maybe it's not necessary to rely on SQLite's parsing function and just do (if the format is %Y):

SELECT DISTINCT substr(date, 1, 4) AS date
  FROM track
 WHERE date IS NOT NULL
 ORDER BY date

One could do this with a check for %Y in https://github.com/mopidy/mopidy-local/blob/master/mopidy_local/schema.py#L233 to not break anything.

Am I correct in understanding that there are two cases to be expected, format is %Y or %Y-%m-%d (at least that's what i find in my files) and SQLite should actually work only with a full ISO date, so that's why inserting a full date when adding tracks is an option?

rgieseke avatar Feb 20 '22 11:02 rgieseke

I am running the fix proposed by @schmaller and AFAICT it works. Any plan to merge this?

orontee avatar Feb 05 '23 16:02 orontee