fix ETag header

VLC will be happy
This commit is contained in:
nikk gitanes
2022-05-17 05:11:23 +03:00
parent d199ffc42b
commit e87a5e716e
2 changed files with 4 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package torr
import (
"encoding/hex"
"errors"
"fmt"
"log"
@@ -61,7 +62,7 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
sets.SetViewed(&sets.Viewed{t.Hash().HexString(), fileID})
resp.Header().Set("Connection", "close")
resp.Header().Set("ETag", httptoo.EncodeQuotedString(fmt.Sprintf("%s/%s", t.Hash().HexString(), file.Path())))
resp.Header().Set("ETag", httptoo.EncodeQuotedString(fmt.Sprintf("%s/%s", t.Hash().HexString(), hex.EncodeToString([]byte(file.Path())))))
// DLNA headers
resp.Header().Set("transferMode.dlna.org", "Streaming")
mime, err := mt.MimeTypeByPath(file.Path())

View File

@@ -2,6 +2,7 @@ package api
import (
"bytes"
"encoding/hex"
"fmt"
"net/http"
"net/url"
@@ -72,7 +73,7 @@ func sendM3U(c *gin.Context, name, hash string, m3u string) {
c.Header("Content-Type", "audio/x-mpegurl")
c.Header("Connection", "close")
if hash != "" {
c.Header("ETag", httptoo.EncodeQuotedString(fmt.Sprintf("%s/%s", hash, name)))
c.Header("ETag", httptoo.EncodeQuotedString(fmt.Sprintf("%s/%s", hash, hex.EncodeToString([]byte(name)))))
}
if name == "" {
name = "playlist.m3u"