43 lines
995 B
Go
43 lines
995 B
Go
package models
|
|
|
|
import (
|
|
"github.com/odwrtw/papi"
|
|
polochon "github.com/odwrtw/polochon/lib"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// TorrentVideo reprensents a torrent embeding the video inforamtions
|
|
type TorrentVideo struct {
|
|
*papi.Torrent
|
|
Video polochon.Video `json:"video,omitempty"`
|
|
}
|
|
|
|
// NewTorrentVideo returns a new TorrentVideo
|
|
func NewTorrentVideo(t *papi.Torrent) *TorrentVideo {
|
|
torrent := &polochon.Torrent{
|
|
ImdbID: t.ImdbID,
|
|
Type: polochon.VideoType(t.Type),
|
|
Quality: polochon.Quality(t.Quality),
|
|
Season: t.Season,
|
|
Episode: t.Episode,
|
|
}
|
|
|
|
return &TorrentVideo{
|
|
Torrent: t,
|
|
Video: torrent.Video(),
|
|
}
|
|
}
|
|
|
|
// Update updates the Torrent video with the database details
|
|
func (t *TorrentVideo) Update(detailer polochon.Detailer, log *logrus.Entry) {
|
|
if t.Video == nil {
|
|
return
|
|
}
|
|
|
|
// TODO: refresh the video in db if not found
|
|
err := detailer.GetDetails(t.Video, log)
|
|
if err != nil {
|
|
log.WithField("function", "TorrentVideo.Update").Errorf(err.Error())
|
|
}
|
|
}
|