mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
Add category associated to each torrent
This commit is contained in:
@@ -37,7 +37,7 @@ func LoadTorrent(tor *Torrent) *Torrent {
|
||||
return tr
|
||||
}
|
||||
|
||||
func AddTorrent(spec *torrent.TorrentSpec, title, poster string, data string) (*Torrent, error) {
|
||||
func AddTorrent(spec *torrent.TorrentSpec, title, poster string, data string, category string) (*Torrent, error) {
|
||||
torr, err := NewTorrent(spec, bts)
|
||||
if err != nil {
|
||||
log.TLogln("error add torrent:", err)
|
||||
@@ -55,6 +55,17 @@ func AddTorrent(spec *torrent.TorrentSpec, title, poster string, data string) (*
|
||||
torr.Title = torr.Info().Name
|
||||
}
|
||||
}
|
||||
|
||||
// Category can be override
|
||||
torr.Category = category
|
||||
if torr.Category == "" {
|
||||
if torDB != nil {
|
||||
torr.Category = torDB.Category
|
||||
} else {
|
||||
torr.Category = "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
if torr.Poster == "" {
|
||||
torr.Poster = poster
|
||||
if torr.Poster == "" && torDB != nil {
|
||||
|
||||
@@ -22,6 +22,7 @@ func AddTorrentDB(torr *Torrent) {
|
||||
t := new(settings.TorrentDB)
|
||||
t.TorrentSpec = torr.TorrentSpec
|
||||
t.Title = torr.Title
|
||||
t.Category = torr.Category
|
||||
if torr.Data == "" {
|
||||
files := new(tsFiles)
|
||||
files.TorrServer.Files = torr.Status().FileStats
|
||||
|
||||
@@ -32,6 +32,7 @@ const (
|
||||
|
||||
type TorrentStatus struct {
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
Poster string `json:"poster"`
|
||||
Data string `json:"data,omitempty"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
|
||||
@@ -18,9 +18,10 @@ import (
|
||||
)
|
||||
|
||||
type Torrent struct {
|
||||
Title string
|
||||
Poster string
|
||||
Data string
|
||||
Title string
|
||||
Category string
|
||||
Poster string
|
||||
Data string
|
||||
*torrent.TorrentSpec
|
||||
|
||||
Stat state.TorrentStat
|
||||
@@ -284,6 +285,7 @@ func (t *Torrent) Status() *state.TorrentStatus {
|
||||
st.Stat = t.Stat
|
||||
st.StatString = t.Stat.String()
|
||||
st.Title = t.Title
|
||||
st.Category = t.Category
|
||||
st.Poster = t.Poster
|
||||
st.Data = t.Data
|
||||
st.Timestamp = t.Timestamp
|
||||
|
||||
Reference in New Issue
Block a user