mopidy / mopidy-local

Mopidy extension for playing music from your local music archive
https://mopidy.com/ext/local/
Apache License 2.0
61 stars 26 forks source link

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

Closed kingosticks closed 1 year ago

kingosticks commented 4 years ago

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.

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.

rgieseke commented 2 years ago

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?

orontee commented 1 year ago

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