feat(subsonic): support dsub edgecase for queries by decade

* Found a podcast that returns 403 without a UserAgent string so I added one. URL is https://feeds.buzzsprout.com/132359.rss

* Fixed lint issues including needed error checking.

* DSub swaps fromYear and toYear so swap them back in that case. TBD -- fix the same logic in ServeGetRandomSongs
This commit is contained in:
brian-doherty
2022-09-13 08:46:33 -05:00
committed by GitHub
parent fdbb28209b
commit 03df207e63
2 changed files with 12 additions and 8 deletions

View File

@@ -115,10 +115,12 @@ func (c *Controller) ServeGetAlbumList(r *http.Request) *spec.Response {
case "alphabeticalByName":
q = q.Order("right_path")
case "byYear":
q = q.Where(
"tag_year BETWEEN ? AND ?",
params.GetOrInt("fromYear", 1800),
params.GetOrInt("toYear", 2200))
fromYear := params.GetOrInt("fromYear", 1800)
toYear := params.GetOrInt("toYear", 2200)
if fromYear > toYear {
toYear, fromYear = fromYear, toYear
}
q = q.Where("tag_year BETWEEN ? AND ?", fromYear, toYear)
q = q.Order("tag_year")
case "byGenre":
genre, _ := params.Get("genre")

View File

@@ -125,10 +125,12 @@ func (c *Controller) ServeGetAlbumListTwo(r *http.Request) *spec.Response {
case "alphabeticalByName":
q = q.Order("tag_title")
case "byYear":
q = q.Where(
"tag_year BETWEEN ? AND ?",
params.GetOrInt("fromYear", 1800),
params.GetOrInt("toYear", 2200))
fromYear := params.GetOrInt("fromYear", 1800)
toYear := params.GetOrInt("toYear", 2200)
if fromYear > toYear {
toYear, fromYear = fromYear, toYear
}
q = q.Where("tag_year BETWEEN ? AND ?", fromYear, toYear)
q = q.Order("tag_year")
case "byGenre":
genre, _ := params.Get("genre")