Lyrics / lyrics-api

Dynamic website for the lyrics database
GNU Affero General Public License v3.0
2 stars 0 forks source link

Return a not found if there's no results #5

Closed C0rn3j closed 5 years ago

C0rn3j commented 5 years ago

I think it'd be nice if this was implemented, currently you just get an empty page like so, which is problematic when you want to look for errors in a script/plugin.

https://lyrics.rys.pw/?title=abcd

defanor commented 5 years ago

This looks like the right thing to do when a single song's lyrics are requested, but perhaps not when a search/list is requested. We currently don't have such a separation (a short list gets served), but issue #4 mentions that it should be designed and added. Then, if a single record is requested and not found, it would be appropriate to serve a 404 error (and probably that's what will be used by plugins most of the time).

defanor commented 5 years ago

Here is a tricky thing about error pages in particular: we get a list of matches from the database, but not exact ones; it's easy when nothing at all is found, but there could be false positives with the current search implementation. A parameter can be added to check for those matches to be exact, but in some cases it would lead to failures even when the lyrics are there. Perhaps a score threshold could be used (for both listing and single song queries), but it would be tricky to calculate a sensible one on per-query basis.

defanor commented 5 years ago

Checked how lyrics.wikia.org deals with it: apparently there's a bit of preprocessing (removing anything in parens, "feat. <anything>" in artist names, etc), and then it goes for exact matches. Perhaps we should do something similar here.

defanor commented 5 years ago

Now a 404 error gets returned if the errors parameter is set (e.g., errors=on) while nothing is found. Does it fix the issue?

C0rn3j commented 5 years ago

That should do it, I like the modularity, thanks!