Compare commits

...

17 Commits

Author SHA1 Message Date
Simon Ding
059c0ee994 fix: refresh 2025-02-10 16:37:15 +08:00
Simon Ding
2f08b5d332 fix button 2025-02-10 16:13:21 +08:00
Simon Ding
ce020566b7 feat: add seeding tab 2025-02-10 16:06:35 +08:00
Simon Ding
f3b2b3bc32 doc: add faq 2025-02-10 15:31:56 +08:00
Simon Ding
e380a624f5 WIP: douban wish list 2025-02-10 15:07:32 +08:00
Simon Ding
80ad9a2a3b feat: horizontal scroll, fix #11 2025-02-10 11:22:25 +08:00
Simon Ding
2a9fdd2a13 fix: db 2025-02-02 13:09:22 +08:00
Simon Ding
88492b3922 feat: deprecate history episodeID and fix related code 2025-02-02 12:49:59 +08:00
Simon Ding
1d9eddf050 fix: episode and history status not match 2025-02-02 12:31:52 +08:00
Simon Ding
8a8bf87c32 fix: torrent hash 2025-02-02 11:55:11 +08:00
Simon Ding
2821d49673 feat: save hash instead of link, and refactor torrent download 2025-02-01 14:22:34 +08:00
Simon Ding
8b6558b2b5 chore: add log 2025-01-31 23:31:32 +08:00
Simon Ding
27515d1368 refactor: history and episode status 2025-01-31 23:21:26 +08:00
Simon Ding
c01924ac3f refactor: copy downloaded file according to torrent info 2025-01-31 19:34:18 +08:00
Simon Ding
1386626712 fix: do not convert torrent to magnet link 2025-01-31 16:34:43 +08:00
Simon Ding
a8b6661ec9 chore: add xml header 2025-01-19 15:44:05 +08:00
Simon Ding
842f8fae09 feat: prowlarr refactor and support prowlarr seed ratio 2025-01-10 11:39:16 +08:00
51 changed files with 2441 additions and 1099 deletions

View File

@@ -47,6 +47,10 @@
- linux/s390x
- linux/ppc64le
## FAQ
- [常见问题 FAQ](./doc/faq.md)
## Todos

View File

