mirror of
https://github.com/owncast/owncast.git
synced 2024-11-21 20:28:15 +03:00
Add support for loading the owncast URL in mpv (#1356)
* redirect players to hls link * add VLC to players list
This commit is contained in:
parent
7278ce8f26
commit
e8e21ca45b
2 changed files with 26 additions and 0 deletions
|
@ -44,6 +44,11 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if utils.IsUserAgentAPlayer(r.UserAgent()) && isIndexRequest {
|
||||||
|
http.Redirect(w, r, "/hls/stream.m3u8", http.StatusTemporaryRedirect)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// If the ETags match then return a StatusNotModified
|
// If the ETags match then return a StatusNotModified
|
||||||
if responseCode := middleware.ProcessEtags(w, r); responseCode != 0 {
|
if responseCode := middleware.ProcessEtags(w, r); responseCode != 0 {
|
||||||
w.WriteHeader(responseCode)
|
w.WriteHeader(responseCode)
|
||||||
|
|
|
@ -86,6 +86,27 @@ func IsUserAgentABot(userAgent string) bool {
|
||||||
return ua.Bot()
|
return ua.Bot()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsUserAgentAPlayer returns if a web client user-agent is seen as a media player.
|
||||||
|
func IsUserAgentAPlayer(userAgent string) bool {
|
||||||
|
if userAgent == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
playerStrings := []string{
|
||||||
|
"mpv",
|
||||||
|
"player",
|
||||||
|
"vlc",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, playerString := range playerStrings {
|
||||||
|
if strings.Contains(strings.ToLower(userAgent), playerString) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func RenderSimpleMarkdown(raw string) string {
|
func RenderSimpleMarkdown(raw string) string {
|
||||||
markdown := goldmark.New(
|
markdown := goldmark.New(
|
||||||
goldmark.WithRendererOptions(
|
goldmark.WithRendererOptions(
|
||||||
|
|
Loading…
Reference in a new issue