Web UI: podcasts, radio, shares, bookmarks pages; admin podcast/jukebox management; per-user Subsonic permission editor
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"git.noroutes.net/NoRoutes/vibetunes/internal/database"
|
||||
)
|
||||
|
||||
func (h *Web) handlePodcasts(w http.ResponseWriter, r *http.Request) {
|
||||
channels, err := database.ListPodcastChannels(h.DB)
|
||||
if err != nil {
|
||||
http.Error(w, "internal error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
type channelView struct {
|
||||
Channel *database.PodcastChannel
|
||||
Episodes []*database.PodcastEpisode
|
||||
}
|
||||
var views []channelView
|
||||
for _, c := range channels {
|
||||
episodes, _ := database.ListPodcastEpisodes(h.DB, c.ID)
|
||||
views = append(views, channelView{Channel: c, Episodes: episodes})
|
||||
}
|
||||
h.page(w, r, "podcasts", "podcasts", "Podcasts", views)
|
||||
}
|
||||
|
||||
func (h *Web) handlePodcastDownload(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
if _, err := database.GetPodcastEpisode(h.DB, id); err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
go func() { _ = h.Podcasts.DownloadEpisode(context.Background(), id) }()
|
||||
http.Redirect(w, r, "/podcasts", http.StatusFound)
|
||||
}
|
||||
Reference in New Issue
Block a user