Skip to content

Commit

Permalink
feat(subsonic): support dsub edgecase for queries by decade
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
brian-doherty committed Sep 13, 2022
1 parent fdbb282 commit 03df207
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions server/ctrlsubsonic/handlers_by_folder.go
Expand Up @@ -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")
Expand Down
10 changes: 6 additions & 4 deletions server/ctrlsubsonic/handlers_by_tags.go
Expand Up @@ -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")
Expand Down

0 comments on commit 03df207

Please sign in to comment.