mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
add bitrate to torr status
This commit is contained in:
@@ -3,6 +3,8 @@ package torr
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"server/ffprobe"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -63,8 +65,16 @@ func (t *Torrent) Preload(index int, size int64) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if ffprobe.Exists() {
|
||||||
|
host := "http://127.0.0.1:" + settings.Port + "/stream?link=" + t.Hash().HexString() + "&index=" + strconv.Itoa(index) + "&play"
|
||||||
|
if data, err := ffprobe.ProbeUrl(host); err == nil {
|
||||||
|
t.BitRate = data.Format.BitRate
|
||||||
|
t.DurationSeconds = data.Format.DurationSeconds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// startend -> 8/16 MB
|
// startend -> 8/16 MB
|
||||||
startend := int64(t.Info().PieceLength)
|
startend := t.Info().PieceLength
|
||||||
if startend < 8*1024*1024 {
|
if startend < 8*1024*1024 {
|
||||||
startend = 8 * 1024 * 1024
|
startend = 8 * 1024 * 1024
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ type TorrentStatus struct {
|
|||||||
ChunksReadWasted int64 `json:"chunks_read_wasted,omitempty"`
|
ChunksReadWasted int64 `json:"chunks_read_wasted,omitempty"`
|
||||||
PiecesDirtiedGood int64 `json:"pieces_dirtied_good,omitempty"`
|
PiecesDirtiedGood int64 `json:"pieces_dirtied_good,omitempty"`
|
||||||
PiecesDirtiedBad int64 `json:"pieces_dirtied_bad,omitempty"`
|
PiecesDirtiedBad int64 `json:"pieces_dirtied_bad,omitempty"`
|
||||||
|
DurationSeconds float64 `json:"duration_seconds,omitempty"`
|
||||||
|
BitRate string `json:"bit_rate,omitempty"`
|
||||||
|
|
||||||
FileStats []*TorrentFileStat `json:"file_stats,omitempty"`
|
FileStats []*TorrentFileStat `json:"file_stats,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ type Torrent struct {
|
|||||||
PreloadSize int64
|
PreloadSize int64
|
||||||
PreloadedBytes int64
|
PreloadedBytes int64
|
||||||
|
|
||||||
|
DurationSeconds float64
|
||||||
|
BitRate string
|
||||||
|
|
||||||
expiredTime time.Time
|
expiredTime time.Time
|
||||||
|
|
||||||
closed <-chan struct{}
|
closed <-chan struct{}
|
||||||
@@ -277,6 +280,8 @@ func (t *Torrent) Status() *state.TorrentStatus {
|
|||||||
st.Data = t.Data
|
st.Data = t.Data
|
||||||
st.Timestamp = t.Timestamp
|
st.Timestamp = t.Timestamp
|
||||||
st.TorrentSize = t.Size
|
st.TorrentSize = t.Size
|
||||||
|
st.BitRate = t.BitRate
|
||||||
|
st.DurationSeconds = t.DurationSeconds
|
||||||
|
|
||||||
if t.TorrentSpec != nil {
|
if t.TorrentSpec != nil {
|
||||||
st.Hash = t.TorrentSpec.InfoHash.HexString()
|
st.Hash = t.TorrentSpec.InfoHash.HexString()
|
||||||
|
|||||||
Reference in New Issue
Block a user