Complete genre browsing for v0.2.34

This commit is contained in:
ponzischeme89
2026-08-09 08:56:42 +12:00
parent fdd9e6cab2
commit 0c623bbcc0
9 changed files with 635 additions and 9 deletions
+22 -2
View File
@@ -53,8 +53,13 @@ func (s *Server) handleGenreItems(w http.ResponseWriter, r *http.Request, sess s
}
limit := queryInt(r, "limit", genrePageSize, genrePageMax)
offset := queryOffset(r, "offset")
itemType, ok := genreItemType(r.URL.Query().Get("type"))
if !ok {
writeError(w, http.StatusBadRequest, "type must be Movie or Series")
return
}
key := cache.UserKey(sess.EmbyUserID, "genre:"+genre+":"+itoa(offset)+":"+itoa(limit))
key := cache.UserKey(sess.EmbyUserID, "genre:"+itemType+":"+genre+":"+itoa(offset)+":"+itoa(limit))
if raw, err := s.cache.Get(ctx, key); err == nil {
w.Header().Set("X-Memby-Cache", "hit")
writeRaw(w, http.StatusOK, raw)
@@ -63,7 +68,7 @@ func (s *Server) handleGenreItems(w http.ResponseWriter, r *http.Request, sess s
params := rowParams(url.Values{
"Genres": {genre},
"IncludeItemTypes": {"Movie,Series"},
"IncludeItemTypes": {itemType},
"Recursive": {"true"},
"StartIndex": {itoa(offset)},
"Limit": {itoa(limit)},
@@ -117,6 +122,21 @@ func (s *Server) handleGenreItems(w http.ResponseWriter, r *http.Request, sess s
writeRaw(w, http.StatusOK, body)
}
// genreItemType keeps the old mixed search as the default for Search, while the Movies
// and TV Series destinations can ask for a shelf that never crosses media types.
func genreItemType(value string) (string, bool) {
switch strings.ToLower(strings.TrimSpace(value)) {
case "":
return "Movie,Series", true
case "movie":
return "Movie", true
case "series":
return "Series", true
default:
return "", false
}
}
// genreTotal is what the television's scroll stops on, and it has to be right in the case
// where nobody counted.
//