mirror of
https://github.com/simon-ding/polaris.git
synced 2026-05-26 04:27:46 +08:00
fix: plexmatch
This commit is contained in:
@@ -22,6 +22,13 @@ Polaris 是一个电视剧和电影的追踪软件。配置好了之后,当剧
|
|||||||
|
|
||||||
使用此程序参考 [【快速开始】](./doc/quick_start.md)
|
使用此程序参考 [【快速开始】](./doc/quick_start.md)
|
||||||
|
|
||||||
|
## 原理
|
||||||
|
|
||||||
|
本程序不提供任何视频相关资源,所有的资源都通过 jackett/prowlarr 所对接的BT/PT站点提供。
|
||||||
|
|
||||||
|
1. 此程序通过调用 jackett/prowlarr API搜索相关资源,然后匹配上对应的剧集
|
||||||
|
2. 把搜索到的资源送到下载器下载
|
||||||
|
3. 下载完成后归入对应的路径
|
||||||
|
|
||||||
## 对比 sonarr/radarr
|
## 对比 sonarr/radarr
|
||||||
* 更好的中文支持
|
* 更好的中文支持
|
||||||
|
|||||||
4
db/db.go
4
db/db.go
@@ -167,6 +167,10 @@ func (c *Client) GetEpisode(seriesId, seasonNum, episodeNum int) (*ent.Episode,
|
|||||||
return c.ent.Episode.Query().Where(episode.MediaID(seriesId), episode.SeasonNumber(seasonNum),
|
return c.ent.Episode.Query().Where(episode.MediaID(seriesId), episode.SeasonNumber(seasonNum),
|
||||||
episode.EpisodeNumber(episodeNum)).First(context.TODO())
|
episode.EpisodeNumber(episodeNum)).First(context.TODO())
|
||||||
}
|
}
|
||||||
|
func (c *Client) GetEpisodeByID(epID int) (*ent.Episode, error) {
|
||||||
|
return c.ent.Episode.Query().Where(episode.ID(epID)).First(context.TODO())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *Client) UpdateEpiode(episodeId int, name, overview string) error {
|
func (c *Client) UpdateEpiode(episodeId int, name, overview string) error {
|
||||||
return c.ent.Episode.Update().Where(episode.ID(episodeId)).SetTitle(name).SetOverview(overview).Exec(context.TODO())
|
return c.ent.Episode.Update().Where(episode.ID(episodeId)).SetTitle(name).SetOverview(overview).Exec(context.TODO())
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) writePlexmatch(seriesId int, episodeNum int, targetDir, name string) error {
|
func (s *Server) writePlexmatch(seriesId int, episodeId int, targetDir, name string) error {
|
||||||
|
|
||||||
if !s.plexmatchEnabled() {
|
if !s.plexmatchEnabled() {
|
||||||
return nil
|
return nil
|
||||||
@@ -28,6 +28,7 @@ func (s *Server) writePlexmatch(seriesId int, episodeNum int, targetDir, name st
|
|||||||
return errors.Wrap(err, "get storage")
|
return errors.Wrap(err, "get storage")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//series plexmatch file
|
||||||
_, err = st.ReadFile(filepath.Join(series.TargetDir, ".plexmatch"))
|
_, err = st.ReadFile(filepath.Join(series.TargetDir, ".plexmatch"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//create new
|
//create new
|
||||||
@@ -37,8 +38,10 @@ func (s *Server) writePlexmatch(seriesId int, episodeNum int, targetDir, name st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if episodeNum == 0 {
|
//season plexmatch file
|
||||||
return nil
|
ep, err := s.db.GetEpisodeByID(episodeId)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "query episode")
|
||||||
}
|
}
|
||||||
buff := bytes.Buffer{}
|
buff := bytes.Buffer{}
|
||||||
seasonPlex := filepath.Join(targetDir, ".plexmatch")
|
seasonPlex := filepath.Join(targetDir, ".plexmatch")
|
||||||
@@ -48,7 +51,7 @@ func (s *Server) writePlexmatch(seriesId int, episodeNum int, targetDir, name st
|
|||||||
} else {
|
} else {
|
||||||
buff.Write(data)
|
buff.Write(data)
|
||||||
}
|
}
|
||||||
buff.WriteString(fmt.Sprintf("\nep: %d: %s\n", episodeNum, name))
|
buff.WriteString(fmt.Sprintf("\nep: %d: %s\n", ep.EpisodeNumber, name))
|
||||||
log.Infof("write season plexmatch file content: %s", buff.String())
|
log.Infof("write season plexmatch file content: %s", buff.String())
|
||||||
return st.WriteFile(seasonPlex, buff.Bytes())
|
return st.WriteFile(seasonPlex, buff.Bytes())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user