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