9b7784634b
* Spike: Ping YP service with instance details * WIP: Add to the config to support YP * Add YP response endpoint * Handle YP errors. Use config. Off by default * Show message about YP support on launch * Add animated gif preview when generating thumb * Increase quality of preview gif and only create it if YP is enabled * Do not allow re-registration by clearing the key * Make large and small logos actually structured * Change log level * Fix default YP service URL * Point to default hostname * Set default value for YP to false
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
package yp
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/gabek/owncast/config"
|
|
"github.com/gabek/owncast/utils"
|
|
)
|
|
|
|
type ypDetailsResponse struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Logo string `json:"logo"`
|
|
NSFW bool `json:"nsfw"`
|
|
Tags []string `json:"tags"`
|
|
Online bool `json:"online"`
|
|
ViewerCount int `json:"viewerCount"`
|
|
OverallMaxViewerCount int `json:"overallMaxViewerCount"`
|
|
SessionMaxViewerCount int `json:"sessionMaxViewerCount"`
|
|
|
|
LastConnectTime utils.NullTime `json:"lastConnectTime"`
|
|
}
|
|
|
|
//GetYPResponse gets the status of the server for YP purposes
|
|
func GetYPResponse(w http.ResponseWriter, r *http.Request) {
|
|
status := getStatus()
|
|
|
|
response := ypDetailsResponse{
|
|
Name: config.Config.InstanceDetails.Name,
|
|
Description: config.Config.InstanceDetails.Summary,
|
|
Logo: config.Config.InstanceDetails.Logo.Large,
|
|
NSFW: config.Config.InstanceDetails.NSFW,
|
|
Tags: config.Config.InstanceDetails.Tags,
|
|
Online: status.Online,
|
|
ViewerCount: status.ViewerCount,
|
|
OverallMaxViewerCount: status.OverallMaxViewerCount,
|
|
SessionMaxViewerCount: status.SessionMaxViewerCount,
|
|
LastConnectTime: status.LastConnectTime,
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
json.NewEncoder(w).Encode(response)
|
|
|
|
}
|