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": case "alphabeticalByName":
q = q.Order("right_path") q = q.Order("right_path")
case "byYear": case "byYear":
q = q.Where( fromYear := params.GetOrInt("fromYear", 1800)
"tag_year BETWEEN ? AND ?", toYear := params.GetOrInt("toYear", 2200)
params.GetOrInt("fromYear", 1800), if fromYear > toYear {
params.GetOrInt("toYear", 2200)) toYear, fromYear = fromYear, toYear
}
q = q.Where("tag_year BETWEEN ? AND ?", fromYear, toYear)
q = q.Order("tag_year") q = q.Order("tag_year")
case "byGenre": case "byGenre":
genre, _ := params.Get("genre") genre, _ := params.Get("genre")

View File

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