Merge branch 'master' into new-torrent

This commit is contained in:
nikk gitanes
2021-09-10 04:57:33 +03:00
53 changed files with 759 additions and 122 deletions

View File

@@ -65,7 +65,7 @@ func (t *Torrent) Preload(index int, size int64) {
// mb5 -> 8/16 MB
mb5 := int64(t.Info().PieceLength)
if (mb5 < 8 * 1024 * 1024) {
if mb5 < 8*1024*1024 {
mb5 = 8 * 1024 * 1024
}

View File

@@ -8,6 +8,7 @@ import (
"net/http"
"time"
"github.com/anacrolix/dms/dlna"
"github.com/anacrolix/missinggo/httptoo"
"github.com/anacrolix/torrent"
@@ -55,11 +56,19 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
log.Println("Connect client", host, port)
}
}
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("transferMode.dlna.org", "Streaming")
if req.Header.Get("getContentFeatures.dlna.org") != "" {
resp.Header().Set("contentFeatures.dlna.org", dlna.ContentFeatures{
SupportRange: true,
SupportTimeSeek: true,
}.String())
}
http.ServeContent(resp, req, file.Path(), time.Unix(t.Timestamp, 0), reader)