mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
change wait info torrent
This commit is contained in:
@@ -2,15 +2,20 @@ package torr
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/anacrolix/missinggo/httptoo"
|
||||
sets "server/settings"
|
||||
)
|
||||
|
||||
func (t *Torrent) Stream(fileIndex int, req *http.Request, resp http.ResponseWriter) error {
|
||||
t.WaitInfo()
|
||||
if !t.GotInfo() {
|
||||
http.NotFound(resp, req)
|
||||
return errors.New("torrent don't get info")
|
||||
}
|
||||
files := t.Files()
|
||||
if fileIndex < 1 || fileIndex > len(files) {
|
||||
return errors.New("file index out of range")
|
||||
@@ -22,9 +27,8 @@ func (t *Torrent) Stream(fileIndex int, req *http.Request, resp http.ResponseWri
|
||||
|
||||
sets.SetViewed(&sets.Viewed{t.Hash().HexString(), fileIndex})
|
||||
|
||||
//TODO проверить почему плеер постоянно переподключается
|
||||
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(), file.Path())))
|
||||
|
||||
http.ServeContent(resp, req, file.Path(), time.Unix(t.Timestamp, 0), reader)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user