@@ -17,6 +17,7 @@ import (
"polaris/ent/storage"
"polaris/log"
"polaris/pkg/utils"
"slices"
"strings"
"time"
@@ -38,13 +39,14 @@ func Open() (*Client, error) {
return nil, errors.Wrap(err, "failed opening connection to sqlite")
}
//defer client.Close()
// Run the auto migration tool.
if err := client.Schema.Create(context.Background()); err != nil {
return nil, errors.Wrap(err, "failed creating schema resources")
}
c := &Client{
ent: client,
}
// Run the auto migration tool.
if err := c.migrate(); err != nil {
return nil, errors.Wrap(err, "migrate")
}
c.init()
return c, nil
@@ -265,20 +267,22 @@ type TorznabSetting struct {
func (c *Client) SaveIndexer(in *ent.Indexers) error {
if in.ID != 0 {
count := c.ent.Indexers.Query().Where(indexers.Name(in.Name)).CountX(context.TODO())
if count > 0 || in.ID != 0 {
//update setting
return c.ent.Indexers.Update().Where(indexers.ID(in.ID)).SetName(in.Name).SetImplementation(in.Implementation).
SetPriority(in.Priority).SetSettings(in.Settings).SetSeedRatio(in.SeedRatio).SetDisabled(in.Disabled).Exec(context.Background())
SetPriority(in.Priority).SetSeedRatio(in.SeedRatio).SetDisabled(in.Disabled).
SetTvSearch(in.TvSearch).SetMovieSearch(in.MovieSearch).SetSettings("").SetSynced(in.Synced).
SetAPIKey(in.APIKey).SetURL(in.URL).
Exec(context.Background())
}
//create new one
count := c.ent.Indexers.Query().Where(indexers.Name(in.Name)).CountX(context.TODO())
if count > 0 {
return fmt.Errorf("name already esxits: %v", in.Name)
}
_, err := c.ent.Indexers.Create().
SetName(in.Name).SetImplementation(in.Implementation).SetPriority(in.Priority).SetSettings(in.Settings).SetSeedRatio(in.SeedRatio).
SetDisabled(in.Disabled).Save(context.TODO())
SetName(in.Name).SetImplementation(in.Implementation).SetPriority(in.Priority).SetSeedRatio(in.SeedRatio).
SetTvSearch(in.TvSearch).SetMovieSearch(in.MovieSearch).SetSettings("").SetSynced(in.Synced).
SetAPIKey(in.APIKey).SetURL(in.URL).SetDisabled(in.Disabled).Save(context.TODO())
if err != nil {
return errors.Wrap(err, "save db")
}
@@ -286,46 +290,21 @@ func (c *Client) SaveIndexer(in *ent.Indexers) error {
return nil
}
func (c *Client) DeleteTorznab(id int) {
func (c *Client) DeleteIndexer(id int) {
c.ent.Indexers.Delete().Where(indexers.ID(id)).Exec(context.TODO())
}
func (c *Client) GetIndexer(id int) (*TorznabInfo, error) {
func (c *Client) GetIndexer(id int) (*ent.Indexers, error) {
res, err := c.ent.Indexers.Query().Where(indexers.ID(id)).First(context.TODO())
if err != nil {
return nil, err
}
var ss TorznabSetting
err = json.Unmarshal([]byte(res.Settings), &ss)
if err != nil {
return nil, fmt.Errorf("unmarshal torznab %s error: %v", res.Name, err)
}
return &TorznabInfo{Indexers: res, TorznabSetting: ss}, nil
return res, nil
}
type TorznabInfo struct {
*ent.Indexers
TorznabSetting
}
func (c *Client) GetAllTorznabInfo() []*TorznabInfo {
res := c.ent.Indexers.Query().Where(indexers.Implementation(IndexerTorznabImpl)).AllX(context.TODO())
var l = make([]*TorznabInfo, 0, len(res))
for _, r := range res {
var ss TorznabSetting
err := json.Unmarshal([]byte(r.Settings), &ss)
if err != nil {
log.Errorf("unmarshal torznab %s error: %v", r.Name, err)
continue
}
l = append(l, &TorznabInfo{
Indexers: r,
TorznabSetting: ss,
})
}
return l
func (c *Client) GetAllIndexers() []*ent.Indexers {
res := c.ent.Indexers.Query().Where(indexers.Implementation(IndexerTorznabImpl)).Order(ent.Asc(indexers.FieldID)).AllX(context.TODO())
return res
}
func (c *Client) SaveDownloader(downloader *ent.DownloadClients) error {
@@ -484,18 +463,10 @@ func (c *Client) SetDefaultStorageByName(name string) error {
}
func (c *Client) SaveHistoryRecord(h ent.History) (*ent.History, error) {
if h.Link != "" {
r, err := utils.Link2Magnet(h.Link)
if err != nil {
log.Warnf("convert link to magnet error, link %v, error: %v", h.Link, err)
} else {
h.Link = r
}
}
return c.ent.History.Create().SetMediaID(h.MediaID).SetEpisodeID(h.EpisodeID).SetDate(time.Now()).
return c.ent.History.Create().SetMediaID(h.MediaID).SetDate(time.Now()).
SetStatus(h.Status).SetTargetDir(h.TargetDir).SetSourceTitle(h.SourceTitle).SetIndexerID(h.IndexerID).
SetDownloadClientID(h.DownloadClientID).SetSize(h.Size).SetSaved(h.Saved).SetSeasonNum(h.SeasonNum).
SetEpisodeNums(h.EpisodeNums).SetLink(h.Link).Save(context.TODO())
SetDownloadClientID(h.DownloadClientID).SetSize(h.Size).SetSeasonNum(h.SeasonNum).
SetEpisodeNums(h.EpisodeNums).SetHash(h.Hash).SetLink(h.Link).Save(context.TODO())
}
func (c *Client) SetHistoryStatus(id int, status history.Status) error {
@@ -550,8 +521,12 @@ func (c *Client) SetEpisodeStatus(id int, status episode.Status) error {
}
func (c *Client) IsEpisodeDownloadingOrDownloaded(id int) bool {
his := c.ent.History.Query().Where(history.EpisodeID(id)).AllX(context.Background())
ep, _ := c.GetEpisodeByID(id)
his := c.ent.History.Query().Where(history.EpisodeNumsNotNil()).AllX(context.Background())
for _, h := range his {
if !slices.Contains(h.EpisodeNums, ep.EpisodeNumber) {
continue
}
if h.Status != history.StatusFail {
return true
}
@@ -712,7 +687,6 @@ func (c *Client) SaveProwlarrSetting(se *ProwlarrSetting) error {
return c.SetSetting(SettingProwlarrInfo, string(data))
}
func (c *Client) getAcceptedFormats(key string) ([]string, error) {
v := c.GetSetting(key)
if v == "" {
@@ -730,7 +704,7 @@ func (c *Client) setAcceptedFormats(key string, v []string) error {
return err
}
return c.SetSetting(key, string(data))
}
}
func (c *Client) GetAcceptedVideoFormats() ([]string, error) {
res, err := c.getAcceptedFormats(SettingAcceptedVideoFormats)
@@ -752,7 +726,7 @@ func (c *Client) GetAcceptedSubtitleFormats() ([]string, error) {
if err != nil {
return nil, err
}
if res== nil {
if res == nil {
return defaultAcceptedSubtitleFormats, nil
}
return res, nil
@@ -760,4 +734,4 @@ func (c *Client) GetAcceptedSubtitleFormats() ([]string, error) {
func (c *Client) SetAcceptedSubtitleFormats(key string, v []string) error {
return c.setAcceptedFormats(SettingAcceptedSubtitleFormats, v)
}
}

46
db/migrate.go Normal file
View File

@@ -0,0 +1,46 @@
package db
import (
"context"
"encoding/json"
"polaris/log"
"github.com/pkg/errors"
)
func (c *Client) migrate() error {
// Run the auto migration tool.
if err := c.ent.Schema.Create(context.Background()); err != nil {
return errors.Wrap(err, "failed creating schema resources")
}
if err := c.migrateIndexerSetting(); err != nil {
return errors.Wrap(err, "migrate indexer setting")
}
return nil
}
func (c *Client) migrateIndexerSetting() error {
indexers := c.GetAllIndexers()
for _, in := range indexers {
if in.Settings == "" {
continue
}
if in.APIKey != "" && in.URL != "" {
continue
}
var setting TorznabSetting
err := json.Unmarshal([]byte(in.Settings), &setting)
if err != nil {
return err
}
in.APIKey = setting.ApiKey
in.URL = setting.URL
if err := c.SaveIndexer(in); err != nil {
return errors.Wrap(err, "save indexer")
}
log.Infof("success migrate indexer setting field: %s", in.Name)
}
return nil
}

14
doc/faq.md Normal file
View File

@@ -0,0 +1,14 @@
# FAQ
## 1. Polaris 能否使用硬链接代替直接拷贝来节省空间?
可以。
使用本地存储时,默认使用硬链接移动文件,如果下载路径和媒体路径不在同一个挂载路径,硬链接会失败,然后会尝试使用拷贝的方式移动文件。
基于这一点我们只需要改造一下docker挂载路径既可以实现硬链接功能。
1. 媒体路径e.g. /data同时挂载到polaris和下载器容器
2. polaris *设置 -> 下载路径* 设为媒体路径下面的文件夹 e.g. /data/downloads
然后Polaris就是使用硬连接而非拷贝的方式

View File

@@ -134,4 +134,6 @@ docker compose up -d
详细配置请看 [配置篇](./configuration.md)
## 6. FAQ
- [常见问题 FAQ](./faq.md)

View File

@@ -20,8 +20,6 @@ type History struct {
ID int `json:"id,omitempty"`
// MediaID holds the value of the "media_id" field.
MediaID int `json:"media_id,omitempty"`
// deprecated
EpisodeID int `json:"episode_id,omitempty"`
// EpisodeNums holds the value of the "episode_nums" field.
EpisodeNums []int `json:"episode_nums,omitempty"`
// SeasonNum holds the value of the "season_num" field.
@@ -38,12 +36,12 @@ type History struct {
DownloadClientID int `json:"download_client_id,omitempty"`
// IndexerID holds the value of the "indexer_id" field.
IndexerID int `json:"indexer_id,omitempty"`
// Link holds the value of the "link" field.
// deprecated, use hash instead
Link string `json:"link,omitempty"`
// torrent hash
Hash string `json:"hash,omitempty"`
// Status holds the value of the "status" field.
Status history.Status `json:"status,omitempty"`
// deprecated
Saved string `json:"saved,omitempty"`
Status history.Status `json:"status,omitempty"`
selectValues sql.SelectValues
}
@@ -54,9 +52,9 @@ func (*History) scanValues(columns []string) ([]any, error) {
switch columns[i] {
case history.FieldEpisodeNums:
values[i] = new([]byte)
case history.FieldID, history.FieldMediaID, history.FieldEpisodeID, history.FieldSeasonNum, history.FieldSize, history.FieldDownloadClientID, history.FieldIndexerID:
case history.FieldID, history.FieldMediaID, history.FieldSeasonNum, history.FieldSize, history.FieldDownloadClientID, history.FieldIndexerID:
values[i] = new(sql.NullInt64)
case history.FieldSourceTitle, history.FieldTargetDir, history.FieldLink, history.FieldStatus, history.FieldSaved:
case history.FieldSourceTitle, history.FieldTargetDir, history.FieldLink, history.FieldHash, history.FieldStatus:
values[i] = new(sql.NullString)
case history.FieldDate:
values[i] = new(sql.NullTime)
@@ -87,12 +85,6 @@ func (h *History) assignValues(columns []string, values []any) error {
} else if value.Valid {
h.MediaID = int(value.Int64)
}
case history.FieldEpisodeID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field episode_id", values[i])
} else if value.Valid {
h.EpisodeID = int(value.Int64)
}
case history.FieldEpisodeNums:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field episode_nums", values[i])
@@ -149,18 +141,18 @@ func (h *History) assignValues(columns []string, values []any) error {
} else if value.Valid {
h.Link = value.String
}
case history.FieldHash:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field hash", values[i])
} else if value.Valid {
h.Hash = value.String
}
case history.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
h.Status = history.Status(value.String)
}
case history.FieldSaved:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field saved", values[i])
} else if value.Valid {
h.Saved = value.String
}
default:
h.selectValues.Set(columns[i], values[i])
}
@@ -200,9 +192,6 @@ func (h *History) String() string {
builder.WriteString("media_id=")
builder.WriteString(fmt.Sprintf("%v", h.MediaID))
builder.WriteString(", ")
builder.WriteString("episode_id=")
builder.WriteString(fmt.Sprintf("%v", h.EpisodeID))
builder.WriteString(", ")
builder.WriteString("episode_nums=")
builder.WriteString(fmt.Sprintf("%v", h.EpisodeNums))
builder.WriteString(", ")
@@ -230,11 +219,11 @@ func (h *History) String() string {
builder.WriteString("link=")
builder.WriteString(h.Link)
builder.WriteString(", ")
builder.WriteString("hash=")
builder.WriteString(h.Hash)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", h.Status))
builder.WriteString(", ")
builder.WriteString("saved=")
builder.WriteString(h.Saved)
builder.WriteByte(')')
return builder.String()
}

View File

@@ -15,8 +15,6 @@ const (
FieldID = "id"
// FieldMediaID holds the string denoting the media_id field in the database.
FieldMediaID = "media_id"
// FieldEpisodeID holds the string denoting the episode_id field in the database.
FieldEpisodeID = "episode_id"
// FieldEpisodeNums holds the string denoting the episode_nums field in the database.
FieldEpisodeNums = "episode_nums"
// FieldSeasonNum holds the string denoting the season_num field in the database.
@@ -35,10 +33,10 @@ const (
FieldIndexerID = "indexer_id"
// FieldLink holds the string denoting the link field in the database.
FieldLink = "link"
// FieldHash holds the string denoting the hash field in the database.
FieldHash = "hash"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldSaved holds the string denoting the saved field in the database.
FieldSaved = "saved"
// Table holds the table name of the history in the database.
Table = "histories"
)
@@ -47,7 +45,6 @@ const (
var Columns = []string{
FieldID,
FieldMediaID,
FieldEpisodeID,
FieldEpisodeNums,
FieldSeasonNum,
FieldSourceTitle,
@@ -57,8 +54,8 @@ var Columns = []string{
FieldDownloadClientID,
FieldIndexerID,
FieldLink,
FieldHash,
FieldStatus,
FieldSaved,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -115,11 +112,6 @@ func ByMediaID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMediaID, opts...).ToFunc()
}
// ByEpisodeID orders the results by the episode_id field.
func ByEpisodeID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEpisodeID, opts...).ToFunc()
}
// BySeasonNum orders the results by the season_num field.
func BySeasonNum(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSeasonNum, opts...).ToFunc()
@@ -160,12 +152,12 @@ func ByLink(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLink, opts...).ToFunc()
}
// ByHash orders the results by the hash field.
func ByHash(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHash, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// BySaved orders the results by the saved field.
func BySaved(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSaved, opts...).ToFunc()
}

View File

@@ -59,11 +59,6 @@ func MediaID(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldMediaID, v))
}
// EpisodeID applies equality check predicate on the "episode_id" field. It's identical to EpisodeIDEQ.
func EpisodeID(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldEpisodeID, v))
}
// SeasonNum applies equality check predicate on the "season_num" field. It's identical to SeasonNumEQ.
func SeasonNum(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldSeasonNum, v))
@@ -104,9 +99,9 @@ func Link(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldLink, v))
}
// Saved applies equality check predicate on the "saved" field. It's identical to SavedEQ.
func Saved(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldSaved, v))
// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ.
func Hash(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldHash, v))
}
// MediaIDEQ applies the EQ predicate on the "media_id" field.
@@ -149,56 +144,6 @@ func MediaIDLTE(v int) predicate.History {
return predicate.History(sql.FieldLTE(FieldMediaID, v))
}
// EpisodeIDEQ applies the EQ predicate on the "episode_id" field.
func EpisodeIDEQ(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldEpisodeID, v))
}
// EpisodeIDNEQ applies the NEQ predicate on the "episode_id" field.
func EpisodeIDNEQ(v int) predicate.History {
return predicate.History(sql.FieldNEQ(FieldEpisodeID, v))
}
// EpisodeIDIn applies the In predicate on the "episode_id" field.
func EpisodeIDIn(vs ...int) predicate.History {
return predicate.History(sql.FieldIn(FieldEpisodeID, vs...))
}
// EpisodeIDNotIn applies the NotIn predicate on the "episode_id" field.
func EpisodeIDNotIn(vs ...int) predicate.History {
return predicate.History(sql.FieldNotIn(FieldEpisodeID, vs...))
}
// EpisodeIDGT applies the GT predicate on the "episode_id" field.
func EpisodeIDGT(v int) predicate.History {
return predicate.History(sql.FieldGT(FieldEpisodeID, v))
}
// EpisodeIDGTE applies the GTE predicate on the "episode_id" field.
func EpisodeIDGTE(v int) predicate.History {
return predicate.History(sql.FieldGTE(FieldEpisodeID, v))
}
// EpisodeIDLT applies the LT predicate on the "episode_id" field.
func EpisodeIDLT(v int) predicate.History {
return predicate.History(sql.FieldLT(FieldEpisodeID, v))
}
// EpisodeIDLTE applies the LTE predicate on the "episode_id" field.
func EpisodeIDLTE(v int) predicate.History {
return predicate.History(sql.FieldLTE(FieldEpisodeID, v))
}
// EpisodeIDIsNil applies the IsNil predicate on the "episode_id" field.
func EpisodeIDIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldEpisodeID))
}
// EpisodeIDNotNil applies the NotNil predicate on the "episode_id" field.
func EpisodeIDNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldEpisodeID))
}
// EpisodeNumsIsNil applies the IsNil predicate on the "episode_nums" field.
func EpisodeNumsIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldEpisodeNums))
@@ -644,6 +589,81 @@ func LinkContainsFold(v string) predicate.History {
return predicate.History(sql.FieldContainsFold(FieldLink, v))
}
// HashEQ applies the EQ predicate on the "hash" field.
func HashEQ(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldHash, v))
}
// HashNEQ applies the NEQ predicate on the "hash" field.
func HashNEQ(v string) predicate.History {
return predicate.History(sql.FieldNEQ(FieldHash, v))
}
// HashIn applies the In predicate on the "hash" field.
func HashIn(vs ...string) predicate.History {
return predicate.History(sql.FieldIn(FieldHash, vs...))
}
// HashNotIn applies the NotIn predicate on the "hash" field.
func HashNotIn(vs ...string) predicate.History {
return predicate.History(sql.FieldNotIn(FieldHash, vs...))
}
// HashGT applies the GT predicate on the "hash" field.
func HashGT(v string) predicate.History {
return predicate.History(sql.FieldGT(FieldHash, v))
}
// HashGTE applies the GTE predicate on the "hash" field.
func HashGTE(v string) predicate.History {
return predicate.History(sql.FieldGTE(FieldHash, v))
}
// HashLT applies the LT predicate on the "hash" field.
func HashLT(v string) predicate.History {
return predicate.History(sql.FieldLT(FieldHash, v))
}
// HashLTE applies the LTE predicate on the "hash" field.
func HashLTE(v string) predicate.History {
return predicate.History(sql.FieldLTE(FieldHash, v))
}
// HashContains applies the Contains predicate on the "hash" field.
func HashContains(v string) predicate.History {
return predicate.History(sql.FieldContains(FieldHash, v))
}
// HashHasPrefix applies the HasPrefix predicate on the "hash" field.
func HashHasPrefix(v string) predicate.History {
return predicate.History(sql.FieldHasPrefix(FieldHash, v))
}
// HashHasSuffix applies the HasSuffix predicate on the "hash" field.
func HashHasSuffix(v string) predicate.History {
return predicate.History(sql.FieldHasSuffix(FieldHash, v))
}
// HashIsNil applies the IsNil predicate on the "hash" field.
func HashIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldHash))
}
// HashNotNil applies the NotNil predicate on the "hash" field.
func HashNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldHash))
}
// HashEqualFold applies the EqualFold predicate on the "hash" field.
func HashEqualFold(v string) predicate.History {
return predicate.History(sql.FieldEqualFold(FieldHash, v))
}
// HashContainsFold applies the ContainsFold predicate on the "hash" field.
func HashContainsFold(v string) predicate.History {
return predicate.History(sql.FieldContainsFold(FieldHash, v))
}
// StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v Status) predicate.History {
return predicate.History(sql.FieldEQ(FieldStatus, v))
@@ -664,81 +684,6 @@ func StatusNotIn(vs ...Status) predicate.History {
return predicate.History(sql.FieldNotIn(FieldStatus, vs...))
}
// SavedEQ applies the EQ predicate on the "saved" field.
func SavedEQ(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldSaved, v))
}
// SavedNEQ applies the NEQ predicate on the "saved" field.
func SavedNEQ(v string) predicate.History {
return predicate.History(sql.FieldNEQ(FieldSaved, v))
}
// SavedIn applies the In predicate on the "saved" field.
func SavedIn(vs ...string) predicate.History {
return predicate.History(sql.FieldIn(FieldSaved, vs...))
}
// SavedNotIn applies the NotIn predicate on the "saved" field.
func SavedNotIn(vs ...string) predicate.History {
return predicate.History(sql.FieldNotIn(FieldSaved, vs...))
}
// SavedGT applies the GT predicate on the "saved" field.
func SavedGT(v string) predicate.History {
return predicate.History(sql.FieldGT(FieldSaved, v))
}
// SavedGTE applies the GTE predicate on the "saved" field.
func SavedGTE(v string) predicate.History {
return predicate.History(sql.FieldGTE(FieldSaved, v))
}
// SavedLT applies the LT predicate on the "saved" field.
func SavedLT(v string) predicate.History {
return predicate.History(sql.FieldLT(FieldSaved, v))
}
// SavedLTE applies the LTE predicate on the "saved" field.
func SavedLTE(v string) predicate.History {
return predicate.History(sql.FieldLTE(FieldSaved, v))
}
// SavedContains applies the Contains predicate on the "saved" field.
func SavedContains(v string) predicate.History {
return predicate.History(sql.FieldContains(FieldSaved, v))
}
// SavedHasPrefix applies the HasPrefix predicate on the "saved" field.
func SavedHasPrefix(v string) predicate.History {
return predicate.History(sql.FieldHasPrefix(FieldSaved, v))
}
// SavedHasSuffix applies the HasSuffix predicate on the "saved" field.
func SavedHasSuffix(v string) predicate.History {
return predicate.History(sql.FieldHasSuffix(FieldSaved, v))
}
// SavedIsNil applies the IsNil predicate on the "saved" field.
func SavedIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldSaved))
}
// SavedNotNil applies the NotNil predicate on the "saved" field.
func SavedNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldSaved))
}
// SavedEqualFold applies the EqualFold predicate on the "saved" field.
func SavedEqualFold(v string) predicate.History {
return predicate.History(sql.FieldEqualFold(FieldSaved, v))
}
// SavedContainsFold applies the ContainsFold predicate on the "saved" field.
func SavedContainsFold(v string) predicate.History {
return predicate.History(sql.FieldContainsFold(FieldSaved, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.History) predicate.History {
return predicate.History(sql.AndPredicates(predicates...))

View File

@@ -26,20 +26,6 @@ func (hc *HistoryCreate) SetMediaID(i int) *HistoryCreate {
return hc
}
// SetEpisodeID sets the "episode_id" field.
func (hc *HistoryCreate) SetEpisodeID(i int) *HistoryCreate {
hc.mutation.SetEpisodeID(i)
return hc
}
// SetNillableEpisodeID sets the "episode_id" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableEpisodeID(i *int) *HistoryCreate {
if i != nil {
hc.SetEpisodeID(*i)
}
return hc
}
// SetEpisodeNums sets the "episode_nums" field.
func (hc *HistoryCreate) SetEpisodeNums(i []int) *HistoryCreate {
hc.mutation.SetEpisodeNums(i)
@@ -134,26 +120,26 @@ func (hc *HistoryCreate) SetNillableLink(s *string) *HistoryCreate {
return hc
}
// SetHash sets the "hash" field.
func (hc *HistoryCreate) SetHash(s string) *HistoryCreate {
hc.mutation.SetHash(s)
return hc
}
// SetNillableHash sets the "hash" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableHash(s *string) *HistoryCreate {
if s != nil {
hc.SetHash(*s)
}
return hc
}
// SetStatus sets the "status" field.
func (hc *HistoryCreate) SetStatus(h history.Status) *HistoryCreate {
hc.mutation.SetStatus(h)
return hc
}
// SetSaved sets the "saved" field.
func (hc *HistoryCreate) SetSaved(s string) *HistoryCreate {
hc.mutation.SetSaved(s)
return hc
}
// SetNillableSaved sets the "saved" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableSaved(s *string) *HistoryCreate {
if s != nil {
hc.SetSaved(*s)
}
return hc
}
// Mutation returns the HistoryMutation object of the builder.
func (hc *HistoryCreate) Mutation() *HistoryMutation {
return hc.mutation
@@ -250,10 +236,6 @@ func (hc *HistoryCreate) createSpec() (*History, *sqlgraph.CreateSpec) {
_spec.SetField(history.FieldMediaID, field.TypeInt, value)
_node.MediaID = value
}
if value, ok := hc.mutation.EpisodeID(); ok {
_spec.SetField(history.FieldEpisodeID, field.TypeInt, value)
_node.EpisodeID = value
}
if value, ok := hc.mutation.EpisodeNums(); ok {
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
_node.EpisodeNums = value
@@ -290,14 +272,14 @@ func (hc *HistoryCreate) createSpec() (*History, *sqlgraph.CreateSpec) {
_spec.SetField(history.FieldLink, field.TypeString, value)
_node.Link = value
}
if value, ok := hc.mutation.Hash(); ok {
_spec.SetField(history.FieldHash, field.TypeString, value)
_node.Hash = value
}
if value, ok := hc.mutation.Status(); ok {
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
_node.Status = value
}
if value, ok := hc.mutation.Saved(); ok {
_spec.SetField(history.FieldSaved, field.TypeString, value)
_node.Saved = value
}
return _node, _spec
}

View File

@@ -50,33 +50,6 @@ func (hu *HistoryUpdate) AddMediaID(i int) *HistoryUpdate {
return hu
}
// SetEpisodeID sets the "episode_id" field.
func (hu *HistoryUpdate) SetEpisodeID(i int) *HistoryUpdate {
hu.mutation.ResetEpisodeID()
hu.mutation.SetEpisodeID(i)
return hu
}
// SetNillableEpisodeID sets the "episode_id" field if the given value is not nil.
func (hu *HistoryUpdate) SetNillableEpisodeID(i *int) *HistoryUpdate {
if i != nil {
hu.SetEpisodeID(*i)
}
return hu
}
// AddEpisodeID adds i to the "episode_id" field.
func (hu *HistoryUpdate) AddEpisodeID(i int) *HistoryUpdate {
hu.mutation.AddEpisodeID(i)
return hu
}
// ClearEpisodeID clears the value of the "episode_id" field.
func (hu *HistoryUpdate) ClearEpisodeID() *HistoryUpdate {
hu.mutation.ClearEpisodeID()
return hu
}
// SetEpisodeNums sets the "episode_nums" field.
func (hu *HistoryUpdate) SetEpisodeNums(i []int) *HistoryUpdate {
hu.mutation.SetEpisodeNums(i)
@@ -259,6 +232,26 @@ func (hu *HistoryUpdate) ClearLink() *HistoryUpdate {
return hu
}
// SetHash sets the "hash" field.
func (hu *HistoryUpdate) SetHash(s string) *HistoryUpdate {
hu.mutation.SetHash(s)
return hu
}
// SetNillableHash sets the "hash" field if the given value is not nil.
func (hu *HistoryUpdate) SetNillableHash(s *string) *HistoryUpdate {
if s != nil {
hu.SetHash(*s)
}
return hu
}
// ClearHash clears the value of the "hash" field.
func (hu *HistoryUpdate) ClearHash() *HistoryUpdate {
hu.mutation.ClearHash()
return hu
}
// SetStatus sets the "status" field.
func (hu *HistoryUpdate) SetStatus(h history.Status) *HistoryUpdate {
hu.mutation.SetStatus(h)
@@ -273,26 +266,6 @@ func (hu *HistoryUpdate) SetNillableStatus(h *history.Status) *HistoryUpdate {
return hu
}
// SetSaved sets the "saved" field.
func (hu *HistoryUpdate) SetSaved(s string) *HistoryUpdate {
hu.mutation.SetSaved(s)
return hu
}
// SetNillableSaved sets the "saved" field if the given value is not nil.
func (hu *HistoryUpdate) SetNillableSaved(s *string) *HistoryUpdate {
if s != nil {
hu.SetSaved(*s)
}
return hu
}
// ClearSaved clears the value of the "saved" field.
func (hu *HistoryUpdate) ClearSaved() *HistoryUpdate {
hu.mutation.ClearSaved()
return hu
}
// Mutation returns the HistoryMutation object of the builder.
func (hu *HistoryUpdate) Mutation() *HistoryMutation {
return hu.mutation
@@ -353,15 +326,6 @@ func (hu *HistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := hu.mutation.AddedMediaID(); ok {
_spec.AddField(history.FieldMediaID, field.TypeInt, value)
}
if value, ok := hu.mutation.EpisodeID(); ok {
_spec.SetField(history.FieldEpisodeID, field.TypeInt, value)
}
if value, ok := hu.mutation.AddedEpisodeID(); ok {
_spec.AddField(history.FieldEpisodeID, field.TypeInt, value)
}
if hu.mutation.EpisodeIDCleared() {
_spec.ClearField(history.FieldEpisodeID, field.TypeInt)
}
if value, ok := hu.mutation.EpisodeNums(); ok {
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
}
@@ -421,15 +385,15 @@ func (hu *HistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if hu.mutation.LinkCleared() {
_spec.ClearField(history.FieldLink, field.TypeString)
}
if value, ok := hu.mutation.Hash(); ok {
_spec.SetField(history.FieldHash, field.TypeString, value)
}
if hu.mutation.HashCleared() {
_spec.ClearField(history.FieldHash, field.TypeString)
}
if value, ok := hu.mutation.Status(); ok {
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
}
if value, ok := hu.mutation.Saved(); ok {
_spec.SetField(history.FieldSaved, field.TypeString, value)
}
if hu.mutation.SavedCleared() {
_spec.ClearField(history.FieldSaved, field.TypeString)
}
if n, err = sqlgraph.UpdateNodes(ctx, hu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{history.Label}
@@ -471,33 +435,6 @@ func (huo *HistoryUpdateOne) AddMediaID(i int) *HistoryUpdateOne {
return huo
}
// SetEpisodeID sets the "episode_id" field.
func (huo *HistoryUpdateOne) SetEpisodeID(i int) *HistoryUpdateOne {
huo.mutation.ResetEpisodeID()
huo.mutation.SetEpisodeID(i)
return huo
}
// SetNillableEpisodeID sets the "episode_id" field if the given value is not nil.
func (huo *HistoryUpdateOne) SetNillableEpisodeID(i *int) *HistoryUpdateOne {
if i != nil {
huo.SetEpisodeID(*i)
}
return huo
}
// AddEpisodeID adds i to the "episode_id" field.
func (huo *HistoryUpdateOne) AddEpisodeID(i int) *HistoryUpdateOne {
huo.mutation.AddEpisodeID(i)
return huo
}
// ClearEpisodeID clears the value of the "episode_id" field.
func (huo *HistoryUpdateOne) ClearEpisodeID() *HistoryUpdateOne {
huo.mutation.ClearEpisodeID()
return huo
}
// SetEpisodeNums sets the "episode_nums" field.
func (huo *HistoryUpdateOne) SetEpisodeNums(i []int) *HistoryUpdateOne {
huo.mutation.SetEpisodeNums(i)
@@ -680,6 +617,26 @@ func (huo *HistoryUpdateOne) ClearLink() *HistoryUpdateOne {
return huo
}
// SetHash sets the "hash" field.
func (huo *HistoryUpdateOne) SetHash(s string) *HistoryUpdateOne {
huo.mutation.SetHash(s)
return huo
}
// SetNillableHash sets the "hash" field if the given value is not nil.
func (huo *HistoryUpdateOne) SetNillableHash(s *string) *HistoryUpdateOne {
if s != nil {
huo.SetHash(*s)
}
return huo
}
// ClearHash clears the value of the "hash" field.
func (huo *HistoryUpdateOne) ClearHash() *HistoryUpdateOne {
huo.mutation.ClearHash()
return huo
}
// SetStatus sets the "status" field.
func (huo *HistoryUpdateOne) SetStatus(h history.Status) *HistoryUpdateOne {
huo.mutation.SetStatus(h)
@@ -694,26 +651,6 @@ func (huo *HistoryUpdateOne) SetNillableStatus(h *history.Status) *HistoryUpdate
return huo
}
// SetSaved sets the "saved" field.
func (huo *HistoryUpdateOne) SetSaved(s string) *HistoryUpdateOne {
huo.mutation.SetSaved(s)
return huo
}
// SetNillableSaved sets the "saved" field if the given value is not nil.
func (huo *HistoryUpdateOne) SetNillableSaved(s *string) *HistoryUpdateOne {
if s != nil {
huo.SetSaved(*s)
}
return huo
}
// ClearSaved clears the value of the "saved" field.
func (huo *HistoryUpdateOne) ClearSaved() *HistoryUpdateOne {
huo.mutation.ClearSaved()
return huo
}
// Mutation returns the HistoryMutation object of the builder.
func (huo *HistoryUpdateOne) Mutation() *HistoryMutation {
return huo.mutation
@@ -804,15 +741,6 @@ func (huo *HistoryUpdateOne) sqlSave(ctx context.Context) (_node *History, err e
if value, ok := huo.mutation.AddedMediaID(); ok {
_spec.AddField(history.FieldMediaID, field.TypeInt, value)
}
if value, ok := huo.mutation.EpisodeID(); ok {
_spec.SetField(history.FieldEpisodeID, field.TypeInt, value)
}
if value, ok := huo.mutation.AddedEpisodeID(); ok {
_spec.AddField(history.FieldEpisodeID, field.TypeInt, value)
}
if huo.mutation.EpisodeIDCleared() {
_spec.ClearField(history.FieldEpisodeID, field.TypeInt)
}
if value, ok := huo.mutation.EpisodeNums(); ok {
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
}
@@ -872,15 +800,15 @@ func (huo *HistoryUpdateOne) sqlSave(ctx context.Context) (_node *History, err e
if huo.mutation.LinkCleared() {
_spec.ClearField(history.FieldLink, field.TypeString)
}
if value, ok := huo.mutation.Hash(); ok {
_spec.SetField(history.FieldHash, field.TypeString, value)
}
if huo.mutation.HashCleared() {
_spec.ClearField(history.FieldHash, field.TypeString)
}
if value, ok := huo.mutation.Status(); ok {
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
}
if value, ok := huo.mutation.Saved(); ok {
_spec.SetField(history.FieldSaved, field.TypeString, value)
}
if huo.mutation.SavedCleared() {
_spec.ClearField(history.FieldSaved, field.TypeString)
}
_node = &History{config: huo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues

View File

@@ -20,7 +20,7 @@ type Indexers struct {
Name string `json:"name,omitempty"`
// Implementation holds the value of the "implementation" field.
Implementation string `json:"implementation,omitempty"`
// Settings holds the value of the "settings" field.
// deprecated, use api_key and url
Settings string `json:"settings,omitempty"`
// EnableRss holds the value of the "enable_rss" field.
EnableRss bool `json:"enable_rss,omitempty"`
@@ -29,7 +29,17 @@ type Indexers struct {
// minimal seed ratio requied, before removing torrent
SeedRatio float32 `json:"seed_ratio,omitempty"`
// Disabled holds the value of the "disabled" field.
Disabled bool `json:"disabled,omitempty"`
Disabled bool `json:"disabled,omitempty"`
// TvSearch holds the value of the "tv_search" field.
TvSearch bool `json:"tv_search,omitempty"`
// MovieSearch holds the value of the "movie_search" field.
MovieSearch bool `json:"movie_search,omitempty"`
// APIKey holds the value of the "api_key" field.
APIKey string `json:"api_key,omitempty"`
// URL holds the value of the "url" field.
URL string `json:"url,omitempty"`
// synced from prowlarr
Synced bool `json:"synced,omitempty"`
selectValues sql.SelectValues
}
@@ -38,13 +48,13 @@ func (*Indexers) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case indexers.FieldEnableRss, indexers.FieldDisabled:
case indexers.FieldEnableRss, indexers.FieldDisabled, indexers.FieldTvSearch, indexers.FieldMovieSearch, indexers.FieldSynced:
values[i] = new(sql.NullBool)
case indexers.FieldSeedRatio:
values[i] = new(sql.NullFloat64)
case indexers.FieldID, indexers.FieldPriority:
values[i] = new(sql.NullInt64)
case indexers.FieldName, indexers.FieldImplementation, indexers.FieldSettings:
case indexers.FieldName, indexers.FieldImplementation, indexers.FieldSettings, indexers.FieldAPIKey, indexers.FieldURL:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
@@ -109,6 +119,36 @@ func (i *Indexers) assignValues(columns []string, values []any) error {
} else if value.Valid {
i.Disabled = value.Bool
}
case indexers.FieldTvSearch:
if value, ok := values[j].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field tv_search", values[j])
} else if value.Valid {
i.TvSearch = value.Bool
}
case indexers.FieldMovieSearch:
if value, ok := values[j].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field movie_search", values[j])
} else if value.Valid {
i.MovieSearch = value.Bool
}
case indexers.FieldAPIKey:
if value, ok := values[j].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field api_key", values[j])
} else if value.Valid {
i.APIKey = value.String
}
case indexers.FieldURL:
if value, ok := values[j].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field url", values[j])
} else if value.Valid {
i.URL = value.String
}
case indexers.FieldSynced:
if value, ok := values[j].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field synced", values[j])
} else if value.Valid {
i.Synced = value.Bool
}
default:
i.selectValues.Set(columns[j], values[j])
}
@@ -165,6 +205,21 @@ func (i *Indexers) String() string {
builder.WriteString(", ")
builder.WriteString("disabled=")
builder.WriteString(fmt.Sprintf("%v", i.Disabled))
builder.WriteString(", ")
builder.WriteString("tv_search=")
builder.WriteString(fmt.Sprintf("%v", i.TvSearch))
builder.WriteString(", ")
builder.WriteString("movie_search=")
builder.WriteString(fmt.Sprintf("%v", i.MovieSearch))
builder.WriteString(", ")
builder.WriteString("api_key=")
builder.WriteString(i.APIKey)
builder.WriteString(", ")
builder.WriteString("url=")
builder.WriteString(i.URL)
builder.WriteString(", ")
builder.WriteString("synced=")
builder.WriteString(fmt.Sprintf("%v", i.Synced))
builder.WriteByte(')')
return builder.String()
}

View File

@@ -25,6 +25,16 @@ const (
FieldSeedRatio = "seed_ratio"
// FieldDisabled holds the string denoting the disabled field in the database.
FieldDisabled = "disabled"
// FieldTvSearch holds the string denoting the tv_search field in the database.
FieldTvSearch = "tv_search"
// FieldMovieSearch holds the string denoting the movie_search field in the database.
FieldMovieSearch = "movie_search"
// FieldAPIKey holds the string denoting the api_key field in the database.
FieldAPIKey = "api_key"
// FieldURL holds the string denoting the url field in the database.
FieldURL = "url"
// FieldSynced holds the string denoting the synced field in the database.
FieldSynced = "synced"
// Table holds the table name of the indexers in the database.
Table = "indexers"
)
@@ -39,6 +49,11 @@ var Columns = []string{
FieldPriority,
FieldSeedRatio,
FieldDisabled,
FieldTvSearch,
FieldMovieSearch,
FieldAPIKey,
FieldURL,
FieldSynced,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -52,6 +67,8 @@ func ValidColumn(column string) bool {
}
var (
// DefaultSettings holds the default value on creation for the "settings" field.
DefaultSettings string
// DefaultEnableRss holds the default value on creation for the "enable_rss" field.
DefaultEnableRss bool
// DefaultPriority holds the default value on creation for the "priority" field.
@@ -60,6 +77,12 @@ var (
DefaultSeedRatio float32
// DefaultDisabled holds the default value on creation for the "disabled" field.
DefaultDisabled bool
// DefaultTvSearch holds the default value on creation for the "tv_search" field.
DefaultTvSearch bool
// DefaultMovieSearch holds the default value on creation for the "movie_search" field.
DefaultMovieSearch bool
// DefaultSynced holds the default value on creation for the "synced" field.
DefaultSynced bool
)
// OrderOption defines the ordering options for the Indexers queries.
@@ -104,3 +127,28 @@ func BySeedRatio(opts ...sql.OrderTermOption) OrderOption {
func ByDisabled(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDisabled, opts...).ToFunc()
}
// ByTvSearch orders the results by the tv_search field.
func ByTvSearch(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTvSearch, opts...).ToFunc()
}
// ByMovieSearch orders the results by the movie_search field.
func ByMovieSearch(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMovieSearch, opts...).ToFunc()
}
// ByAPIKey orders the results by the api_key field.
func ByAPIKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAPIKey, opts...).ToFunc()
}
// ByURL orders the results by the url field.
func ByURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldURL, opts...).ToFunc()
}
// BySynced orders the results by the synced field.
func BySynced(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSynced, opts...).ToFunc()
}

View File

@@ -88,6 +88,31 @@ func Disabled(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldDisabled, v))
}
// TvSearch applies equality check predicate on the "tv_search" field. It's identical to TvSearchEQ.
func TvSearch(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldTvSearch, v))
}
// MovieSearch applies equality check predicate on the "movie_search" field. It's identical to MovieSearchEQ.
func MovieSearch(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldMovieSearch, v))
}
// APIKey applies equality check predicate on the "api_key" field. It's identical to APIKeyEQ.
func APIKey(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldAPIKey, v))
}
// URL applies equality check predicate on the "url" field. It's identical to URLEQ.
func URL(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldURL, v))
}
// Synced applies equality check predicate on the "synced" field. It's identical to SyncedEQ.
func Synced(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldSynced, v))
}
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldName, v))
@@ -273,6 +298,16 @@ func SettingsHasSuffix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasSuffix(FieldSettings, v))
}
// SettingsIsNil applies the IsNil predicate on the "settings" field.
func SettingsIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldSettings))
}
// SettingsNotNil applies the NotNil predicate on the "settings" field.
func SettingsNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldSettings))
}
// SettingsEqualFold applies the EqualFold predicate on the "settings" field.
func SettingsEqualFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEqualFold(FieldSettings, v))
@@ -403,6 +438,216 @@ func DisabledNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldDisabled))
}
// TvSearchEQ applies the EQ predicate on the "tv_search" field.
func TvSearchEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldTvSearch, v))
}
// TvSearchNEQ applies the NEQ predicate on the "tv_search" field.
func TvSearchNEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldTvSearch, v))
}
// TvSearchIsNil applies the IsNil predicate on the "tv_search" field.
func TvSearchIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldTvSearch))
}
// TvSearchNotNil applies the NotNil predicate on the "tv_search" field.
func TvSearchNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldTvSearch))
}
// MovieSearchEQ applies the EQ predicate on the "movie_search" field.
func MovieSearchEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldMovieSearch, v))
}
// MovieSearchNEQ applies the NEQ predicate on the "movie_search" field.
func MovieSearchNEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldMovieSearch, v))
}
// MovieSearchIsNil applies the IsNil predicate on the "movie_search" field.
func MovieSearchIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldMovieSearch))
}
// MovieSearchNotNil applies the NotNil predicate on the "movie_search" field.
func MovieSearchNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldMovieSearch))
}
// APIKeyEQ applies the EQ predicate on the "api_key" field.
func APIKeyEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldAPIKey, v))
}
// APIKeyNEQ applies the NEQ predicate on the "api_key" field.
func APIKeyNEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldAPIKey, v))
}
// APIKeyIn applies the In predicate on the "api_key" field.
func APIKeyIn(vs ...string) predicate.Indexers {
return predicate.Indexers(sql.FieldIn(FieldAPIKey, vs...))
}
// APIKeyNotIn applies the NotIn predicate on the "api_key" field.
func APIKeyNotIn(vs ...string) predicate.Indexers {
return predicate.Indexers(sql.FieldNotIn(FieldAPIKey, vs...))
}
// APIKeyGT applies the GT predicate on the "api_key" field.
func APIKeyGT(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldGT(FieldAPIKey, v))
}
// APIKeyGTE applies the GTE predicate on the "api_key" field.
func APIKeyGTE(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldGTE(FieldAPIKey, v))
}
// APIKeyLT applies the LT predicate on the "api_key" field.
func APIKeyLT(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldLT(FieldAPIKey, v))
}
// APIKeyLTE applies the LTE predicate on the "api_key" field.
func APIKeyLTE(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldLTE(FieldAPIKey, v))
}
// APIKeyContains applies the Contains predicate on the "api_key" field.
func APIKeyContains(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldContains(FieldAPIKey, v))
}
// APIKeyHasPrefix applies the HasPrefix predicate on the "api_key" field.
func APIKeyHasPrefix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasPrefix(FieldAPIKey, v))
}
// APIKeyHasSuffix applies the HasSuffix predicate on the "api_key" field.
func APIKeyHasSuffix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasSuffix(FieldAPIKey, v))
}
// APIKeyIsNil applies the IsNil predicate on the "api_key" field.
func APIKeyIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldAPIKey))
}
// APIKeyNotNil applies the NotNil predicate on the "api_key" field.
func APIKeyNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldAPIKey))
}
// APIKeyEqualFold applies the EqualFold predicate on the "api_key" field.
func APIKeyEqualFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEqualFold(FieldAPIKey, v))
}
// APIKeyContainsFold applies the ContainsFold predicate on the "api_key" field.
func APIKeyContainsFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldContainsFold(FieldAPIKey, v))
}
// URLEQ applies the EQ predicate on the "url" field.
func URLEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldURL, v))
}
// URLNEQ applies the NEQ predicate on the "url" field.
func URLNEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldURL, v))
}
// URLIn applies the In predicate on the "url" field.
func URLIn(vs ...string) predicate.Indexers {
return predicate.Indexers(sql.FieldIn(FieldURL, vs...))
}
// URLNotIn applies the NotIn predicate on the "url" field.
func URLNotIn(vs ...string) predicate.Indexers {
return predicate.Indexers(sql.FieldNotIn(FieldURL, vs...))
}
// URLGT applies the GT predicate on the "url" field.
func URLGT(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldGT(FieldURL, v))
}
// URLGTE applies the GTE predicate on the "url" field.
func URLGTE(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldGTE(FieldURL, v))
}
// URLLT applies the LT predicate on the "url" field.
func URLLT(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldLT(FieldURL, v))
}
// URLLTE applies the LTE predicate on the "url" field.
func URLLTE(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldLTE(FieldURL, v))
}
// URLContains applies the Contains predicate on the "url" field.
func URLContains(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldContains(FieldURL, v))
}
// URLHasPrefix applies the HasPrefix predicate on the "url" field.
func URLHasPrefix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasPrefix(FieldURL, v))
}
// URLHasSuffix applies the HasSuffix predicate on the "url" field.
func URLHasSuffix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasSuffix(FieldURL, v))
}
// URLIsNil applies the IsNil predicate on the "url" field.
func URLIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldURL))
}
// URLNotNil applies the NotNil predicate on the "url" field.
func URLNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldURL))
}
// URLEqualFold applies the EqualFold predicate on the "url" field.
func URLEqualFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEqualFold(FieldURL, v))
}
// URLContainsFold applies the ContainsFold predicate on the "url" field.
func URLContainsFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldContainsFold(FieldURL, v))
}
// SyncedEQ applies the EQ predicate on the "synced" field.
func SyncedEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldSynced, v))
}
// SyncedNEQ applies the NEQ predicate on the "synced" field.
func SyncedNEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldSynced, v))
}
// SyncedIsNil applies the IsNil predicate on the "synced" field.
func SyncedIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldSynced))
}
// SyncedNotNil applies the NotNil predicate on the "synced" field.
func SyncedNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldSynced))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Indexers) predicate.Indexers {
return predicate.Indexers(sql.AndPredicates(predicates...))

View File

@@ -37,6 +37,14 @@ func (ic *IndexersCreate) SetSettings(s string) *IndexersCreate {
return ic
}
// SetNillableSettings sets the "settings" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableSettings(s *string) *IndexersCreate {
if s != nil {
ic.SetSettings(*s)
}
return ic
}
// SetEnableRss sets the "enable_rss" field.
func (ic *IndexersCreate) SetEnableRss(b bool) *IndexersCreate {
ic.mutation.SetEnableRss(b)
@@ -93,6 +101,76 @@ func (ic *IndexersCreate) SetNillableDisabled(b *bool) *IndexersCreate {
return ic
}
// SetTvSearch sets the "tv_search" field.
func (ic *IndexersCreate) SetTvSearch(b bool) *IndexersCreate {
ic.mutation.SetTvSearch(b)
return ic
}
// SetNillableTvSearch sets the "tv_search" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableTvSearch(b *bool) *IndexersCreate {
if b != nil {
ic.SetTvSearch(*b)
}
return ic
}
// SetMovieSearch sets the "movie_search" field.
func (ic *IndexersCreate) SetMovieSearch(b bool) *IndexersCreate {
ic.mutation.SetMovieSearch(b)
return ic
}
// SetNillableMovieSearch sets the "movie_search" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableMovieSearch(b *bool) *IndexersCreate {
if b != nil {
ic.SetMovieSearch(*b)
}
return ic
}
// SetAPIKey sets the "api_key" field.
func (ic *IndexersCreate) SetAPIKey(s string) *IndexersCreate {
ic.mutation.SetAPIKey(s)
return ic
}
// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableAPIKey(s *string) *IndexersCreate {
if s != nil {
ic.SetAPIKey(*s)
}
return ic
}
// SetURL sets the "url" field.
func (ic *IndexersCreate) SetURL(s string) *IndexersCreate {
ic.mutation.SetURL(s)
return ic
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableURL(s *string) *IndexersCreate {
if s != nil {
ic.SetURL(*s)
}
return ic
}
// SetSynced sets the "synced" field.
func (ic *IndexersCreate) SetSynced(b bool) *IndexersCreate {
ic.mutation.SetSynced(b)
return ic
}
// SetNillableSynced sets the "synced" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableSynced(b *bool) *IndexersCreate {
if b != nil {
ic.SetSynced(*b)
}
return ic
}
// Mutation returns the IndexersMutation object of the builder.
func (ic *IndexersCreate) Mutation() *IndexersMutation {
return ic.mutation
@@ -128,6 +206,10 @@ func (ic *IndexersCreate) ExecX(ctx context.Context) {
// defaults sets the default values of the builder before save.
func (ic *IndexersCreate) defaults() {
if _, ok := ic.mutation.Settings(); !ok {
v := indexers.DefaultSettings
ic.mutation.SetSettings(v)
}
if _, ok := ic.mutation.EnableRss(); !ok {
v := indexers.DefaultEnableRss
ic.mutation.SetEnableRss(v)
@@ -144,6 +226,18 @@ func (ic *IndexersCreate) defaults() {
v := indexers.DefaultDisabled
ic.mutation.SetDisabled(v)
}
if _, ok := ic.mutation.TvSearch(); !ok {
v := indexers.DefaultTvSearch
ic.mutation.SetTvSearch(v)
}
if _, ok := ic.mutation.MovieSearch(); !ok {
v := indexers.DefaultMovieSearch
ic.mutation.SetMovieSearch(v)
}
if _, ok := ic.mutation.Synced(); !ok {
v := indexers.DefaultSynced
ic.mutation.SetSynced(v)
}
}
// check runs all checks and user-defined validators on the builder.
@@ -154,9 +248,6 @@ func (ic *IndexersCreate) check() error {
if _, ok := ic.mutation.Implementation(); !ok {
return &ValidationError{Name: "implementation", err: errors.New(`ent: missing required field "Indexers.implementation"`)}
}
if _, ok := ic.mutation.Settings(); !ok {
return &ValidationError{Name: "settings", err: errors.New(`ent: missing required field "Indexers.settings"`)}
}
if _, ok := ic.mutation.EnableRss(); !ok {
return &ValidationError{Name: "enable_rss", err: errors.New(`ent: missing required field "Indexers.enable_rss"`)}
}
@@ -217,6 +308,26 @@ func (ic *IndexersCreate) createSpec() (*Indexers, *sqlgraph.CreateSpec) {
_spec.SetField(indexers.FieldDisabled, field.TypeBool, value)
_node.Disabled = value
}
if value, ok := ic.mutation.TvSearch(); ok {
_spec.SetField(indexers.FieldTvSearch, field.TypeBool, value)
_node.TvSearch = value
}
if value, ok := ic.mutation.MovieSearch(); ok {
_spec.SetField(indexers.FieldMovieSearch, field.TypeBool, value)
_node.MovieSearch = value
}
if value, ok := ic.mutation.APIKey(); ok {
_spec.SetField(indexers.FieldAPIKey, field.TypeString, value)
_node.APIKey = value
}
if value, ok := ic.mutation.URL(); ok {
_spec.SetField(indexers.FieldURL, field.TypeString, value)
_node.URL = value
}
if value, ok := ic.mutation.Synced(); ok {
_spec.SetField(indexers.FieldSynced, field.TypeBool, value)
_node.Synced = value
}
return _node, _spec
}

View File

@@ -69,6 +69,12 @@ func (iu *IndexersUpdate) SetNillableSettings(s *string) *IndexersUpdate {
return iu
}
// ClearSettings clears the value of the "settings" field.
func (iu *IndexersUpdate) ClearSettings() *IndexersUpdate {
iu.mutation.ClearSettings()
return iu
}
// SetEnableRss sets the "enable_rss" field.
func (iu *IndexersUpdate) SetEnableRss(b bool) *IndexersUpdate {
iu.mutation.SetEnableRss(b)
@@ -151,6 +157,106 @@ func (iu *IndexersUpdate) ClearDisabled() *IndexersUpdate {
return iu
}
// SetTvSearch sets the "tv_search" field.
func (iu *IndexersUpdate) SetTvSearch(b bool) *IndexersUpdate {
iu.mutation.SetTvSearch(b)
return iu
}
// SetNillableTvSearch sets the "tv_search" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableTvSearch(b *bool) *IndexersUpdate {
if b != nil {
iu.SetTvSearch(*b)
}
return iu
}
// ClearTvSearch clears the value of the "tv_search" field.
func (iu *IndexersUpdate) ClearTvSearch() *IndexersUpdate {
iu.mutation.ClearTvSearch()
return iu
}
// SetMovieSearch sets the "movie_search" field.
func (iu *IndexersUpdate) SetMovieSearch(b bool) *IndexersUpdate {
iu.mutation.SetMovieSearch(b)
return iu
}
// SetNillableMovieSearch sets the "movie_search" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableMovieSearch(b *bool) *IndexersUpdate {
if b != nil {
iu.SetMovieSearch(*b)
}
return iu
}
// ClearMovieSearch clears the value of the "movie_search" field.
func (iu *IndexersUpdate) ClearMovieSearch() *IndexersUpdate {
iu.mutation.ClearMovieSearch()
return iu
}
// SetAPIKey sets the "api_key" field.
func (iu *IndexersUpdate) SetAPIKey(s string) *IndexersUpdate {
iu.mutation.SetAPIKey(s)
return iu
}
// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableAPIKey(s *string) *IndexersUpdate {
if s != nil {
iu.SetAPIKey(*s)
}
return iu
}
// ClearAPIKey clears the value of the "api_key" field.
func (iu *IndexersUpdate) ClearAPIKey() *IndexersUpdate {
iu.mutation.ClearAPIKey()
return iu
}
// SetURL sets the "url" field.
func (iu *IndexersUpdate) SetURL(s string) *IndexersUpdate {
iu.mutation.SetURL(s)
return iu
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableURL(s *string) *IndexersUpdate {
if s != nil {
iu.SetURL(*s)
}
return iu
}
// ClearURL clears the value of the "url" field.
func (iu *IndexersUpdate) ClearURL() *IndexersUpdate {
iu.mutation.ClearURL()
return iu
}
// SetSynced sets the "synced" field.
func (iu *IndexersUpdate) SetSynced(b bool) *IndexersUpdate {
iu.mutation.SetSynced(b)
return iu
}
// SetNillableSynced sets the "synced" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableSynced(b *bool) *IndexersUpdate {
if b != nil {
iu.SetSynced(*b)
}
return iu
}
// ClearSynced clears the value of the "synced" field.
func (iu *IndexersUpdate) ClearSynced() *IndexersUpdate {
iu.mutation.ClearSynced()
return iu
}
// Mutation returns the IndexersMutation object of the builder.
func (iu *IndexersUpdate) Mutation() *IndexersMutation {
return iu.mutation
@@ -201,6 +307,9 @@ func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := iu.mutation.Settings(); ok {
_spec.SetField(indexers.FieldSettings, field.TypeString, value)
}
if iu.mutation.SettingsCleared() {
_spec.ClearField(indexers.FieldSettings, field.TypeString)
}
if value, ok := iu.mutation.EnableRss(); ok {
_spec.SetField(indexers.FieldEnableRss, field.TypeBool, value)
}
@@ -225,6 +334,36 @@ func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) {
if iu.mutation.DisabledCleared() {
_spec.ClearField(indexers.FieldDisabled, field.TypeBool)
}
if value, ok := iu.mutation.TvSearch(); ok {
_spec.SetField(indexers.FieldTvSearch, field.TypeBool, value)
}
if iu.mutation.TvSearchCleared() {
_spec.ClearField(indexers.FieldTvSearch, field.TypeBool)
}
if value, ok := iu.mutation.MovieSearch(); ok {
_spec.SetField(indexers.FieldMovieSearch, field.TypeBool, value)
}
if iu.mutation.MovieSearchCleared() {
_spec.ClearField(indexers.FieldMovieSearch, field.TypeBool)
}
if value, ok := iu.mutation.APIKey(); ok {
_spec.SetField(indexers.FieldAPIKey, field.TypeString, value)
}
if iu.mutation.APIKeyCleared() {
_spec.ClearField(indexers.FieldAPIKey, field.TypeString)
}
if value, ok := iu.mutation.URL(); ok {
_spec.SetField(indexers.FieldURL, field.TypeString, value)
}
if iu.mutation.URLCleared() {
_spec.ClearField(indexers.FieldURL, field.TypeString)
}
if value, ok := iu.mutation.Synced(); ok {
_spec.SetField(indexers.FieldSynced, field.TypeBool, value)
}
if iu.mutation.SyncedCleared() {
_spec.ClearField(indexers.FieldSynced, field.TypeBool)
}
if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{indexers.Label}
@@ -287,6 +426,12 @@ func (iuo *IndexersUpdateOne) SetNillableSettings(s *string) *IndexersUpdateOne
return iuo
}
// ClearSettings clears the value of the "settings" field.
func (iuo *IndexersUpdateOne) ClearSettings() *IndexersUpdateOne {
iuo.mutation.ClearSettings()
return iuo
}
// SetEnableRss sets the "enable_rss" field.
func (iuo *IndexersUpdateOne) SetEnableRss(b bool) *IndexersUpdateOne {
iuo.mutation.SetEnableRss(b)
@@ -369,6 +514,106 @@ func (iuo *IndexersUpdateOne) ClearDisabled() *IndexersUpdateOne {
return iuo
}
// SetTvSearch sets the "tv_search" field.
func (iuo *IndexersUpdateOne) SetTvSearch(b bool) *IndexersUpdateOne {
iuo.mutation.SetTvSearch(b)
return iuo
}
// SetNillableTvSearch sets the "tv_search" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableTvSearch(b *bool) *IndexersUpdateOne {
if b != nil {
iuo.SetTvSearch(*b)
}
return iuo
}
// ClearTvSearch clears the value of the "tv_search" field.
func (iuo *IndexersUpdateOne) ClearTvSearch() *IndexersUpdateOne {
iuo.mutation.ClearTvSearch()
return iuo
}
// SetMovieSearch sets the "movie_search" field.
func (iuo *IndexersUpdateOne) SetMovieSearch(b bool) *IndexersUpdateOne {
iuo.mutation.SetMovieSearch(b)
return iuo
}
// SetNillableMovieSearch sets the "movie_search" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableMovieSearch(b *bool) *IndexersUpdateOne {
if b != nil {
iuo.SetMovieSearch(*b)
}
return iuo
}
// ClearMovieSearch clears the value of the "movie_search" field.
func (iuo *IndexersUpdateOne) ClearMovieSearch() *IndexersUpdateOne {
iuo.mutation.ClearMovieSearch()
return iuo
}
// SetAPIKey sets the "api_key" field.
func (iuo *IndexersUpdateOne) SetAPIKey(s string) *IndexersUpdateOne {
iuo.mutation.SetAPIKey(s)
return iuo
}
// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableAPIKey(s *string) *IndexersUpdateOne {
if s != nil {
iuo.SetAPIKey(*s)
}
return iuo
}
// ClearAPIKey clears the value of the "api_key" field.
func (iuo *IndexersUpdateOne) ClearAPIKey() *IndexersUpdateOne {
iuo.mutation.ClearAPIKey()
return iuo
}
// SetURL sets the "url" field.
func (iuo *IndexersUpdateOne) SetURL(s string) *IndexersUpdateOne {
iuo.mutation.SetURL(s)
return iuo
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableURL(s *string) *IndexersUpdateOne {
if s != nil {
iuo.SetURL(*s)
}
return iuo
}
// ClearURL clears the value of the "url" field.
func (iuo *IndexersUpdateOne) ClearURL() *IndexersUpdateOne {
iuo.mutation.ClearURL()
return iuo
}
// SetSynced sets the "synced" field.
func (iuo *IndexersUpdateOne) SetSynced(b bool) *IndexersUpdateOne {
iuo.mutation.SetSynced(b)
return iuo
}
// SetNillableSynced sets the "synced" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableSynced(b *bool) *IndexersUpdateOne {
if b != nil {
iuo.SetSynced(*b)
}
return iuo
}
// ClearSynced clears the value of the "synced" field.
func (iuo *IndexersUpdateOne) ClearSynced() *IndexersUpdateOne {
iuo.mutation.ClearSynced()
return iuo
}
// Mutation returns the IndexersMutation object of the builder.
func (iuo *IndexersUpdateOne) Mutation() *IndexersMutation {
return iuo.mutation
@@ -449,6 +694,9 @@ func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err
if value, ok := iuo.mutation.Settings(); ok {
_spec.SetField(indexers.FieldSettings, field.TypeString, value)
}
if iuo.mutation.SettingsCleared() {
_spec.ClearField(indexers.FieldSettings, field.TypeString)
}
if value, ok := iuo.mutation.EnableRss(); ok {
_spec.SetField(indexers.FieldEnableRss, field.TypeBool, value)
}
@@ -473,6 +721,36 @@ func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err
if iuo.mutation.DisabledCleared() {
_spec.ClearField(indexers.FieldDisabled, field.TypeBool)
}
if value, ok := iuo.mutation.TvSearch(); ok {
_spec.SetField(indexers.FieldTvSearch, field.TypeBool, value)
}
if iuo.mutation.TvSearchCleared() {
_spec.ClearField(indexers.FieldTvSearch, field.TypeBool)
}
if value, ok := iuo.mutation.MovieSearch(); ok {
_spec.SetField(indexers.FieldMovieSearch, field.TypeBool, value)
}
if iuo.mutation.MovieSearchCleared() {
_spec.ClearField(indexers.FieldMovieSearch, field.TypeBool)
}
if value, ok := iuo.mutation.APIKey(); ok {
_spec.SetField(indexers.FieldAPIKey, field.TypeString, value)
}
if iuo.mutation.APIKeyCleared() {
_spec.ClearField(indexers.FieldAPIKey, field.TypeString)
}
if value, ok := iuo.mutation.URL(); ok {
_spec.SetField(indexers.FieldURL, field.TypeString, value)
}
if iuo.mutation.URLCleared() {
_spec.ClearField(indexers.FieldURL, field.TypeString)
}
if value, ok := iuo.mutation.Synced(); ok {
_spec.SetField(indexers.FieldSynced, field.TypeBool, value)
}
if iuo.mutation.SyncedCleared() {
_spec.ClearField(indexers.FieldSynced, field.TypeBool)
}
_node = &Indexers{config: iuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues

View File

@@ -73,7 +73,6 @@ var (
HistoriesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "media_id", Type: field.TypeInt},
{Name: "episode_id", Type: field.TypeInt, Nullable: true},
{Name: "episode_nums", Type: field.TypeJSON, Nullable: true},
{Name: "season_num", Type: field.TypeInt, Nullable: true},
{Name: "source_title", Type: field.TypeString},
@@ -83,8 +82,8 @@ var (
{Name: "download_client_id", Type: field.TypeInt, Nullable: true},
{Name: "indexer_id", Type: field.TypeInt, Nullable: true},
{Name: "link", Type: field.TypeString, Nullable: true},
{Name: "hash", Type: field.TypeString, Nullable: true},
{Name: "status", Type: field.TypeEnum, Enums: []string{"running", "success", "fail", "uploading", "seeding"}},
{Name: "saved", Type: field.TypeString, Nullable: true},
}
// HistoriesTable holds the schema information for the "histories" table.
HistoriesTable = &schema.Table{
@@ -113,11 +112,16 @@ var (
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString},
{Name: "implementation", Type: field.TypeString},
{Name: "settings", Type: field.TypeString},
{Name: "settings", Type: field.TypeString, Nullable: true, Default: ""},
{Name: "enable_rss", Type: field.TypeBool, Default: true},
{Name: "priority", Type: field.TypeInt, Default: 50},
{Name: "seed_ratio", Type: field.TypeFloat32, Nullable: true, Default: 0},
{Name: "disabled", Type: field.TypeBool, Nullable: true, Default: false},
{Name: "tv_search", Type: field.TypeBool, Nullable: true, Default: true},
{Name: "movie_search", Type: field.TypeBool, Nullable: true, Default: true},
{Name: "api_key", Type: field.TypeString, Nullable: true},
{Name: "url", Type: field.TypeString, Nullable: true},
{Name: "synced", Type: field.TypeBool, Nullable: true, Default: false},
}
// IndexersTable holds the schema information for the "indexers" table.
IndexersTable = &schema.Table{

View File

@@ -2334,8 +2334,6 @@ type HistoryMutation struct {
id *int
media_id *int
addmedia_id *int
episode_id *int
addepisode_id *int
episode_nums *[]int
appendepisode_nums []int
season_num *int
@@ -2350,8 +2348,8 @@ type HistoryMutation struct {
indexer_id *int
addindexer_id *int
link *string
hash *string
status *history.Status
saved *string
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*History, error)
@@ -2512,76 +2510,6 @@ func (m *HistoryMutation) ResetMediaID() {
m.addmedia_id = nil
}
// SetEpisodeID sets the "episode_id" field.
func (m *HistoryMutation) SetEpisodeID(i int) {
m.episode_id = &i
m.addepisode_id = nil
}
// EpisodeID returns the value of the "episode_id" field in the mutation.
func (m *HistoryMutation) EpisodeID() (r int, exists bool) {
v := m.episode_id
if v == nil {
return
}
return *v, true
}
// OldEpisodeID returns the old "episode_id" field's value of the History entity.
// If the History object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *HistoryMutation) OldEpisodeID(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEpisodeID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEpisodeID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEpisodeID: %w", err)
}
return oldValue.EpisodeID, nil
}
// AddEpisodeID adds i to the "episode_id" field.
func (m *HistoryMutation) AddEpisodeID(i int) {
if m.addepisode_id != nil {
*m.addepisode_id += i
} else {
m.addepisode_id = &i
}
}
// AddedEpisodeID returns the value that was added to the "episode_id" field in this mutation.
func (m *HistoryMutation) AddedEpisodeID() (r int, exists bool) {
v := m.addepisode_id
if v == nil {
return
}
return *v, true
}
// ClearEpisodeID clears the value of the "episode_id" field.
func (m *HistoryMutation) ClearEpisodeID() {
m.episode_id = nil
m.addepisode_id = nil
m.clearedFields[history.FieldEpisodeID] = struct{}{}
}
// EpisodeIDCleared returns if the "episode_id" field was cleared in this mutation.
func (m *HistoryMutation) EpisodeIDCleared() bool {
_, ok := m.clearedFields[history.FieldEpisodeID]
return ok
}
// ResetEpisodeID resets all changes to the "episode_id" field.
func (m *HistoryMutation) ResetEpisodeID() {
m.episode_id = nil
m.addepisode_id = nil
delete(m.clearedFields, history.FieldEpisodeID)
}
// SetEpisodeNums sets the "episode_nums" field.
func (m *HistoryMutation) SetEpisodeNums(i []int) {
m.episode_nums = &i
@@ -3070,6 +2998,55 @@ func (m *HistoryMutation) ResetLink() {
delete(m.clearedFields, history.FieldLink)
}
// SetHash sets the "hash" field.
func (m *HistoryMutation) SetHash(s string) {
m.hash = &s
}
// Hash returns the value of the "hash" field in the mutation.
func (m *HistoryMutation) Hash() (r string, exists bool) {
v := m.hash
if v == nil {
return
}
return *v, true
}
// OldHash returns the old "hash" field's value of the History entity.
// If the History object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *HistoryMutation) OldHash(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHash is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHash requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHash: %w", err)
}
return oldValue.Hash, nil
}
// ClearHash clears the value of the "hash" field.
func (m *HistoryMutation) ClearHash() {
m.hash = nil
m.clearedFields[history.FieldHash] = struct{}{}
}
// HashCleared returns if the "hash" field was cleared in this mutation.
func (m *HistoryMutation) HashCleared() bool {
_, ok := m.clearedFields[history.FieldHash]
return ok
}
// ResetHash resets all changes to the "hash" field.
func (m *HistoryMutation) ResetHash() {
m.hash = nil
delete(m.clearedFields, history.FieldHash)
}
// SetStatus sets the "status" field.
func (m *HistoryMutation) SetStatus(h history.Status) {
m.status = &h
@@ -3106,55 +3083,6 @@ func (m *HistoryMutation) ResetStatus() {
m.status = nil
}
// SetSaved sets the "saved" field.
func (m *HistoryMutation) SetSaved(s string) {
m.saved = &s
}
// Saved returns the value of the "saved" field in the mutation.
func (m *HistoryMutation) Saved() (r string, exists bool) {
v := m.saved
if v == nil {
return
}
return *v, true
}
// OldSaved returns the old "saved" field's value of the History entity.
// If the History object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *HistoryMutation) OldSaved(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSaved is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSaved requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSaved: %w", err)
}
return oldValue.Saved, nil
}
// ClearSaved clears the value of the "saved" field.
func (m *HistoryMutation) ClearSaved() {
m.saved = nil
m.clearedFields[history.FieldSaved] = struct{}{}
}
// SavedCleared returns if the "saved" field was cleared in this mutation.
func (m *HistoryMutation) SavedCleared() bool {
_, ok := m.clearedFields[history.FieldSaved]
return ok
}
// ResetSaved resets all changes to the "saved" field.
func (m *HistoryMutation) ResetSaved() {
m.saved = nil
delete(m.clearedFields, history.FieldSaved)
}
// Where appends a list predicates to the HistoryMutation builder.
func (m *HistoryMutation) Where(ps ...predicate.History) {
m.predicates = append(m.predicates, ps...)
@@ -3189,13 +3117,10 @@ func (m *HistoryMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *HistoryMutation) Fields() []string {
fields := make([]string, 0, 13)
fields := make([]string, 0, 12)
if m.media_id != nil {
fields = append(fields, history.FieldMediaID)
}
if m.episode_id != nil {
fields = append(fields, history.FieldEpisodeID)
}
if m.episode_nums != nil {
fields = append(fields, history.FieldEpisodeNums)
}
@@ -3223,12 +3148,12 @@ func (m *HistoryMutation) Fields() []string {
if m.link != nil {
fields = append(fields, history.FieldLink)
}
if m.hash != nil {
fields = append(fields, history.FieldHash)
}
if m.status != nil {
fields = append(fields, history.FieldStatus)
}
if m.saved != nil {
fields = append(fields, history.FieldSaved)
}
return fields
}
@@ -3239,8 +3164,6 @@ func (m *HistoryMutation) Field(name string) (ent.Value, bool) {
switch name {
case history.FieldMediaID:
return m.MediaID()
case history.FieldEpisodeID:
return m.EpisodeID()
case history.FieldEpisodeNums:
return m.EpisodeNums()
case history.FieldSeasonNum:
@@ -3259,10 +3182,10 @@ func (m *HistoryMutation) Field(name string) (ent.Value, bool) {
return m.IndexerID()
case history.FieldLink:
return m.Link()
case history.FieldHash:
return m.Hash()
case history.FieldStatus:
return m.Status()
case history.FieldSaved:
return m.Saved()
}
return nil, false
}
@@ -3274,8 +3197,6 @@ func (m *HistoryMutation) OldField(ctx context.Context, name string) (ent.Value,
switch name {
case history.FieldMediaID:
return m.OldMediaID(ctx)
case history.FieldEpisodeID:
return m.OldEpisodeID(ctx)
case history.FieldEpisodeNums:
return m.OldEpisodeNums(ctx)
case history.FieldSeasonNum:
@@ -3294,10 +3215,10 @@ func (m *HistoryMutation) OldField(ctx context.Context, name string) (ent.Value,
return m.OldIndexerID(ctx)
case history.FieldLink:
return m.OldLink(ctx)
case history.FieldHash:
return m.OldHash(ctx)
case history.FieldStatus:
return m.OldStatus(ctx)
case history.FieldSaved:
return m.OldSaved(ctx)
}
return nil, fmt.Errorf("unknown History field %s", name)
}
@@ -3314,13 +3235,6 @@ func (m *HistoryMutation) SetField(name string, value ent.Value) error {
}
m.SetMediaID(v)
return nil
case history.FieldEpisodeID:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEpisodeID(v)
return nil
case history.FieldEpisodeNums:
v, ok := value.([]int)
if !ok {
@@ -3384,6 +3298,13 @@ func (m *HistoryMutation) SetField(name string, value ent.Value) error {
}
m.SetLink(v)
return nil
case history.FieldHash:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHash(v)
return nil
case history.FieldStatus:
v, ok := value.(history.Status)
if !ok {
@@ -3391,13 +3312,6 @@ func (m *HistoryMutation) SetField(name string, value ent.Value) error {
}
m.SetStatus(v)
return nil
case history.FieldSaved:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSaved(v)
return nil
}
return fmt.Errorf("unknown History field %s", name)
}
@@ -3409,9 +3323,6 @@ func (m *HistoryMutation) AddedFields() []string {
if m.addmedia_id != nil {
fields = append(fields, history.FieldMediaID)
}
if m.addepisode_id != nil {
fields = append(fields, history.FieldEpisodeID)
}
if m.addseason_num != nil {
fields = append(fields, history.FieldSeasonNum)
}
@@ -3434,8 +3345,6 @@ func (m *HistoryMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case history.FieldMediaID:
return m.AddedMediaID()
case history.FieldEpisodeID:
return m.AddedEpisodeID()
case history.FieldSeasonNum:
return m.AddedSeasonNum()
case history.FieldSize:
@@ -3460,13 +3369,6 @@ func (m *HistoryMutation) AddField(name string, value ent.Value) error {
}
m.AddMediaID(v)
return nil
case history.FieldEpisodeID:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddEpisodeID(v)
return nil
case history.FieldSeasonNum:
v, ok := value.(int)
if !ok {
@@ -3503,9 +3405,6 @@ func (m *HistoryMutation) AddField(name string, value ent.Value) error {
// mutation.
func (m *HistoryMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(history.FieldEpisodeID) {
fields = append(fields, history.FieldEpisodeID)
}
if m.FieldCleared(history.FieldEpisodeNums) {
fields = append(fields, history.FieldEpisodeNums)
}
@@ -3521,8 +3420,8 @@ func (m *HistoryMutation) ClearedFields() []string {
if m.FieldCleared(history.FieldLink) {
fields = append(fields, history.FieldLink)
}
if m.FieldCleared(history.FieldSaved) {
fields = append(fields, history.FieldSaved)
if m.FieldCleared(history.FieldHash) {
fields = append(fields, history.FieldHash)
}
return fields
}
@@ -3538,9 +3437,6 @@ func (m *HistoryMutation) FieldCleared(name string) bool {
// error if the field is not defined in the schema.
func (m *HistoryMutation) ClearField(name string) error {
switch name {
case history.FieldEpisodeID:
m.ClearEpisodeID()
return nil
case history.FieldEpisodeNums:
m.ClearEpisodeNums()
return nil
@@ -3556,8 +3452,8 @@ func (m *HistoryMutation) ClearField(name string) error {
case history.FieldLink:
m.ClearLink()
return nil
case history.FieldSaved:
m.ClearSaved()
case history.FieldHash:
m.ClearHash()
return nil
}
return fmt.Errorf("unknown History nullable field %s", name)
@@ -3570,9 +3466,6 @@ func (m *HistoryMutation) ResetField(name string) error {
case history.FieldMediaID:
m.ResetMediaID()
return nil
case history.FieldEpisodeID:
m.ResetEpisodeID()
return nil
case history.FieldEpisodeNums:
m.ResetEpisodeNums()
return nil
@@ -3600,12 +3493,12 @@ func (m *HistoryMutation) ResetField(name string) error {
case history.FieldLink:
m.ResetLink()
return nil
case history.FieldHash:
m.ResetHash()
return nil
case history.FieldStatus:
m.ResetStatus()
return nil
case history.FieldSaved:
m.ResetSaved()
return nil
}
return fmt.Errorf("unknown History field %s", name)
}
@@ -4346,6 +4239,11 @@ type IndexersMutation struct {
seed_ratio *float32
addseed_ratio *float32
disabled *bool
tv_search *bool
movie_search *bool
api_key *string
url *string
synced *bool
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*Indexers, error)
@@ -4553,9 +4451,22 @@ func (m *IndexersMutation) OldSettings(ctx context.Context) (v string, err error
return oldValue.Settings, nil
}
// ClearSettings clears the value of the "settings" field.
func (m *IndexersMutation) ClearSettings() {
m.settings = nil
m.clearedFields[indexers.FieldSettings] = struct{}{}
}
// SettingsCleared returns if the "settings" field was cleared in this mutation.
func (m *IndexersMutation) SettingsCleared() bool {
_, ok := m.clearedFields[indexers.FieldSettings]
return ok
}
// ResetSettings resets all changes to the "settings" field.
func (m *IndexersMutation) ResetSettings() {
m.settings = nil
delete(m.clearedFields, indexers.FieldSettings)
}
// SetEnableRss sets the "enable_rss" field.
@@ -4769,6 +4680,251 @@ func (m *IndexersMutation) ResetDisabled() {
delete(m.clearedFields, indexers.FieldDisabled)
}
// SetTvSearch sets the "tv_search" field.
func (m *IndexersMutation) SetTvSearch(b bool) {
m.tv_search = &b
}
// TvSearch returns the value of the "tv_search" field in the mutation.
func (m *IndexersMutation) TvSearch() (r bool, exists bool) {
v := m.tv_search
if v == nil {
return
}
return *v, true
}
// OldTvSearch returns the old "tv_search" field's value of the Indexers entity.
// If the Indexers object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IndexersMutation) OldTvSearch(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTvSearch is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTvSearch requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTvSearch: %w", err)
}
return oldValue.TvSearch, nil
}
// ClearTvSearch clears the value of the "tv_search" field.
func (m *IndexersMutation) ClearTvSearch() {
m.tv_search = nil
m.clearedFields[indexers.FieldTvSearch] = struct{}{}
}
// TvSearchCleared returns if the "tv_search" field was cleared in this mutation.
func (m *IndexersMutation) TvSearchCleared() bool {
_, ok := m.clearedFields[indexers.FieldTvSearch]
return ok
}
// ResetTvSearch resets all changes to the "tv_search" field.
func (m *IndexersMutation) ResetTvSearch() {
m.tv_search = nil
delete(m.clearedFields, indexers.FieldTvSearch)
}
// SetMovieSearch sets the "movie_search" field.
func (m *IndexersMutation) SetMovieSearch(b bool) {
m.movie_search = &b
}
// MovieSearch returns the value of the "movie_search" field in the mutation.
func (m *IndexersMutation) MovieSearch() (r bool, exists bool) {
v := m.movie_search
if v == nil {
return
}
return *v, true
}
// OldMovieSearch returns the old "movie_search" field's value of the Indexers entity.
// If the Indexers object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IndexersMutation) OldMovieSearch(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMovieSearch is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMovieSearch requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMovieSearch: %w", err)
}
return oldValue.MovieSearch, nil
}
// ClearMovieSearch clears the value of the "movie_search" field.
func (m *IndexersMutation) ClearMovieSearch() {
m.movie_search = nil
m.clearedFields[indexers.FieldMovieSearch] = struct{}{}
}
// MovieSearchCleared returns if the "movie_search" field was cleared in this mutation.
func (m *IndexersMutation) MovieSearchCleared() bool {
_, ok := m.clearedFields[indexers.FieldMovieSearch]
return ok
}
// ResetMovieSearch resets all changes to the "movie_search" field.
func (m *IndexersMutation) ResetMovieSearch() {
m.movie_search = nil
delete(m.clearedFields, indexers.FieldMovieSearch)
}
// SetAPIKey sets the "api_key" field.
func (m *IndexersMutation) SetAPIKey(s string) {
m.api_key = &s
}
// APIKey returns the value of the "api_key" field in the mutation.
func (m *IndexersMutation) APIKey() (r string, exists bool) {
v := m.api_key
if v == nil {
return
}
return *v, true
}
// OldAPIKey returns the old "api_key" field's value of the Indexers entity.
// If the Indexers object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IndexersMutation) OldAPIKey(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAPIKey requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
}
return oldValue.APIKey, nil
}
// ClearAPIKey clears the value of the "api_key" field.
func (m *IndexersMutation) ClearAPIKey() {
m.api_key = nil
m.clearedFields[indexers.FieldAPIKey] = struct{}{}
}
// APIKeyCleared returns if the "api_key" field was cleared in this mutation.
func (m *IndexersMutation) APIKeyCleared() bool {
_, ok := m.clearedFields[indexers.FieldAPIKey]
return ok
}
// ResetAPIKey resets all changes to the "api_key" field.
func (m *IndexersMutation) ResetAPIKey() {
m.api_key = nil
delete(m.clearedFields, indexers.FieldAPIKey)
}
// SetURL sets the "url" field.
func (m *IndexersMutation) SetURL(s string) {
m.url = &s
}
// URL returns the value of the "url" field in the mutation.
func (m *IndexersMutation) URL() (r string, exists bool) {
v := m.url
if v == nil {
return
}
return *v, true
}
// OldURL returns the old "url" field's value of the Indexers entity.
// If the Indexers object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IndexersMutation) OldURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldURL: %w", err)
}
return oldValue.URL, nil
}
// ClearURL clears the value of the "url" field.
func (m *IndexersMutation) ClearURL() {
m.url = nil
m.clearedFields[indexers.FieldURL] = struct{}{}
}
// URLCleared returns if the "url" field was cleared in this mutation.
func (m *IndexersMutation) URLCleared() bool {
_, ok := m.clearedFields[indexers.FieldURL]
return ok
}
// ResetURL resets all changes to the "url" field.
func (m *IndexersMutation) ResetURL() {
m.url = nil
delete(m.clearedFields, indexers.FieldURL)
}
// SetSynced sets the "synced" field.
func (m *IndexersMutation) SetSynced(b bool) {
m.synced = &b
}
// Synced returns the value of the "synced" field in the mutation.
func (m *IndexersMutation) Synced() (r bool, exists bool) {
v := m.synced
if v == nil {
return
}
return *v, true
}
// OldSynced returns the old "synced" field's value of the Indexers entity.
// If the Indexers object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IndexersMutation) OldSynced(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSynced is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSynced requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSynced: %w", err)
}
return oldValue.Synced, nil
}
// ClearSynced clears the value of the "synced" field.
func (m *IndexersMutation) ClearSynced() {
m.synced = nil
m.clearedFields[indexers.FieldSynced] = struct{}{}
}
// SyncedCleared returns if the "synced" field was cleared in this mutation.
func (m *IndexersMutation) SyncedCleared() bool {
_, ok := m.clearedFields[indexers.FieldSynced]
return ok
}
// ResetSynced resets all changes to the "synced" field.
func (m *IndexersMutation) ResetSynced() {
m.synced = nil
delete(m.clearedFields, indexers.FieldSynced)
}
// Where appends a list predicates to the IndexersMutation builder.
func (m *IndexersMutation) Where(ps ...predicate.Indexers) {
m.predicates = append(m.predicates, ps...)
@@ -4803,7 +4959,7 @@ func (m *IndexersMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *IndexersMutation) Fields() []string {
fields := make([]string, 0, 7)
fields := make([]string, 0, 12)
if m.name != nil {
fields = append(fields, indexers.FieldName)
}
@@ -4825,6 +4981,21 @@ func (m *IndexersMutation) Fields() []string {
if m.disabled != nil {
fields = append(fields, indexers.FieldDisabled)
}
if m.tv_search != nil {
fields = append(fields, indexers.FieldTvSearch)
}
if m.movie_search != nil {
fields = append(fields, indexers.FieldMovieSearch)
}
if m.api_key != nil {
fields = append(fields, indexers.FieldAPIKey)
}
if m.url != nil {
fields = append(fields, indexers.FieldURL)
}
if m.synced != nil {
fields = append(fields, indexers.FieldSynced)
}
return fields
}
@@ -4847,6 +5018,16 @@ func (m *IndexersMutation) Field(name string) (ent.Value, bool) {
return m.SeedRatio()
case indexers.FieldDisabled:
return m.Disabled()
case indexers.FieldTvSearch:
return m.TvSearch()
case indexers.FieldMovieSearch:
return m.MovieSearch()
case indexers.FieldAPIKey:
return m.APIKey()
case indexers.FieldURL:
return m.URL()
case indexers.FieldSynced:
return m.Synced()
}
return nil, false
}
@@ -4870,6 +5051,16 @@ func (m *IndexersMutation) OldField(ctx context.Context, name string) (ent.Value
return m.OldSeedRatio(ctx)
case indexers.FieldDisabled:
return m.OldDisabled(ctx)
case indexers.FieldTvSearch:
return m.OldTvSearch(ctx)
case indexers.FieldMovieSearch:
return m.OldMovieSearch(ctx)
case indexers.FieldAPIKey:
return m.OldAPIKey(ctx)
case indexers.FieldURL:
return m.OldURL(ctx)
case indexers.FieldSynced:
return m.OldSynced(ctx)
}
return nil, fmt.Errorf("unknown Indexers field %s", name)
}
@@ -4928,6 +5119,41 @@ func (m *IndexersMutation) SetField(name string, value ent.Value) error {
}
m.SetDisabled(v)
return nil
case indexers.FieldTvSearch:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTvSearch(v)
return nil
case indexers.FieldMovieSearch:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMovieSearch(v)
return nil
case indexers.FieldAPIKey:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAPIKey(v)
return nil
case indexers.FieldURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetURL(v)
return nil
case indexers.FieldSynced:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSynced(v)
return nil
}
return fmt.Errorf("unknown Indexers field %s", name)
}
@@ -4985,12 +5211,30 @@ func (m *IndexersMutation) AddField(name string, value ent.Value) error {
// mutation.
func (m *IndexersMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(indexers.FieldSettings) {
fields = append(fields, indexers.FieldSettings)
}
if m.FieldCleared(indexers.FieldSeedRatio) {
fields = append(fields, indexers.FieldSeedRatio)
}
if m.FieldCleared(indexers.FieldDisabled) {
fields = append(fields, indexers.FieldDisabled)
}
if m.FieldCleared(indexers.FieldTvSearch) {
fields = append(fields, indexers.FieldTvSearch)
}
if m.FieldCleared(indexers.FieldMovieSearch) {
fields = append(fields, indexers.FieldMovieSearch)
}
if m.FieldCleared(indexers.FieldAPIKey) {
fields = append(fields, indexers.FieldAPIKey)
}
if m.FieldCleared(indexers.FieldURL) {
fields = append(fields, indexers.FieldURL)
}
if m.FieldCleared(indexers.FieldSynced) {
fields = append(fields, indexers.FieldSynced)
}
return fields
}
@@ -5005,12 +5249,30 @@ func (m *IndexersMutation) FieldCleared(name string) bool {
// error if the field is not defined in the schema.
func (m *IndexersMutation) ClearField(name string) error {
switch name {
case indexers.FieldSettings:
m.ClearSettings()
return nil
case indexers.FieldSeedRatio:
m.ClearSeedRatio()
return nil
case indexers.FieldDisabled:
m.ClearDisabled()
return nil
case indexers.FieldTvSearch:
m.ClearTvSearch()
return nil
case indexers.FieldMovieSearch:
m.ClearMovieSearch()
return nil
case indexers.FieldAPIKey:
m.ClearAPIKey()
return nil
case indexers.FieldURL:
m.ClearURL()
return nil
case indexers.FieldSynced:
m.ClearSynced()
return nil
}
return fmt.Errorf("unknown Indexers nullable field %s", name)
}
@@ -5040,6 +5302,21 @@ func (m *IndexersMutation) ResetField(name string) error {
case indexers.FieldDisabled:
m.ResetDisabled()
return nil
case indexers.FieldTvSearch:
m.ResetTvSearch()
return nil
case indexers.FieldMovieSearch:
m.ResetMovieSearch()
return nil
case indexers.FieldAPIKey:
m.ResetAPIKey()
return nil
case indexers.FieldURL:
m.ResetURL()
return nil
case indexers.FieldSynced:
m.ResetSynced()
return nil
}
return fmt.Errorf("unknown Indexers field %s", name)
}

View File

@@ -66,11 +66,15 @@ func init() {
historyFields := schema.History{}.Fields()
_ = historyFields
// historyDescSize is the schema descriptor for size field.
historyDescSize := historyFields[7].Descriptor()
historyDescSize := historyFields[6].Descriptor()
// history.DefaultSize holds the default value on creation for the size field.
history.DefaultSize = historyDescSize.Default.(int)
indexersFields := schema.Indexers{}.Fields()
_ = indexersFields
// indexersDescSettings is the schema descriptor for settings field.
indexersDescSettings := indexersFields[2].Descriptor()
// indexers.DefaultSettings holds the default value on creation for the settings field.
indexers.DefaultSettings = indexersDescSettings.Default.(string)
// indexersDescEnableRss is the schema descriptor for enable_rss field.
indexersDescEnableRss := indexersFields[3].Descriptor()
// indexers.DefaultEnableRss holds the default value on creation for the enable_rss field.
@@ -87,6 +91,18 @@ func init() {
indexersDescDisabled := indexersFields[6].Descriptor()
// indexers.DefaultDisabled holds the default value on creation for the disabled field.
indexers.DefaultDisabled = indexersDescDisabled.Default.(bool)
// indexersDescTvSearch is the schema descriptor for tv_search field.
indexersDescTvSearch := indexersFields[7].Descriptor()
// indexers.DefaultTvSearch holds the default value on creation for the tv_search field.
indexers.DefaultTvSearch = indexersDescTvSearch.Default.(bool)
// indexersDescMovieSearch is the schema descriptor for movie_search field.
indexersDescMovieSearch := indexersFields[8].Descriptor()
// indexers.DefaultMovieSearch holds the default value on creation for the movie_search field.
indexers.DefaultMovieSearch = indexersDescMovieSearch.Default.(bool)
// indexersDescSynced is the schema descriptor for synced field.
indexersDescSynced := indexersFields[11].Descriptor()
// indexers.DefaultSynced holds the default value on creation for the synced field.
indexers.DefaultSynced = indexersDescSynced.Default.(bool)
mediaFields := schema.Media{}.Fields()
_ = mediaFields
// mediaDescCreatedAt is the schema descriptor for created_at field.

View File

@@ -14,7 +14,7 @@ type History struct {
func (History) Fields() []ent.Field {
return []ent.Field{
field.Int("media_id"),
field.Int("episode_id").Optional().Comment("deprecated"),
//field.Int("episode_id").Optional().Comment("deprecated"),
field.Ints("episode_nums").Optional(),
field.Int("season_num").Optional(),
field.String("source_title"),
@@ -23,9 +23,10 @@ func (History) Fields() []ent.Field {
field.Int("size").Default(0),
field.Int("download_client_id").Optional(),
field.Int("indexer_id").Optional(),
field.String("link").Optional(), //should be magnet link
field.String("link").Optional().Comment("deprecated, use hash instead"), //should be magnet link
field.String("hash").Optional().Comment("torrent hash"),
field.Enum("status").Values("running", "success", "fail", "uploading", "seeding"),
field.String("saved").Optional().Comment("deprecated"), //deprecated
//field.String("saved").Optional().Comment("deprecated"), //deprecated
}
}

View File

@@ -15,11 +15,16 @@ func (Indexers) Fields() []ent.Field {
return []ent.Field{
field.String("name"),
field.String("implementation"),
field.String("settings"),
field.String("settings").Optional().Default("").Comment("deprecated, use api_key and url"),
field.Bool("enable_rss").Default(true),
field.Int("priority").Default(50),
field.Float32("seed_ratio").Optional().Default(0).Comment("minimal seed ratio requied, before removing torrent"),
field.Bool("disabled").Optional().Default(false),
field.Bool("tv_search").Optional().Default(true),
field.Bool("movie_search").Optional().Default(true),
field.String("api_key").Optional(),
field.String("url").Optional(),
field.Bool("synced").Optional().Default(false).Comment("synced from prowlarr"),
}
}

27
go.mod
View File

@@ -10,14 +10,15 @@ require (
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/robfig/cron v1.2.0
go.uber.org/zap v1.27.0
golang.org/x/net v0.33.0
golang.org/x/net v0.34.0
)
require (
github.com/PuerkitoBio/goquery v1.9.2
github.com/PuerkitoBio/goquery v1.10.1
github.com/anacrolix/torrent v1.57.1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/gin-contrib/zap v1.1.3
github.com/gocolly/colly v1.2.0
github.com/ncruces/go-sqlite3 v0.18.4
github.com/nikoksr/notify v1.0.0
github.com/stretchr/testify v1.9.0
@@ -30,24 +31,34 @@ require (
github.com/anacrolix/generics v0.0.3-0.20240902042256-7fb2702ef0ca // indirect
github.com/anacrolix/missinggo v1.3.0 // indirect
github.com/anacrolix/missinggo/v2 v2.7.4 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/antchfx/htmlquery v1.3.4 // indirect
github.com/antchfx/xmlquery v1.4.4 // indirect
github.com/antchfx/xpath v1.3.3 // indirect
github.com/blinkbean/dingtalk v1.1.3 // indirect
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect
github.com/go-test/deep v1.0.4 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/gregdel/pushover v1.3.1 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/ncruces/julianday v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
github.com/temoto/robotstxt v1.1.2 // indirect
github.com/tetratelabs/wazero v1.8.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sync v0.11.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
lukechampine.com/blake3 v1.1.6 // indirect
@@ -95,12 +106,12 @@ require (
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/zclconf/go-cty v1.8.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.31.0
golang.org/x/crypto v0.32.0
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948
golang.org/x/mod v0.20.0 // indirect
golang.org/x/sys v0.28.0
golang.org/x/text v0.21.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/sys v0.29.0
golang.org/x/text v0.22.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

87
go.sum
View File

@@ -11,8 +11,8 @@ github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE=
github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk=
github.com/PuerkitoBio/goquery v1.10.1 h1:Y8JGYUkXWTGRB6Ars3+j3kN0xg1YqqlwvdTV8WTFQcU=
github.com/PuerkitoBio/goquery v1.10.1/go.mod h1:IYiHrOMps66ag56LEH7QYDDupKXyo5A8qrjIx3ZtujY=
github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w=
github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrXIr8KVNvRsDi1NI=
github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo=
@@ -49,8 +49,14 @@ github.com/anacrolix/tagflag v1.0.0/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pm
github.com/anacrolix/tagflag v1.1.0/go.mod h1:Scxs9CV10NQatSmbyjqmqmeQNwGzlNe0CMUMIxqHIG8=
github.com/anacrolix/torrent v1.57.1 h1:CS8rYfC2Oe15NPBhwCNs/3WBY6HiBCPDFpY+s9aFHbA=
github.com/anacrolix/torrent v1.57.1/go.mod h1:NNBg4lP2/us9Hp5+cLNcZRILM69cNoKIkqMGqr9AuR0=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
github.com/antchfx/htmlquery v1.3.4 h1:Isd0srPkni2iNTWCwVj/72t7uCphFeor5Q8nCzj1jdQ=
github.com/antchfx/htmlquery v1.3.4/go.mod h1:K9os0BwIEmLAvTqaNSua8tXLWRWZpocZIH73OzWQbwM=
github.com/antchfx/xmlquery v1.4.4 h1:mxMEkdYP3pjKSftxss4nUHfjBhnMk4imGoR96FRY2dg=
github.com/antchfx/xmlquery v1.4.4/go.mod h1:AEPEEPYE9GnA2mj5Ur2L5Q5/2PycJ0N9Fusrx9b12fc=
github.com/antchfx/xpath v1.3.3 h1:tmuPQa1Uye0Ym1Zn65vxPgfltWb/Lxu2jeqIGteJSRs=
github.com/antchfx/xpath v1.3.3/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
@@ -126,8 +132,12 @@ github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaEL
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho=
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gocolly/colly v1.2.0 h1:qRz9YAn8FIH0qzgNUw+HT9UN7wm1oF9OBAilwEWpyrI=
github.com/gocolly/colly v1.2.0/go.mod h1:Hof5T3ZswNVsOHYmba1u03W65HDWgpV5HifSuueE0EA=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
@@ -135,6 +145,9 @@ github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVI
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -145,6 +158,10 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180124185431-e89373fe6b4a/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@@ -153,6 +170,7 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -192,6 +210,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o=
github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE=
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
@@ -290,6 +310,8 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d h1:hrujxIzL1woJ7AwssoOcM/tq5JjjG2yYOc8odClEiXA=
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
@@ -331,6 +353,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fxg=
github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo=
github.com/tetratelabs/wazero v1.8.0 h1:iEKu0d4c2Pd+QSRieYbnQC9yiFlMS9D+Jr0LsRmcF4g=
github.com/tetratelabs/wazero v1.8.0/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
@@ -362,8 +386,12 @@ golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++8WpuKPcR5yjLBjvLEA=
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
@@ -373,6 +401,9 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -390,9 +421,13 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -403,8 +438,12 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -422,22 +461,36 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -447,6 +500,8 @@ golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golift.io/starr v1.0.0 h1:IDSaSL+ZYxdLT/Lg//dg/iwZ39LHO3D5CmbLCOgSXbI=
@@ -455,6 +510,8 @@ google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMt
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@@ -466,8 +523,10 @@ google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@@ -1,5 +1,7 @@
package pkg
import "io/fs"
type Torrent interface {
Name() (string, error)
Progress() (int, error)
@@ -11,10 +13,10 @@ type Torrent interface {
SeedRatio() (float64, error)
GetHash() string
//Reload() error
WalkFunc() func(fn func(path string, info fs.FileInfo) error) error
}
type Downloader interface {
GetAll() ([]Torrent, error)
Download(link, dir string) (Torrent, error)
Download(link, hash, dir string) (Torrent, error)
}

View File

@@ -2,29 +2,25 @@ package douban
import (
"fmt"
"io"
"net/http"
"polaris/log"
"polaris/pkg/importlist"
"strconv"
"strings"
"time"
"github.com/PuerkitoBio/goquery"
"github.com/gocolly/colly"
)
const ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
const ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36"
func ParseDoulist(doulistUrl string) (*importlist.Response, error) {
if !strings.Contains(doulistUrl, "doulist") {
return nil, fmt.Errorf("not doulist")
}
req, err := http.NewRequest("GET", doulistUrl, nil)
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", ua)
res, err := http.DefaultClient.Do(req)
res, err := doHttpReq("GET", doulistUrl, nil)
if err != nil {
return nil, err
}
@@ -85,13 +81,8 @@ func ParseDoulist(doulistUrl string) (*importlist.Response, error) {
func parseDetailPage(url string) (string, error) {
println(url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return "", err
}
req.Header.Set("User-Agent", ua)
res, err := http.DefaultClient.Do(req)
res, err := doHttpReq("GET", url, nil)
if err != nil {
return "", err
}
@@ -115,3 +106,80 @@ func parseDetailPage(url string) (string, error) {
_ = doc
return "", nil
}
func NewDoubanWishlist(personId string) *DoubanWishlist {
return &DoubanWishlist{PersonId: personId}
}
type DoubanWishlist struct {
PersonId string
}
const wishlistUrl = "https://movie.douban.com/people/%s/wish?sort=time&start=%d&mode=grid&tags_sort=count"
func (d *DoubanWishlist) GetWishlist(page int) (*importlist.Response, error) {
c := colly.NewCollector(colly.UserAgent(ua))
c.Limit(&colly.LimitRule{
DomainRegexp: "*",
Delay: 10 * time.Second,
RandomDelay: 2 * time.Second,
})
url := fmt.Sprintf(wishlistUrl, d.PersonId, (page-1)*15)
c.OnHTML("div[class='item comment-item']", func(e *colly.HTMLElement) {
if !strings.HasPrefix(e.Request.URL.String(), "https://movie.douban.com/people") {
return
}
e.DOM.Find("div[class='pic'] a[title]").Each(func(i int, selection *goquery.Selection) {
println(selection.Attr("href"))
url, ok := selection.Attr("href")
if ok {
c.Visit(url)
}
})
})
c.OnHTML("#content", func(h *colly.HTMLElement) {
var item importlist.Item
h.DOM.Find("h1").Each(func(i int, selection *goquery.Selection) {
selection.Find("span[property]").Each(func(i int, selection *goquery.Selection) {
println(selection.Text())
item.Title = selection.Text()
})
selection.Find("span[class='year']").Each(func(i int, selection *goquery.Selection) {
n, _ := strconv.Atoi(selection.Text())
item.Year = n
})
})
h.DOM.Find("#info").Each(func(i int, s *goquery.Selection) {
info := strings.TrimSpace(s.Text())
lines := strings.Split(info, "\n")
if len(lines) == 0 {
return
}
last := lines[len(lines)-1]
if !strings.HasPrefix(strings.ToLower(last), "imdb") {
return
}
ss := strings.Split(last, ":")
for _, p := range ss {
p := strings.TrimSpace(strings.ToLower(p))
if strings.HasPrefix(p, "tt") {
item.ImdbID = p
}
}
})
log.Info(item)
})
return nil, c.Visit(url)
}
func doHttpReq(method, url string, body io.Reader) (*http.Response, error) {
req, err := http.NewRequest(method, url, body)
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", ua)
return http.DefaultClient.Do(req)
}

View File

@@ -9,3 +9,10 @@ func TestParseDoulist(t *testing.T) {
r, err := ParseDoulist("https://www.douban.com/doulist/81580/")
log.Info(r, err)
}
func Test111(t *testing.T) {
d := NewDoubanWishlist("69894889")
_, err := d.GetWishlist(1)
log.Infof("err: %v", err)
}

View File

@@ -31,26 +31,28 @@ func New(apiKey, url string) *Client {
return &Client{p: p, apiKey: apiKey, url: url}
}
func (c *Client) GetIndexers(t ProwlarrSupportType) ([]*db.TorznabInfo, error) {
func (c *Client) GetIndexers() ([]*ent.Indexers, error) {
ins, err := c.p.GetIndexers()
if err != nil {
return nil, err
}
var indexers []*db.TorznabInfo
var indexers []*ent.Indexers
for _, in := range ins {
if !in.Enable {
continue
tvSearch := true
movieSearch := true
if len(in.Capabilities.TvSearchParams) == 0 { //no tv resource in this indexer
tvSearch = false
}
if t == "tv" && len(in.Capabilities.TvSearchParams) == 0 { //no tv resource in this indexer
continue
} else if t == "movie" && len(in.Capabilities.MovieSearchParams) == 0 { //no movie resource in this indexer
continue
if len(in.Capabilities.MovieSearchParams) == 0 { //no movie resource in this indexer
movieSearch = false
}
seedRatio := 0.0
for _, f := range in.Fields {
if f.Name == "torrentBaseSettings.seedRatio" && f.Value != nil {
if r, ok := f.Value.(float64); ok {
seedRatio = r
break
}
}
}
@@ -61,17 +63,18 @@ func (c *Client) GetIndexers(t ProwlarrSupportType) ([]*db.TorznabInfo, error) {
data, _ := json.Marshal(&setting)
entIndexer := ent.Indexers{
Disabled: !in.Enable,
Name: in.Name,
Implementation: "torznab",
Priority: 128 - int(in.Priority),
SeedRatio: float32(seedRatio),
Settings: string(data),
TvSearch: tvSearch,
MovieSearch: movieSearch,
APIKey: c.apiKey,
URL: fmt.Sprintf("%s/%d/api", strings.TrimSuffix(c.url, "/"), in.ID),
}
indexers = append(indexers, &db.TorznabInfo{
Indexers: &entIndexer,
TorznabSetting: setting,
})
indexers = append(indexers, &entIndexer)
}
return indexers, nil
}

View File

@@ -7,7 +7,7 @@ import (
func Test111(t *testing.T) {
c := New("", "http://10.0.0.8:9696/")
apis , err := c.GetIndexers("tv")
apis , err := c.GetIndexers()
log.Infof("errors: %v", err)
log.Infof("indexers: %+v", apis[0])
}

View File

@@ -2,7 +2,9 @@ package qbittorrent
import (
"fmt"
"io/fs"
"os"
"path/filepath"
"polaris/pkg"
"polaris/pkg/go-qbittorrent/qbt"
"polaris/pkg/utils"
@@ -59,17 +61,8 @@ func (c *Client) GetAll() ([]pkg.Torrent, error) {
return res, nil
}
func (c *Client) Download(link, dir string) (pkg.Torrent, error) {
magnet, err := utils.Link2Magnet(link)
if err != nil {
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
}
hash, err := utils.MagnetHash(magnet)
if err != nil {
return nil, errors.Wrap(err, "get hash")
}
err = c.c.DownloadLinks([]string{magnet}, qbt.DownloadOptions{Savepath: &dir, Category: &c.category})
func (c *Client) Download(link, hash, dir string) (pkg.Torrent, error) {
err := c.c.DownloadLinks([]string{link}, qbt.DownloadOptions{Savepath: &dir, Category: &c.category})
if err != nil {
return nil, errors.Wrap(err, "qbt download")
}
@@ -77,11 +70,23 @@ func (c *Client) Download(link, dir string) (pkg.Torrent, error) {
}
func NewTorrent(info Info, link string) (*Torrent, error) {
func NewTorrentHash(info Info, hash string) (*Torrent, error) {
c, err := NewClient(info.URL, info.User, info.Password)
if err != nil {
return nil, err
}
t := &Torrent{
c: c.c,
hash: hash,
}
if !t.Exists() {
return nil, errors.Errorf("torrent not exist: %v", hash)
}
return t, nil
}
func NewTorrent(info Info, link string) (*Torrent, error) {
magnet, err := utils.Link2Magnet(link)
if err != nil {
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
@@ -91,14 +96,8 @@ func NewTorrent(info Info, link string) (*Torrent, error) {
if err != nil {
return nil, err
}
t := &Torrent{
c: c.c,
hash: hash,
}
if !t.Exists() {
return nil, errors.Errorf("torrent not exist: %v", magnet)
}
return t, nil
return NewTorrentHash(info, hash)
}
type Torrent struct {
@@ -202,3 +201,49 @@ func (t *Torrent) SeedRatio() (float64, error) {
}
return qb.Ratio, nil
}
func (t *Torrent) Walk(f func(string) error) error {
files, err := t.c.TorrentFiles(t.hash)
if err != nil {
return err
}
for _, file := range files {
if err := f(file.Name); err != nil {
return errors.Errorf("proccess file (%s) error: %v", file.Name, err)
}
}
return nil
}
func (t *Torrent) WalkFunc() func(fn func(path string, info fs.FileInfo) error) error {
files, err := t.c.TorrentFiles(t.hash)
if err != nil {
return func(fn func(path string, info fs.FileInfo) error) error {
return err
}
}
path, err := t.c.DefaultSavePath()
if err != nil {
return func(fn func(path string, info fs.FileInfo) error) error {
return err
}
}
return func(fn func(path string, info fs.FileInfo) error) error {
for _, file := range files {
name := filepath.Join(path, file.Name)
info, err := os.Stat(name)
if err != nil {
return err
}
if err := fn(name, info); err != nil {
return errors.Errorf("proccess file (%s) error: %v", file.Name, err)
}
}
return nil
}
}

View File

@@ -3,7 +3,6 @@ package storage
import (
"io"
"io/fs"
"os"
"path/filepath"
"polaris/pkg/alist"
@@ -28,14 +27,7 @@ type Alist struct {
subtitleFormats []string
}
func (a *Alist) Move(src, dest string) error {
if err := a.Copy(src, dest); err != nil {
return err
}
return os.RemoveAll(src)
}
func (a *Alist) Copy(src, dest string) error {
func (a *Alist) Copy(src, dest string, walkFn WalkFn) error {
b, err := NewBase(src, a.videoFormats, a.subtitleFormats)
if err != nil {
return err
@@ -51,7 +43,7 @@ func (a *Alist) Copy(src, dest string) error {
}
baseDest := filepath.Join(a.baseDir, dest)
return b.Upload(baseDest, false, false, false, uploadFunc, mkdirFunc)
return b.Upload(baseDest, false, false, false, uploadFunc, mkdirFunc, walkFn)
}
func (a *Alist) ReadDir(dir string) ([]fs.FileInfo, error) {
@@ -75,4 +67,4 @@ func (a *Alist) UploadProgress() float64 {
func (a *Alist) RemoveAll(path string) error {
return nil
}
}

View File

@@ -13,9 +13,10 @@ import (
"github.com/pkg/errors"
)
type WalkFn func(fn func(path string, info fs.FileInfo) error) error
type Storage interface {
Move(src, dest string) error
Copy(src, dest string) error
//Move(src, dest string) error
Copy(src, dest string, walkFn WalkFn) error
ReadDir(dir string) ([]fs.FileInfo, error)
ReadFile(string) ([]byte, error)
WriteFile(string, []byte) error
@@ -79,7 +80,7 @@ func (b *Base) isFileNeeded(name string) bool {
}
func (b *Base) Upload(destDir string, tryLink, detectMime, changeMediaHash bool, upload uploadFunc, mkdir func(string) error) error {
func (b *Base) Upload(destDir string, tryLink, detectMime, changeMediaHash bool, upload uploadFunc, mkdir func(string) error, walkFn WalkFn) error {
if !b.checkVideoFilesExist() {
return errors.Errorf("torrent has no video file(s)")
}
@@ -95,7 +96,7 @@ func (b *Base) Upload(destDir string, tryLink, detectMime, changeMediaHash bool,
}
log.Debugf("local storage target base dir is: %v", targetBase)
err = filepath.Walk(b.src, func(path string, info fs.FileInfo, err error) error {
err = walkFn(func(path string, info fs.FileInfo) (err error) {
if err != nil {
return err
}
@@ -112,6 +113,13 @@ func (b *Base) Upload(destDir string, tryLink, detectMime, changeMediaHash bool,
log.Debugf("file is not needed, skip: %s", info.Name())
return nil
}
defer func () {
if err == nil {
log.Infof("copy file success, filename %s, destination %s", rel, destName)
}
}()
if tryLink {
if err := os.Link(path, destName); err == nil {
return nil //link success

View File

@@ -22,7 +22,7 @@ type LocalStorage struct {
subtitleFormats []string
}
func (l *LocalStorage) Copy(src, destDir string) error {
func (l *LocalStorage) Copy(src, destDir string,walkFn WalkFn) error {
b, err := NewBase(src, l.videoFormats, l.subtitleFormats)
if err != nil {
return err
@@ -44,14 +44,7 @@ func (l *LocalStorage) Copy(src, destDir string) error {
}
return b.Upload(baseDest, true, false, false, uploadFunc, func(s string) error {
return os.Mkdir(s, os.ModePerm)
})
}
func (l *LocalStorage) Move(src, destDir string) error {
if err := l.Copy(src, destDir); err != nil {
return err
}
return os.RemoveAll(src)
}, walkFn)
}
func (l *LocalStorage) ReadDir(dir string) ([]fs.FileInfo, error) {

View File

@@ -34,7 +34,7 @@ func NewWebdavStorage(url, user, password, path string, changeMediaHash bool, vi
}, nil
}
func (w *WebdavStorage) Copy(local, remoteDir string) error {
func (w *WebdavStorage) Copy(local, remoteDir string, walkFn WalkFn) error {
b, err := NewBase(local, w.videoFormats, w.subtitleFormats)
if err != nil {
return err
@@ -57,14 +57,7 @@ func (w *WebdavStorage) Copy(local, remoteDir string) error {
return b.Upload(filepath.Join(w.dir, remoteDir), false, true, w.changeMediaHash, uploadFunc, func(s string) error {
return nil
})
}
func (w *WebdavStorage) Move(local, remoteDir string) error {
if err := w.Copy(local, remoteDir); err != nil {
return err
}
return os.RemoveAll(local)
}, walkFn)
}
func (w *WebdavStorage) ReadDir(dir string) ([]fs.FileInfo, error) {

View File

@@ -7,7 +7,7 @@ import (
"io"
"net/http"
"net/url"
"polaris/db"
"polaris/ent"
"polaris/log"
"slices"
"strconv"
@@ -74,7 +74,7 @@ func (i *Item) GetAttr(key string) string {
}
return ""
}
func (r *Response) ToResults(indexer *db.TorznabInfo) []Result {
func (r *Response) ToResults(indexer *ent.Indexers) []Result {
var res []Result
for _, item := range r.Channel.Item {
if slices.Contains(item.Category, "3000") { //exclude audio files
@@ -130,7 +130,7 @@ func tryParseFloat(s string) float32 {
return float32(r)
}
func Search(indexer *db.TorznabInfo, keyWord string) ([]Result, error) {
func Search(indexer *ent.Indexers, keyWord string) ([]Result, error) {
ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
defer cancel()
@@ -139,7 +139,7 @@ func Search(indexer *db.TorznabInfo, keyWord string) ([]Result, error) {
return nil, errors.Wrap(err, "new request")
}
var q = url.Values{}
q.Add("apikey", indexer.ApiKey)
q.Add("apikey", indexer.APIKey)
q.Add("t", "search")
q.Add("q", keyWord)
req.URL.RawQuery = q.Encode()
@@ -183,7 +183,7 @@ type Result struct {
Name string `json:"name"`
Description string `json:"description"`
Link string `json:"link"`
Size int64 `json:"size"`
Size int64 `json:"size"`
Seeders int `json:"seeders"`
Peers int `json:"peers"`
Category int `json:"category"`

View File

@@ -3,7 +3,10 @@ package transmission
import (
"context"
"fmt"
"io/fs"
"net/url"
"os"
"path/filepath"
"polaris/log"
"polaris/pkg"
"polaris/pkg/utils"
@@ -60,21 +63,15 @@ func (c *Client) GetAll() ([]pkg.Torrent, error) {
return torrents, nil
}
func (c *Client) Download(link, dir string) (pkg.Torrent, error) {
magnet, err := utils.Link2Magnet(link)
if err != nil {
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
}
hash, err := utils.MagnetHash(magnet)
if err != nil {
return nil, errors.Wrap(err, "get hash")
}
func (c *Client) Download(link, hash, dir string) (pkg.Torrent, error) {
t, err := c.c.TorrentAdd(context.TODO(), transmissionrpc.TorrentAddPayload{
Filename: &magnet,
Filename: &link,
DownloadDir: &dir,
})
if err != nil {
return nil, err
}
log.Debugf("get torrent info: %+v", t)
return &Torrent{
@@ -84,33 +81,38 @@ func (c *Client) Download(link, dir string) (pkg.Torrent, error) {
}, err
}
func NewTorrent(cfg Config, link string) (*Torrent, error) {
func NewTorrentHash(cfg Config, hash string) (*Torrent, error) {
c, err := NewClient(cfg)
if err != nil {
return nil, err
}
magnet, err := utils.Link2Magnet(link)
if err != nil {
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
}
hash, err := utils.MagnetHash(magnet)
if err != nil {
return nil, err
}
t := &Torrent{
c: c.c,
hash: hash,
//cfg: cfg,
}
if !t.Exists() {
return nil, errors.Errorf("torrent not exist: %v", magnet)
return nil, errors.Errorf("torrent not exist: %v", hash)
}
return t, nil
}
func NewTorrent(cfg Config, link string) (*Torrent, error) {
magnet, err := utils.Link2Magnet(link)
if err != nil {
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
}
hash, err := utils.MagnetHash(magnet)
if err != nil {
return nil, err
}
return NewTorrentHash(cfg, hash)
}
type Torrent struct {
//t *transmissionrpc.Torrent
c *transmissionrpc.Client
@@ -208,3 +210,28 @@ func (t *Torrent) Size() (int, error) {
func (t *Torrent) GetHash() string {
return t.hash
}
func (t *Torrent) WalkFunc() func(fn func(path string, info fs.FileInfo) error) error {
tt, err := t.getTorrent()
if err != nil {
return func(fn func(path string, info fs.FileInfo) error) error {
return errors.Wrap(err, "get torrent info")
}
}
return func(fn func(path string, info fs.FileInfo) error) error {
for _, file := range tt.Files {
name := filepath.Join(*tt.DownloadDir, file.Name)
info, err := os.Stat(name)
if err != nil {
return err
}
if err := fn(name, info); err != nil {
return err
}
}
return nil
}
}

View File

@@ -222,6 +222,33 @@ func isWSL() bool {
return strings.Contains(strings.ToLower(string(releaseData)), "microsoft")
}
func Link2Hash(link string) (string, error) {
if strings.HasPrefix(strings.ToLower(link), "magnet:") {
return MagnetHash(link)
}
client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse //do not follow redirects
},
}
resp, err := client.Get(link)
if err != nil {
return "", errors.Wrap(err, "get link")
}
defer resp.Body.Close()
if resp.StatusCode >= 300 && resp.StatusCode < 400 {
//redirects
tourl := resp.Header.Get("Location")
return Link2Hash(tourl)
}
info, err := metainfo.Load(resp.Body)
if err != nil {
return "", errors.Wrap(err, "parse response")
}
return info.HashInfoBytes().HexString(), nil
}
func Link2Magnet(link string) (string, error) {
if strings.HasPrefix(strings.ToLower(link), "magnet:") {
return link, nil

12
pkg/utils/utils_test.go Normal file
View File

@@ -0,0 +1,12 @@
package utils
import (
"polaris/log"
"testing"
)
func TestLink2Magnet(t *testing.T) {
s, err := Link2Hash("https://api.m-team.io/api/rss/dlv2?useHttps=true&type=ipv6&sign=1a5174668feea2630acfd6a665f41e5c&t=1738468436&tid=901313&uid=346577")
log.Errorf("%v", err)
log.Infof("%v", s)
}

View File

@@ -102,19 +102,13 @@ func (s *Server) RemoveActivity(c *gin.Context) (interface{}, error) {
return nil, errors.Wrap(err, "db")
}
if his.EpisodeID != 0 {
if !s.db.IsEpisodeDownloadingOrDownloaded(his.EpisodeID) {
s.db.SetEpisodeStatus(his.EpisodeID, episode.StatusMissing)
}
episodeIds := s.core.GetEpisodeIds(his)
} else {
seasonNum, err := utils.SeasonId(his.TargetDir)
if err != nil {
log.Errorf("no season id: %v", his.TargetDir)
seasonNum = -1
}
if his.Status == history.StatusRunning || his.Status == history.StatusUploading {
s.db.SetSeasonAllEpisodeStatus(his.MediaID, seasonNum, episode.StatusMissing)
for _, id := range episodeIds {
ep, _ := s.db.GetEpisode(his.MediaID, his.SeasonNum, id)
if !s.db.IsEpisodeDownloadingOrDownloaded(id) && ep.Status != episode.StatusDownloaded {
//没有正在下载中或者下载完成的任务并且episode状态不是已经下载完成
s.db.SetEpisodeStatus(id, episode.StatusMissing)
}
}

View File

@@ -59,27 +59,55 @@ func (c *Client) reloadTasks() {
}
if dl.Implementation == downloadclients.ImplementationTransmission {
to, err := transmission.NewTorrent(transmission.Config{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Link)
if err != nil {
log.Warnf("get task error: %v", err)
continue
if t.Hash != "" { //优先使用hash
to, err := transmission.NewTorrentHash(transmission.Config{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Hash)
if err != nil {
log.Warnf("get task error: %v", err)
continue
}
c.tasks[t.ID] = &Task{Torrent: to}
} else if t.Link != "" {
to, err := transmission.NewTorrent(transmission.Config{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Link)
if err != nil {
log.Warnf("get task error: %v", err)
continue
}
c.tasks[t.ID] = &Task{Torrent: to}
}
c.tasks[t.ID] = &Task{Torrent: to}
} else if dl.Implementation == downloadclients.ImplementationQbittorrent {
to, err := qbittorrent.NewTorrent(qbittorrent.Info{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Link)
if err != nil {
log.Warnf("get task error: %v", err)
continue
if t.Hash != "" {
to, err := qbittorrent.NewTorrentHash(qbittorrent.Info{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Hash)
if err != nil {
log.Warnf("get task error: %v", err)
continue
}
c.tasks[t.ID] = &Task{Torrent: to}
} else if t.Link != "" {
to, err := qbittorrent.NewTorrent(qbittorrent.Info{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Link)
if err != nil {
log.Warnf("get task error: %v", err)
continue
}
c.tasks[t.ID] = &Task{Torrent: to}
}
c.tasks[t.ID] = &Task{Torrent: to}
}
}

80
server/core/indexer.go Normal file
View File

@@ -0,0 +1,80 @@
package core
import (
"polaris/ent"
"polaris/log"
"polaris/pkg/prowlarr"
"strings"
"github.com/pkg/errors"
)
const prowlarrPrefix = "Prowlarr_"
func (c *Client) SyncProwlarrIndexers(apiKey, url string) error {
client := prowlarr.New(apiKey, url)
if ins, err := client.GetIndexers(); err != nil {
return errors.Wrap(err, "connect to prowlarr error")
} else {
var prowlarrNames = make(map[string]bool, len(ins))
for _, in := range ins {
prowlarrNames[in.Name] = true
}
all := c.db.GetAllIndexers()
for _, index := range all {
if index.Synced {
if !prowlarrNames[strings.TrimPrefix(index.Name, prowlarrPrefix)] {
c.db.DeleteIndexer(index.ID) //remove deleted indexers
}
}
}
for _, indexer := range ins {
if err := c.db.SaveIndexer(&ent.Indexers{
Disabled: indexer.Disabled,
Name: prowlarrPrefix + indexer.Name,
Priority: indexer.Priority,
SeedRatio: indexer.SeedRatio,
//Settings: indexer.Settings,
Implementation: "torznab",
APIKey: indexer.APIKey,
URL: indexer.URL,
TvSearch: indexer.TvSearch,
MovieSearch: indexer.MovieSearch,
Synced: true,
}); err != nil {
return errors.Wrap(err, "save prowlarr indexers")
}
log.Debugf("synced prowlarr indexer to db: %v", indexer.Name)
}
}
return nil
}
func (c *Client) syncProwlarr() error {
p, err := c.db.GetProwlarrSetting()
if err != nil {
return errors.Wrap(err, "db")
}
if p.Disabled {
return nil
}
if err := c.SyncProwlarrIndexers(p.ApiKey, p.URL); err != nil {
return errors.Wrap(err, "sync prowlarr indexers")
}
return nil
}
func (c *Client) DeleteAllProwlarrIndexers() error {
all := c.db.GetAllIndexers()
for _, index := range all {
if index.Synced {
c.db.DeleteIndexer(index.ID)
log.Debugf("success delete prowlarr indexer: %s", index.Name)
}
}
return nil
}

View File

@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/xml"
"fmt"
"os"
"io/fs"
"path/filepath"
"polaris/db"
"polaris/ent/media"
@@ -14,7 +14,6 @@ import (
"polaris/pkg/metadata"
"polaris/pkg/notifier"
"polaris/pkg/storage"
"polaris/pkg/utils"
"slices"
"strconv"
"strings"
@@ -66,7 +65,7 @@ func (c *Client) writeNfoFile(historyId int) error {
if err != nil {
return errors.Wrap(err, "xml marshal")
}
return st.WriteFile(nfoPath, data)
return st.WriteFile(nfoPath, []byte(xml.Header+string(data)))
}
} else if md.MediaType == media.MediaTypeMovie { //movie.nfo
@@ -101,7 +100,7 @@ func (c *Client) writeNfoFile(historyId int) error {
if err != nil {
return errors.Wrap(err, "xml marshal")
}
return st.WriteFile(nfoPath, data)
return st.WriteFile(nfoPath, []byte(xml.Header+string(data)))
}
}
return nil
@@ -150,41 +149,22 @@ func (c *Client) writePlexmatch(historyId int) error {
} else {
buff.Write(data)
}
episodesIds := c.GetEpisodeIds(his)
if his.EpisodeID > 0 {
//single episode download
ep, err := c.db.GetEpisodeByID(his.EpisodeID)
for _, id := range episodesIds {
ep, err := c.db.GetEpisodeByID(id)
if err != nil {
return errors.Wrap(err, "query episode")
log.Warnf("query episode: %v", err)
continue
}
if strings.Contains(buff.String(), ep.TargetFile) {
log.Debugf("already write plex episode line: %v", ep.TargetFile)
return nil
}
buff.WriteString(fmt.Sprintf("\nep: %d: %s\n", ep.EpisodeNumber, ep.TargetFile))
} else {
seasonNum, err := utils.SeasonId(his.TargetDir)
if err != nil {
return errors.Wrap(err, "no season id")
}
allEpisodes, err := c.db.GetSeasonEpisodes(his.MediaID, seasonNum)
if err != nil {
return errors.Wrap(err, "query season episode")
}
for _, ep := range allEpisodes {
if ep.TargetFile == "" {
log.Errorf("no episode file of episode %d, season %d", ep.EpisodeNumber, ep.SeasonNumber)
//TODO update db
continue
}
if strings.Contains(buff.String(), ep.TargetFile) {
log.Debugf("already write plex episode line: %v", ep.TargetFile)
continue
}
buff.WriteString(fmt.Sprintf("\nep: %d: %s\n", ep.EpisodeNumber, ep.TargetFile))
}
}
log.Infof("write season plexmatch file content: %s", buff.String())
return st.WriteFile(seasonPlex, buff.Bytes())
}
@@ -212,7 +192,6 @@ func (c *Client) GetStorage(storageId int, mediaType media.MediaType) (storage.S
log.Warnf("get accepted subtitle format error: %v", err)
}
switch st.Implementation {
case storage1.ImplementationLocal:
@@ -272,63 +251,33 @@ func (c *Client) sendMsg(msg string) {
func (c *Client) findEpisodeFilesPreMoving(historyId int) error {
his := c.db.GetHistory(historyId)
isSingleEpisode := his.EpisodeID > 0
downloadDir := c.db.GetDownloadDir()
episodeIds := c.GetEpisodeIds(his)
task := c.tasks[historyId]
name, err := task.Name()
ff, err := c.db.GetAcceptedVideoFormats()
if err != nil {
return err
}
target := filepath.Join(downloadDir, name)
fi, err := os.Stat(target)
if err != nil {
return errors.Wrapf(err, "read dir %v", target)
}
if isSingleEpisode {
if fi.IsDir() {
//download single episode in dir
//TODO
} else {
//is file
if err := c.db.UpdateEpisodeTargetFile(his.EpisodeID, fi.Name()); err != nil {
log.Errorf("writing downloaded file name to db error: %v", err)
for _, id := range episodeIds {
ep, _ := c.db.GetEpisode(his.MediaID, his.SeasonNum, id)
task.WalkFunc()(func(path string, info fs.FileInfo) error {
if info.IsDir() {
return nil
}
}
} else {
if !fi.IsDir() {
return fmt.Errorf("not season pack downloaded")
}
seasonNum, err := utils.SeasonId(his.TargetDir)
if err != nil {
return errors.Wrap(err, "no season id")
}
files, err := os.ReadDir(target)
if err != nil {
return err
}
for _, f := range files {
if f.IsDir() { //want media file
continue
ext := filepath.Ext(info.Name())
if slices.Contains(ff, ext) {
return nil
}
excludedExt := []string{".txt", ".srt", ".ass", ".sub"}
ext := filepath.Ext(f.Name())
if slices.Contains(excludedExt, strings.ToLower(ext)) {
continue
}
meta := metadata.ParseTv(f.Name())
if meta.StartEpisode > 0 {
//episode exists
ep, err := c.db.GetEpisode(his.MediaID, seasonNum, meta.StartEpisode)
if err != nil {
return err
}
if err := c.db.UpdateEpisodeTargetFile(ep.ID, f.Name()); err != nil {
return errors.Wrap(err, "update episode file")
meta := metadata.ParseTv(info.Name())
if meta.StartEpisode == meta.EndEpisode && meta.StartEpisode == ep.EpisodeNumber {
if err := c.db.UpdateEpisodeTargetFile(id, info.Name()); err != nil {
log.Errorf("writing downloaded file name to db error: %v", err)
}
}
}
return nil
})
}
return nil
}

View File

@@ -6,6 +6,7 @@ import (
"polaris/ent"
"polaris/ent/episode"
"polaris/ent/history"
"polaris/ent/media"
"polaris/log"
"polaris/pkg/metadata"
"polaris/pkg/notifier/message"
@@ -16,95 +17,13 @@ import (
)
func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum int, episodeNums ...int) (*string, error) {
trc, dlc, err := c.GetDownloadClient()
series, err := c.db.GetMedia(seriesId)
if err != nil {
return nil, errors.Wrap(err, "connect transmission")
}
series := c.db.GetMediaDetails(seriesId)
if series == nil {
return nil, fmt.Errorf("no tv series of id %v", seriesId)
}
//check space available
downloadDir := c.db.GetDownloadDir()
size := utils.AvailableSpace(downloadDir)
if size < uint64(r1.Size) {
log.Errorf("space available %v, space needed %v", size, r1.Size)
return nil, errors.New("no enough space")
}
magnet, err := utils.Link2Magnet(r1.Link)
if err != nil {
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", r1.Link, err)
}
dir := fmt.Sprintf("%s/Season %02d/", series.TargetDir, seasonNum)
if len(episodeNums) > 0 {
for _, epNum := range episodeNums {
var ep *ent.Episode
for _, e := range series.Episodes {
if e.SeasonNumber == seasonNum && e.EpisodeNumber == epNum {
ep = e
}
}
if ep == nil {
return nil, errors.Errorf("no episode of season %d episode %d", seasonNum, epNum)
}
if ep.Status == episode.StatusMissing {
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
}
}
} else { //season package download
c.db.SetSeasonAllEpisodeStatus(seriesId, seasonNum, episode.StatusDownloading)
}
history, err := c.db.SaveHistoryRecord(ent.History{
MediaID: seriesId,
EpisodeNums: episodeNums,
SeasonNum: seasonNum,
SourceTitle: r1.Name,
TargetDir: dir,
Status: history.StatusRunning,
Size: int(r1.Size),
//Saved: torrent.Save(),
Link: magnet,
DownloadClientID: dlc.ID,
IndexerID: r1.IndexerId,
})
if err != nil {
return nil, errors.Wrap(err, "save record")
}
torrent, err := trc.Download(magnet, downloadDir)
if err != nil {
return nil, errors.Wrap(err, "downloading")
}
torrent.Start()
c.tasks[history.ID] = &Task{Torrent: torrent}
name := r1.Name
if len(episodeNums) > 0 {
buff := &bytes.Buffer{}
for i, ep := range episodeNums {
if i != 0 {
buff.WriteString(",")
}
buff.WriteString(fmt.Sprint(ep))
}
name = fmt.Sprintf("第%s集 (%s)", buff.String(), name)
} else {
name = fmt.Sprintf("全集 (%s)", name)
}
c.sendMsg(fmt.Sprintf(message.BeginDownload, name))
log.Infof("success add %s to download task", r1.Name)
return &r1.Name, nil
return c.downloadTorrent(series, r1, seasonNum, episodeNums...)
}
/*
@@ -192,53 +111,95 @@ lo:
return torrentNames, nil
}
func (c *Client) DownloadMovie(m *ent.Media, link, name string, size int64, indexerID int) (*string, error) {
func (c *Client) DownloadMovie(m *ent.Media, r1 torznab.Result) (*string, error) {
return c.downloadTorrent(m, r1, 0)
}
func (c *Client) downloadTorrent(m *ent.Media, r1 torznab.Result, seasonNum int, episodeNums ...int) (*string, error) {
trc, dlc, err := c.GetDownloadClient()
if err != nil {
return nil, errors.Wrap(err, "connect transmission")
}
magnet, err := utils.Link2Magnet(link)
if err != nil {
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
//check space available
downloadDir := c.db.GetDownloadDir()
size := utils.AvailableSpace(downloadDir)
if size < uint64(r1.Size) {
log.Errorf("space available %v, space needed %v", size, r1.Size)
return nil, errors.New("no enough space")
}
torrent, err := trc.Download(magnet, c.db.GetDownloadDir())
var name = r1.Name
var targetDir = m.TargetDir
if m.MediaType == media.MediaTypeTv { //tv download
targetDir = fmt.Sprintf("%s/Season %02d/", m.TargetDir, seasonNum)
if len(episodeNums) > 0 {
for _, epNum := range episodeNums {
ep, err := c.db.GetEpisode(m.ID, seasonNum, epNum)
if err != nil {
return nil, errors.Errorf("no episode of season %d episode %d", seasonNum, epNum)
}
if ep.Status == episode.StatusMissing {
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
}
}
buff := &bytes.Buffer{}
for i, ep := range episodeNums {
if i != 0 {
buff.WriteString(",")
}
buff.WriteString(fmt.Sprint(ep))
}
name = fmt.Sprintf("第%s集 (%s)", buff.String(), name)
} else { //season package download
name = fmt.Sprintf("全集 (%s)", name)
c.db.SetSeasonAllEpisodeStatus(m.ID, seasonNum, episode.StatusDownloading)
}
} else {
ep, _ := c.db.GetMovieDummyEpisode(m.ID)
if ep.Status == episode.StatusMissing {
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
}
}
hash, err := utils.Link2Hash(r1.Link)
if err != nil {
return nil, errors.Wrap(err, "get hash")
}
history, err := c.db.SaveHistoryRecord(ent.History{
MediaID: m.ID,
EpisodeNums: episodeNums,
SeasonNum: seasonNum,
SourceTitle: r1.Name,
TargetDir: targetDir,
Status: history.StatusRunning,
Size: int(r1.Size),
//Saved: torrent.Save(),
Link: r1.Link,
Hash: hash,
DownloadClientID: dlc.ID,
IndexerID: r1.IndexerId,
})
if err != nil {
return nil, errors.Wrap(err, "save record")
}
torrent, err := trc.Download(r1.Link, hash, downloadDir)
if err != nil {
return nil, errors.Wrap(err, "downloading")
}
torrent.Start()
if name == "" {
name = m.OriginalName
}
go func() {
ep, _ := c.db.GetMovieDummyEpisode(m.ID)
history, err := c.db.SaveHistoryRecord(ent.History{
MediaID: m.ID,
EpisodeID: ep.ID,
SourceTitle: name,
TargetDir: m.TargetDir,
Status: history.StatusRunning,
Size: int(size),
//Saved: torrent.Save(),
Link: magnet,
DownloadClientID: dlc.ID,
IndexerID: indexerID,
})
if err != nil {
log.Errorf("save history error: %v", err)
}
c.tasks[history.ID] = &Task{Torrent: torrent}
if ep.Status == episode.StatusMissing {
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
}
}()
c.tasks[history.ID] = &Task{Torrent: torrent}
c.sendMsg(fmt.Sprintf(message.BeginDownload, name))
log.Infof("success add %s to download task", name)
return &name, nil
log.Infof("success add %s to download task", r1.Name)
return &r1.Name, nil
}

View File

@@ -25,6 +25,9 @@ func (c *Client) addSysCron() {
if v == "true" {
return nil
}
if err := c.syncProwlarr(); err != nil {
log.Warnf("sync prowlarr error: %v", err)
}
c.downloadAllTvSeries()
c.downloadAllMovies()
return nil
@@ -90,20 +93,84 @@ func (c *Client) checkTasks() error {
log.Infof("torrent file seed ratio reached, remove: %v, current seed ratio: %v", name, ratio)
torrent.Remove()
delete(c.tasks, id)
c.setHistoryStatus(id, history.StatusSuccess)
} else {
log.Infof("torrent file still sedding: %v, current seed ratio: %v", name, ratio)
}
continue
} else if r.Status == history.StatusRunning {
log.Infof("task is done: %v", name)
c.sendMsg(fmt.Sprintf(message.DownloadComplete, name))
go c.postTaskProcessing(id)
}
log.Infof("task is done: %v", name)
c.sendMsg(fmt.Sprintf(message.DownloadComplete, name))
go c.postTaskProcessing(id)
}
}
return nil
}
/*
episode 状态有3种missing、downloading、downloaded
history状态有5种running, success, fail, uploading, seeding
没有下载的剧集状态都是missing已下载完成的都是downloaded正在下载的是downloading
对应的history状态下载任务创建成功正常跑着是running出了问题失败了就是fail下载完成的任务会先进入uploading状态进一步处理
uploading状态下会传输到对应的存储里面uploading成功如果需要做种会进入seeding状态如果不做种进入success状态失败了会进入fail状态
seeding状态中会定时检查做种状态达到指定分享率会置为success
任务创建成功episode状态会由missing置为downloading如果任务失败重新置为missing如果任务成功进入success或seedingepisode状态应置为downloaded
*/
func (c *Client) setHistoryStatus(id int, status history.Status) {
r := c.db.GetHistory(id)
episodeIds := c.GetEpisodeIds(r)
switch status {
case history.StatusRunning:
c.db.SetHistoryStatus(id, history.StatusRunning)
c.setEpsideoStatus(episodeIds, episode.StatusDownloading)
case history.StatusSuccess:
c.db.SetHistoryStatus(id, history.StatusSuccess)
c.setEpsideoStatus(episodeIds, episode.StatusDownloaded)
case history.StatusUploading:
c.db.SetHistoryStatus(id, history.StatusUploading)
case history.StatusSeeding:
c.db.SetHistoryStatus(id, history.StatusSeeding)
c.setEpsideoStatus(episodeIds, episode.StatusDownloaded)
case history.StatusFail:
c.db.SetHistoryStatus(id, history.StatusFail)
c.setEpsideoStatus(episodeIds, episode.StatusMissing)
default:
panic(fmt.Sprintf("unkown status %v", status))
}
}
func (c *Client) setEpsideoStatus(episodeIds []int, status episode.Status) error {
for _, id := range episodeIds {
ep, err := c.db.GetEpisodeByID(id)
if err != nil {
return err
}
if ep.Status == episode.StatusDownloaded {
//已经下载完成的任务,不再重新设置状态
continue
}
if err := c.db.SetEpisodeStatus(id, status); err != nil {
return err
}
}
return nil
}
func (c *Client) postTaskProcessing(id int) {
if err := c.findEpisodeFilesPreMoving(id); err != nil {
log.Errorf("finding all episode file error: %v", err)
@@ -136,11 +203,12 @@ func (c *Client) GetEpisodeIds(r *ent.History) []int {
var episodeIds []int
seasonNum := getSeasonNum(r)
if r.EpisodeID > 0 {
episodeIds = append(episodeIds, r.EpisodeID)
}
// if r.EpisodeID > 0 {
// episodeIds = append(episodeIds, r.EpisodeID)
// }
series := c.db.GetMediaDetails(r.MediaID)
if len(r.EpisodeNums) > 0 {
series := c.db.GetMediaDetails(r.MediaID)
for _, epNum := range r.EpisodeNums {
for _, ep := range series.Episodes {
if ep.SeasonNumber == seasonNum && ep.EpisodeNumber == epNum {
@@ -148,6 +216,13 @@ func (c *Client) GetEpisodeIds(r *ent.History) []int {
}
}
}
} else {
for _, ep := range series.Episodes {
if ep.SeasonNumber == seasonNum {
episodeIds = append(episodeIds, ep.ID)
}
}
}
return episodeIds
}
@@ -155,11 +230,12 @@ func (c *Client) GetEpisodeIds(r *ent.History) []int {
func (c *Client) moveCompletedTask(id int) (err1 error) {
torrent := c.tasks[id]
r := c.db.GetHistory(id)
if r.Status == history.StatusUploading {
log.Infof("task %d is already uploading, skip", id)
return nil
}
c.db.SetHistoryStatus(r.ID, history.StatusUploading)
// if r.Status == history.StatusUploading {
// log.Infof("task %d is already uploading, skip", id)
// return nil
// }
c.setHistoryStatus(r.ID, history.StatusUploading)
downloadclient, err := c.db.GetDownloadClient(r.DownloadClientID)
if err != nil {
@@ -171,23 +247,10 @@ func (c *Client) moveCompletedTask(id int) (err1 error) {
return err
}
seasonNum := getSeasonNum(r)
episodeIds := c.GetEpisodeIds(r)
defer func() {
if err1 != nil {
c.db.SetHistoryStatus(r.ID, history.StatusFail)
if len(episodeIds) > 0 {
for _, id := range episodeIds {
if !c.db.IsEpisodeDownloadingOrDownloaded(id) {
c.db.SetEpisodeStatus(id, episode.StatusMissing)
}
}
} else {
c.db.SetSeasonAllEpisodeStatus(r.MediaID, seasonNum, episode.StatusMissing)
}
c.setHistoryStatus(r.ID, history.StatusFail)
c.sendMsg(fmt.Sprintf(message.ProcessingFailed, err1))
if downloadclient.RemoveFailedDownloads {
log.Debugf("task failed, remove failed torrent and files related")
@@ -201,6 +264,7 @@ func (c *Client) moveCompletedTask(id int) (err1 error) {
if series == nil {
return nil
}
st := c.db.GetStorage(series.StorageID)
log.Infof("move task files to target dir: %v", r.TargetDir)
stImpl, err := c.GetStorage(st.ID, series.MediaType)
@@ -209,28 +273,23 @@ func (c *Client) moveCompletedTask(id int) (err1 error) {
}
//如果种子是路径,则会把路径展开,只移动文件,类似 move dir/* dir2/, 如果种子是文件,则会直接移动文件,类似 move file dir/
if err := stImpl.Copy(filepath.Join(c.db.GetDownloadDir(), torrentName), r.TargetDir); err != nil {
if err := stImpl.Copy(filepath.Join(c.db.GetDownloadDir(), torrentName), r.TargetDir, torrent.WalkFunc()); err != nil {
return errors.Wrap(err, "move file")
}
torrent.UploadProgresser = stImpl.UploadProgress
c.db.SetHistoryStatus(r.ID, history.StatusSeeding)
if len(episodeIds) > 0 {
for _, id := range episodeIds {
c.db.SetEpisodeStatus(id, episode.StatusDownloaded)
}
} else {
c.db.SetSeasonAllEpisodeStatus(r.MediaID, seasonNum, episode.StatusDownloaded)
}
c.sendMsg(fmt.Sprintf(message.ProcessingComplete, torrentName))
//判断是否需要删除本地文件
//判断是否需要删除本地文件, TODO prowlarr has no indexer id
r1, ok := c.isSeedRatioLimitReached(r.IndexerID, torrent)
if downloadclient.RemoveCompletedDownloads && ok {
log.Debugf("download complete,remove torrent and files related, torrent: %v, seed ratio: %v", torrentName, r1)
c.db.SetHistoryStatus(r.ID, history.StatusSuccess)
c.setHistoryStatus(r.ID, history.StatusSuccess)
delete(c.tasks, r.ID)
torrent.Remove()
} else {
log.Infof("task complete but still needs seeding: %v", torrentName)
c.setHistoryStatus(r.ID, history.StatusSeeding)
}
log.Infof("move downloaded files to target dir success, file: %v, target dir: %v", torrentName, r.TargetDir)
@@ -391,18 +450,15 @@ func (c *Client) DownloadMovieByID(id int) (string, error) {
return "", nil
}
if name, err := c.downloadMovieSingleEpisode(ep, detail.TargetDir); err != nil {
if name, err := c.downloadMovieSingleEpisode(detail.Media, ep); err != nil {
return "", errors.Wrap(err, "download movie")
} else {
return name, nil
}
}
func (c *Client) downloadMovieSingleEpisode(ep *ent.Episode, targetDir string) (string, error) {
trc, dlc, err := c.GetDownloadClient()
if err != nil {
return "", errors.Wrap(err, "connect transmission")
}
func (c *Client) downloadMovieSingleEpisode(m *ent.Media, ep *ent.Episode) (string, error) {
qiangban := c.db.GetSetting(db.SettingAllowQiangban)
allowQiangban := false
if qiangban == "true" {
@@ -416,43 +472,16 @@ func (c *Client) downloadMovieSingleEpisode(ep *ent.Episode, targetDir string) (
FilterQiangban: !allowQiangban,
})
if err != nil {
return "", errors.Wrap(err, "search movie")
}
r1 := res[0]
log.Infof("begin download torrent resource: %v", r1.Name)
magnet, err := utils.Link2Magnet(r1.Link)
s, err := c.downloadTorrent(m, r1, 0)
if err != nil {
return "", errors.Errorf("converting link to magnet error, link: %v, error: %v", r1.Link, err)
return "", err
}
torrent, err := trc.Download(magnet, c.db.GetDownloadDir())
if err != nil {
return "", errors.Wrap(err, "downloading")
}
torrent.Start()
history, err := c.db.SaveHistoryRecord(ent.History{
MediaID: ep.MediaID,
EpisodeID: ep.ID,
SourceTitle: r1.Name,
TargetDir: targetDir,
Status: history.StatusRunning,
Size: int(r1.Size),
//Saved: torrent.Save(),
Link: magnet,
DownloadClientID: dlc.ID,
IndexerID: r1.IndexerId,
})
if err != nil {
log.Errorf("save history error: %v", err)
}
c.tasks[history.ID] = &Task{Torrent: torrent}
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
return r1.Name, nil
return *s, nil
}
func (c *Client) checkAllSeriesNewSeason() error {

View File

@@ -7,7 +7,6 @@ import (
"polaris/ent/media"
"polaris/log"
"polaris/pkg/metadata"
"polaris/pkg/prowlarr"
"polaris/pkg/torznab"
"slices"
"sort"
@@ -86,7 +85,7 @@ func SearchTvSeries(db1 *db.Client, param *SearchParam) ([]torznab.Result, error
names := names2Query(series.Media)
res := searchWithTorznab(db1, prowlarr.TV, names...)
res := searchWithTorznab(db1, SearchTypeTv, names...)
var filtered []torznab.Result
lo:
@@ -248,9 +247,9 @@ func SearchMovie(db1 *db.Client, param *SearchParam) ([]torznab.Result, error) {
}
names := names2Query(movieDetail.Media)
res := searchWithTorznab(db1, prowlarr.Movie, names...)
res := searchWithTorznab(db1, SearchTypeMovie, names...)
if movieDetail.Extras.IsJav() {
res1 := searchWithTorznab(db1, prowlarr.Movie, movieDetail.Extras.JavId)
res1 := searchWithTorznab(db1, SearchTypeMovie, movieDetail.Extras.JavId)
res = append(res, res1...)
}
@@ -304,21 +303,18 @@ func SearchMovie(db1 *db.Client, param *SearchParam) ([]torznab.Result, error) {
}
func searchWithTorznab(db *db.Client, t prowlarr.ProwlarrSupportType, queries ...string) []torznab.Result {
type SearchType int
const (
SearchTypeTv SearchType = 1
SearchTypeMovie SearchType = 2
)
func searchWithTorznab(db *db.Client, t SearchType, queries ...string) []torznab.Result {
var res []torznab.Result
allTorznab := db.GetAllTorznabInfo()
allTorznab := db.GetAllIndexers()
p, err := db.GetProwlarrSetting()
if err == nil && !p.Disabled { //prowlarr exists
c := prowlarr.New(p.ApiKey, p.URL)
all, err := c.GetIndexers(t)
if err != nil {
log.Warnf("get prowlarr all indexer error: %v", err)
} else {
allTorznab = append(allTorznab, all...)
}
}
resChan := make(chan []torznab.Result)
var wg sync.WaitGroup
@@ -326,6 +322,13 @@ func searchWithTorznab(db *db.Client, t prowlarr.ProwlarrSupportType, queries ..
if tor.Disabled {
continue
}
if t == SearchTypeTv && !tor.TvSearch {
continue
}
if t == SearchTypeMovie && !tor.MovieSearch {
continue
}
for _, q := range queries {
wg.Add(1)

View File

@@ -164,7 +164,13 @@ func (s *Server) DownloadTorrent(c *gin.Context) (interface{}, error) {
return s.core.DownloadEpisodeTorrent(res, in.MediaID, in.Season, in.Episode)
} else {
//movie
return s.core.DownloadMovie(m, in.Link, in.Name, in.Size, in.IndexerId)
name := in.Name
if name == "" {
name = m.OriginalName
}
res := torznab.Result{Name: name, Link: in.Link, Size: in.Size, IndexerId: in.IndexerId}
return s.core.DownloadMovie(m, res)
}
}

View File

@@ -1,14 +1,12 @@
package server
import (
"encoding/json"
"fmt"
"html/template"
"polaris/db"
"polaris/ent"
"polaris/ent/downloadclients"
"polaris/log"
"polaris/pkg/prowlarr"
"polaris/pkg/qbittorrent"
"polaris/pkg/torznab"
"polaris/pkg/transmission"
@@ -146,29 +144,25 @@ func (s *Server) AddTorznabInfo(c *gin.Context) (interface{}, error) {
utils.TrimFields(&in)
log.Infof("add indexer settings: %+v", in)
setting := db.TorznabSetting{
URL: in.URL,
ApiKey: in.ApiKey,
}
data, err := json.Marshal(setting)
if err != nil {
return nil, errors.Wrap(err, "marshal json")
}
if in.Priority > 128 {
in.Priority = 128
}
if in.Priority < 1 {
in.Priority = 1
}
indexer := ent.Indexers{
ID: in.ID,
Name: in.Name,
Implementation: "torznab",
Settings: string(data),
Priority: in.Priority,
Disabled: in.Disabled,
SeedRatio: in.SeedRatio,
APIKey: in.ApiKey,
URL: in.URL,
}
err = s.db.SaveIndexer(&indexer)
err := s.db.SaveIndexer(&indexer)
if err != nil {
return nil, errors.Wrap(err, "add ")
}
@@ -183,12 +177,12 @@ func (s *Server) DeleteTorznabInfo(c *gin.Context) (interface{}, error) {
if err != nil {
return nil, fmt.Errorf("id is not correct: %v", ids)
}
s.db.DeleteTorznab(id)
s.db.DeleteIndexer(id)
return "success", nil
}
func (s *Server) GetAllIndexers(c *gin.Context) (interface{}, error) {
indexers := s.db.GetAllTorznabInfo()
indexers := s.db.GetAllIndexers()
if len(indexers) == 0 {
return nil, nil
}
@@ -316,11 +310,16 @@ func (s *Server) SaveProwlarrSetting(c *gin.Context) (interface{}, error) {
if err := c.ShouldBindJSON(&in); err != nil {
return nil, err
}
if !in.Disabled {
client := prowlarr.New(in.ApiKey, in.URL)
if _, err := client.GetIndexers(prowlarr.TV); err != nil {
return nil, errors.Wrap(err, "connect to prowlarr error")
if in.Disabled {
if err := s.core.DeleteAllProwlarrIndexers(); err != nil {
return nil, errors.Wrap(err, "delete prowlarr indexers")
}
} else {
if err := s.core.SyncProwlarrIndexers(in.ApiKey, in.URL); err != nil {
return nil, errors.Wrap(err, "verify prowlarr")
}
}
err := s.db.SaveProwlarrSetting(&in)
if err != nil {

View File

@@ -20,7 +20,7 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
@override
void initState() {
super.initState();
_nestedTabController = new TabController(length: 2, vsync: this);
_nestedTabController = new TabController(length: 3, vsync: this);
}
@override
@@ -48,6 +48,9 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
Tab(
text: "下载中",
),
Tab(
text: "做种中",
),
Tab(
text: "历史记录",
),
@@ -56,10 +59,12 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
Builder(builder: (context) {
AsyncValue<List<Activity>>? activitiesWatcher;
if (selectedTab == 1) {
activitiesWatcher = ref.watch(activitiesDataProvider("archive"));
if (selectedTab == 2) {
activitiesWatcher = ref.watch(activitiesDataProvider(ActivityStatus.archive));
} else if (selectedTab == 1) {
activitiesWatcher = ref.watch(activitiesDataProvider(ActivityStatus.seeding));
} else if (selectedTab == 0) {
activitiesWatcher = ref.watch(activitiesDataProvider("active"));
activitiesWatcher = ref.watch(activitiesDataProvider(ActivityStatus.active));
}
return activitiesWatcher!.when(
@@ -135,7 +140,7 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
],
),
),
trailing: selectedTab == 0
trailing: selectedTab != 2
? IconButton(
tooltip: "删除任务",
onPressed: () => onDelete()(ac.id!),
@@ -158,7 +163,7 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
Function(int) onDelete() {
return (id) {
final f = ref
.read(activitiesDataProvider("active").notifier)
.read(activitiesDataProvider(ActivityStatus.active).notifier)
.deleteActivity(id);
showLoadingWithFuture(f);
};

View File

@@ -5,7 +5,7 @@ import 'package:ui/providers/APIs.dart';
import 'package:ui/providers/server_response.dart';
var activitiesDataProvider = AsyncNotifierProvider.autoDispose
.family<ActivityData, List<Activity>, String>(ActivityData.new);
.family<ActivityData, List<Activity>, ActivityStatus>(ActivityData.new);
var mediaHistoryDataProvider = FutureProvider.autoDispose.family(
(ref, arg) async {
@@ -23,32 +23,47 @@ var mediaHistoryDataProvider = FutureProvider.autoDispose.family(
},
);
enum ActivityStatus {
active,
seeding,
archive,
}
class ActivityData
extends AutoDisposeFamilyAsyncNotifier<List<Activity>, String> {
Timer? _timer;
extends AutoDisposeFamilyAsyncNotifier<List<Activity>, ActivityStatus> {
@override
FutureOr<List<Activity>> build(String arg) async {
if (_timer != null) {
_timer!.cancel();
}
FutureOr<List<Activity>> build(ActivityStatus arg) async {
final dio = APIs.getDio();
var status = arg == ActivityStatus.archive
? "archive"
: "active"; //archive or active
var resp =
await dio.get(APIs.activityUrl, queryParameters: {"status": arg});
await dio.get(APIs.activityUrl, queryParameters: {"status": status});
final sp = ServerResponse.fromJson(resp.data);
if (sp.code != 0) {
throw sp.message;
}
List<Activity> activities = List.empty(growable: true);
for (final a in sp.data as List) {
activities.add(Activity.fromJson(a));
var activity = Activity.fromJson(a);
if (arg == ActivityStatus.archive) {
activities.add(activity);
} else {
if (arg == ActivityStatus.active && activity.status != "seeding") {
activities.add(activity);
} else if (arg == ActivityStatus.seeding &&
activity.status == "seeding") {
activities.add(activity);
}
}
}
if (arg == "active") {
if (status == "active") {
//refresh active downloads
_timer = Timer(const Duration(seconds: 5),
() => ref.invalidateSelf()); //Periodically Refresh
final _timer = Timer(const Duration(seconds: 5),
ref.invalidateSelf); //Periodically Refresh
ref.onDispose(_timer.cancel);
}
return activities;
}

View File

@@ -161,6 +161,7 @@ class Indexer {
int? priority;
double? seedRatio;
bool? disabled;
bool? synced;
Indexer(
{this.name,
@@ -169,7 +170,8 @@ class Indexer {
this.id,
this.priority = 50,
this.seedRatio = 0,
this.disabled});
this.disabled,
this.synced});
Indexer.fromJson(Map<String, dynamic> json) {
name = json['name'];
@@ -179,6 +181,7 @@ class Indexer {
priority = json["priority"];
seedRatio = json["seed_ratio"] ?? 0;
disabled = json["disabled"] ?? false;
synced = json["synced"] ?? false;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};

View File

@@ -5,6 +5,7 @@ import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:ui/providers/settings.dart';
import 'package:ui/settings/dialog.dart';
import 'package:ui/widgets/progress_indicator.dart';
import 'package:ui/widgets/utils.dart';
import 'package:ui/widgets/widgets.dart';
class IndexerSettings extends ConsumerStatefulWidget {
@@ -16,22 +17,112 @@ class IndexerSettings extends ConsumerStatefulWidget {
}
class _IndexerState extends ConsumerState<IndexerSettings> {
final _formKey = GlobalKey<FormBuilderState>();
@override
Widget build(BuildContext context) {
var indexers = ref.watch(indexersProvider);
return indexers.when(
data: (value) => Wrap(
children: List.generate(value.length + 1, (i) {
if (i < value.length) {
var indexer = value[i];
return SettingsCard(
onTap: () => showIndexerDetails(indexer),
child: Text(indexer.name ?? ""));
}
return SettingsCard(
onTap: () => showIndexerDetails(Indexer()),
child: const Icon(Icons.add));
}),
data: (value) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(top: 10, bottom: 10, left: 10),
child: Text("Prowlarr 设置", style: TextStyle(fontSize: 18)),
),
Padding(
padding: EdgeInsets.only(left: 20), child: prowlarrSetting()),
Divider(),
Padding(
padding: EdgeInsets.only(top: 10, bottom: 10, left: 10),
child: Text("索引器列表", style: TextStyle(fontSize: 18)),
),
Padding(
padding: EdgeInsets.only(left: 20),
child: Wrap(
children: List.generate(value.length + 1, (i) {
if (i < value.length) {
var indexer = value[i];
return SettingsCard(
onTap: () => showIndexerDetails(indexer),
child: Text(indexer.name ?? ""));
}
return SettingsCard(
onTap: () => showIndexerDetails(Indexer()),
child: const Icon(Icons.add));
}),
)),
],
);
},
error: (err, trace) => PoNetworkError(err: err),
loading: () => const MyProgressIndicator());
}
Widget prowlarrSetting() {
var ps = ref.watch(prowlarrSettingDataProvider);
return ps.when(
data: (v) => FormBuilder(
key: _formKey, //设置globalKey用于后面获取FormState
autovalidateMode: AutovalidateMode.onUserInteraction,
initialValue: {
"api_key": v.apiKey,
"url": v.url,
"disabled": v.disabled
},
child: Column(
children: [
FormBuilderTextField(
name: "url",
decoration: const InputDecoration(
labelText: "Prowlarr URL",
icon: Icon(Icons.web),
hintText: "http://10.0.0.8:9696"),
validator: FormBuilderValidators.required(),
),
FormBuilderTextField(
name: "api_key",
decoration: const InputDecoration(
labelText: "API Key",
icon: Icon(Icons.key),
helperText: "Prowlarr 设置 -> 通用 -> API 密钥"),
validator: FormBuilderValidators.required(),
),
FormBuilderSwitch(
name: "disabled",
title: const Text("禁用 Prowlarr"),
decoration:
InputDecoration(icon: Icon(Icons.do_not_disturb)),
),
Center(
child: Padding(
padding: const EdgeInsets.all(10),
child: ElevatedButton(
onPressed: () {
if (_formKey.currentState!.saveAndValidate()) {
var values = _formKey.currentState!.value;
var f = ref
.read(prowlarrSettingDataProvider.notifier)
.save(ProwlarrSetting(
apiKey: values["api_key"],
url: values["url"],
disabled: values["disabled"]))
.then((v) {
showSnakeBar("更新成功");
ref.invalidate(indexersProvider);
});
showLoadingWithFuture(f);
}
},
child: const Padding(
padding: EdgeInsets.all(10),
child: Text("保存"),
)),
),
)
],
),
),
error: (err, trace) => PoNetworkError(err: err),
loading: () => const MyProgressIndicator());
@@ -54,6 +145,7 @@ class _IndexerState extends ConsumerState<IndexerSettings> {
child: Column(
children: [
FormBuilderDropdown(
enabled: indexer.synced != true,
name: "impl",
decoration: const InputDecoration(labelText: "类型"),
items: const [
@@ -61,24 +153,28 @@ class _IndexerState extends ConsumerState<IndexerSettings> {
],
),
FormBuilderTextField(
enabled: indexer.synced != true,
name: "name",
decoration: Commons.requiredTextFieldStyle(text: "名称"),
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: FormBuilderValidators.required(),
),
FormBuilderTextField(
enabled: indexer.synced != true,
name: "url",
decoration: Commons.requiredTextFieldStyle(text: "地址"),
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: FormBuilderValidators.required(),
),
FormBuilderTextField(
enabled: indexer.synced != true,
name: "api_key",
decoration: Commons.requiredTextFieldStyle(text: "API Key"),
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: FormBuilderValidators.required(),
),
FormBuilderTextField(
enabled: indexer.synced != true,
name: "priority",
decoration: const InputDecoration(
labelText: "索引优先级",
@@ -88,6 +184,7 @@ class _IndexerState extends ConsumerState<IndexerSettings> {
validator: FormBuilderValidators.positiveNumber(),
),
FormBuilderTextField(
enabled: indexer.synced != true,
name: "seed_ratio",
decoration: const InputDecoration(
labelText: "做种率",
@@ -97,7 +194,10 @@ class _IndexerState extends ConsumerState<IndexerSettings> {
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: FormBuilderValidators.numeric(),
),
FormBuilderSwitch(name: "disabled", title: const Text("禁用此索引器"))
FormBuilderSwitch(
enabled: indexer.synced != true,
name: "disabled",
title: const Text("禁用此索引器"))
],
),
);
@@ -122,6 +222,11 @@ class _IndexerState extends ConsumerState<IndexerSettings> {
}
return showSettingDialog(
context, "索引器", indexer.id != null, body, onSubmit, onDelete);
context,
indexer.synced != true?"索引器":"Prowlarr 索引器",
(indexer.id != null) && (indexer.synced != true),
body,
onSubmit,
onDelete);
}
}

View File

@@ -6,7 +6,6 @@ import 'package:ui/settings/general.dart';
import 'package:ui/settings/importlist.dart';
import 'package:ui/settings/indexer.dart';
import 'package:ui/settings/notifier.dart';
import 'package:ui/settings/prowlarr.dart';
import 'package:ui/settings/storage.dart';
class SystemSettingsPage extends ConsumerStatefulWidget {
@@ -27,7 +26,6 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
children: [
getExpansionTile("常规", const GeneralSettings()),
getExpansionTile("索引器", const IndexerSettings()),
getExpansionTile("Prowlarr 设置", const ProwlarrSettingPage()),
getExpansionTile("下载器", const DownloaderSettings()),
getExpansionTile("存储", const StorageSettings()),
getExpansionTile("通知客户端", const NotifierSettings()),

View File

@@ -23,7 +23,7 @@ class ResourceList extends ConsumerWidget {
seasonNumber: seasonNum,
episodeNumber: episodeNum
)));
return torrents.when(
var widgets = torrents.when(
data: (v) {
bool hasPrivate = false;
for (final item in v) {
@@ -83,5 +83,9 @@ class ResourceList extends ConsumerWidget {
: Text("$err");
},
loading: () => const MyProgressIndicator());
return isSmallScreen(context)
? SingleChildScrollView(
scrollDirection: Axis.horizontal, child: widgets)
: widgets;
}
}