mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-24 04:30:47 +08:00
Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be07e457d0 | ||
|
|
2cdd6e3740 | ||
|
|
fa2968f01a | ||
|
|
36f24a7e04 | ||
|
|
ecc7465028 | ||
|
|
3af4ac795e | ||
|
|
af2a30405c | ||
|
|
ba3f6de852 | ||
|
|
7d5ce8ba97 | ||
|
|
b136b9167f | ||
|
|
f0f3281428 | ||
|
|
196ba6635f | ||
|
|
b61b7f082e | ||
|
|
105b296ba2 | ||
|
|
c4d153f15b | ||
|
|
d2619120da | ||
|
|
fbfee65a50 | ||
|
|
c433ccaa0e | ||
|
|
58428405b0 | ||
|
|
45cd94f65b | ||
|
|
53cbca3101 | ||
|
|
576956e271 | ||
|
|
31d20b4f36 | ||
|
|
d026dc4eec | ||
|
|
e472d67c79 | ||
|
|
2165a8c533 | ||
|
|
0c3b5a6907 | ||
|
|
aaa006a322 | ||
|
|
a83f860624 | ||
|
|
b0c325bc4b | ||
|
|
a0431df1ee | ||
|
|
7b02eeac51 | ||
|
|
66a307f202 | ||
|
|
ae611943c3 | ||
|
|
4fd11540cd | ||
|
|
587a28127b | ||
|
|
05ae58030c | ||
|
|
f1c4e306f4 | ||
|
|
949b6e5188 | ||
|
|
0d4b453d0a | ||
|
|
bce4d93ab1 | ||
|
|
36b72e6461 | ||
|
|
62417727f9 | ||
|
|
03f72b9d86 | ||
|
|
c17cf750e5 | ||
|
|
b176253fc4 | ||
|
|
1e2d8b8520 | ||
|
|
3739f2c960 | ||
|
|
bb6da47efb | ||
|
|
c28373bde1 | ||
|
|
8ce7045466 | ||
|
|
0b1bd8226d | ||
|
|
e67413cec2 | ||
|
|
2da02fa706 | ||
|
|
bc50dd888a | ||
|
|
0305c0709d |
@@ -27,21 +27,22 @@
|
||||
|
||||
- [x] 电视剧自动追踪下载
|
||||
- [x] 电影自动追踪下载
|
||||
- [x] webdav 存储支持,配合 [alist](https://github.com/alist-org/alist) 或阿里云等实现更多功能
|
||||
- [x] 本地、webdav、 [alist](https://github.com/alist-org/alist) 存储支持,使用 alist 存储支持秒传功能
|
||||
- [x] 事件通知推送,目前支持 Pushover和 Bark,还在扩充中
|
||||
- [x] 后台代理支持
|
||||
- [x] TMDB 代理支持
|
||||
- [x] 用户认证
|
||||
- [x] plex 刮削支持
|
||||
- [x] NFO 刮削文件支持
|
||||
- [x] BT/PT 支持
|
||||
- [x] qbittorrent/transmission客户端支持
|
||||
- [x] 支持导入plex watchlist,plex里标记,自动导入polaris
|
||||
- [x] and more...
|
||||
|
||||
## Todos
|
||||
|
||||
|
||||
- [ ] 更多通知客户端支持
|
||||
- [ ] 第三方watchlist导入支持
|
||||
- [ ] 更多第三方watchlist导入支持
|
||||
- [ ] 手机客户端
|
||||
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ type Limiter struct {
|
||||
}
|
||||
|
||||
type ProwlarrSetting struct {
|
||||
ApiKey string `json:"api_key"`
|
||||
URL string `json:"url"`
|
||||
Disabled bool `json:"disabled"`
|
||||
ApiKey string `json:"api_key"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
17
db/db.go
17
db/db.go
@@ -374,6 +374,15 @@ func (s *StorageInfo) ToWebDavSetting() WebdavSetting {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StorageInfo) ToAlistSetting() WebdavSetting {
|
||||
return WebdavSetting{
|
||||
URL: s.Settings["url"],
|
||||
User: s.Settings["user"],
|
||||
Password: s.Settings["password"],
|
||||
ChangeFileHash: s.Settings["change_file_hash"],
|
||||
}
|
||||
}
|
||||
|
||||
type WebdavSetting struct {
|
||||
URL string `json:"url"`
|
||||
User string `json:"user"`
|
||||
@@ -432,7 +441,7 @@ type Storage struct {
|
||||
}
|
||||
|
||||
func (s *Storage) ToWebDavSetting() WebdavSetting {
|
||||
if s.Implementation != storage.ImplementationWebdav {
|
||||
if s.Implementation != storage.ImplementationWebdav && s.Implementation != storage.ImplementationAlist{
|
||||
panic("not webdav storage")
|
||||
}
|
||||
var webdavSetting WebdavSetting
|
||||
@@ -483,7 +492,8 @@ func (c *Client) SaveHistoryRecord(h ent.History) (*ent.History, error) {
|
||||
}
|
||||
return c.ent.History.Create().SetMediaID(h.MediaID).SetEpisodeID(h.EpisodeID).SetDate(time.Now()).
|
||||
SetStatus(h.Status).SetTargetDir(h.TargetDir).SetSourceTitle(h.SourceTitle).SetIndexerID(h.IndexerID).
|
||||
SetDownloadClientID(h.DownloadClientID).SetSize(h.Size).SetSaved(h.Saved).SetLink(h.Link).Save(context.TODO())
|
||||
SetDownloadClientID(h.DownloadClientID).SetSize(h.Size).SetSaved(h.Saved).SetSeasonNum(h.SeasonNum).
|
||||
SetEpisodeNums(h.EpisodeNums).SetLink(h.Link).Save(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) SetHistoryStatus(id int, status history.Status) error {
|
||||
@@ -661,7 +671,6 @@ func (c *Client) AddBlacklistItem(item *ent.Blacklist) error {
|
||||
return c.ent.Blacklist.Create().SetType(item.Type).SetValue(item.Value).SetNotes(item.Notes).Exec(context.Background())
|
||||
}
|
||||
|
||||
|
||||
func (c *Client) GetProwlarrSetting() (*ProwlarrSetting, error) {
|
||||
s := c.GetSetting(SettingProwlarrInfo)
|
||||
if s == "" {
|
||||
@@ -680,4 +689,4 @@ func (c *Client) SaveProwlarrSetting(se *ProwlarrSetting) error {
|
||||
return err
|
||||
}
|
||||
return c.SetSetting(SettingProwlarrInfo, string(data))
|
||||
}
|
||||
}
|
||||
|
||||
13
doc/alist.md
Normal file
13
doc/alist.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# alist 对接
|
||||
|
||||
> 本程序可以把alist作为一个存储后台使用,下载完成的电影电视剧上传到alist对应的文件夹。配合阿里云、夸克云盘等实现云盘NAS功能。目前支持两种对接方式,webdav和直接对接
|
||||
|
||||
## webdav
|
||||
|
||||
使用webdav形式对接本程序,支持程序所有功能,但是不支持秒传,上传会比较慢
|
||||
|
||||
## alist 直接对接
|
||||
|
||||
存储设置里选择 alist,填入对应的信息即可。
|
||||
|
||||
优点:支持秒传,上传速度快。缺点:部分功能无法使用(plex和nfo文件刮削)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 MiB After Width: | Height: | Size: 843 KiB |
@@ -9,20 +9,22 @@
|
||||
```yaml
|
||||
services:
|
||||
polaris:
|
||||
image: ghcr.io/simon-ding/polaris:latest
|
||||
image: ghcr.io/simon-ding/polaris:latest
|
||||
restart: always
|
||||
environment:
|
||||
- PUID=99
|
||||
- PGID=100
|
||||
- TZ=Asia/Shanghai
|
||||
- PUID=99 #程序运行的用户UID
|
||||
- PGID=100 #程序运行的用户GID
|
||||
- TZ=Asia/Shanghai #时区
|
||||
volumes:
|
||||
- <配置文件路径>:/app/data #程序配置文件路径
|
||||
- <下载路径>:/downloads #下载路径,需要和下载客户端配置一致
|
||||
- <媒体文件路径>:/data #媒体数据存储路径,也可以启动自己配置webdav存储
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 8080:8080 #端口映射,冒号前的端口可自行改为需要的
|
||||
```
|
||||
|
||||
> latest为发布版本,如果你追求新功能,且能接受bug,可以使用main tag
|
||||
|
||||
### 1.2 Docker 方式安装
|
||||
|
||||
也可以通过原始 docker 命令的方式安装 Polaris:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"polaris/ent/history"
|
||||
"strings"
|
||||
@@ -19,8 +20,12 @@ type History struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
// MediaID holds the value of the "media_id" field.
|
||||
MediaID int `json:"media_id,omitempty"`
|
||||
// EpisodeID holds the value of the "episode_id" field.
|
||||
// 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.
|
||||
SeasonNum int `json:"season_num,omitempty"`
|
||||
// SourceTitle holds the value of the "source_title" field.
|
||||
SourceTitle string `json:"source_title,omitempty"`
|
||||
// Date holds the value of the "date" field.
|
||||
@@ -47,7 +52,9 @@ func (*History) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case history.FieldID, history.FieldMediaID, history.FieldEpisodeID, history.FieldSize, history.FieldDownloadClientID, history.FieldIndexerID:
|
||||
case history.FieldEpisodeNums:
|
||||
values[i] = new([]byte)
|
||||
case history.FieldID, history.FieldMediaID, history.FieldEpisodeID, history.FieldSeasonNum, history.FieldSize, history.FieldDownloadClientID, history.FieldIndexerID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case history.FieldSourceTitle, history.FieldTargetDir, history.FieldLink, history.FieldStatus, history.FieldSaved:
|
||||
values[i] = new(sql.NullString)
|
||||
@@ -86,6 +93,20 @@ func (h *History) assignValues(columns []string, values []any) error {
|
||||
} 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])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &h.EpisodeNums); err != nil {
|
||||
return fmt.Errorf("unmarshal field episode_nums: %w", err)
|
||||
}
|
||||
}
|
||||
case history.FieldSeasonNum:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field season_num", values[i])
|
||||
} else if value.Valid {
|
||||
h.SeasonNum = int(value.Int64)
|
||||
}
|
||||
case history.FieldSourceTitle:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field source_title", values[i])
|
||||
@@ -182,6 +203,12 @@ func (h *History) String() string {
|
||||
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(", ")
|
||||
builder.WriteString("season_num=")
|
||||
builder.WriteString(fmt.Sprintf("%v", h.SeasonNum))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("source_title=")
|
||||
builder.WriteString(h.SourceTitle)
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -17,6 +17,10 @@ const (
|
||||
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.
|
||||
FieldSeasonNum = "season_num"
|
||||
// FieldSourceTitle holds the string denoting the source_title field in the database.
|
||||
FieldSourceTitle = "source_title"
|
||||
// FieldDate holds the string denoting the date field in the database.
|
||||
@@ -44,6 +48,8 @@ var Columns = []string{
|
||||
FieldID,
|
||||
FieldMediaID,
|
||||
FieldEpisodeID,
|
||||
FieldEpisodeNums,
|
||||
FieldSeasonNum,
|
||||
FieldSourceTitle,
|
||||
FieldDate,
|
||||
FieldTargetDir,
|
||||
@@ -114,6 +120,11 @@ 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()
|
||||
}
|
||||
|
||||
// BySourceTitle orders the results by the source_title field.
|
||||
func BySourceTitle(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSourceTitle, opts...).ToFunc()
|
||||
|
||||
@@ -64,6 +64,11 @@ 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))
|
||||
}
|
||||
|
||||
// SourceTitle applies equality check predicate on the "source_title" field. It's identical to SourceTitleEQ.
|
||||
func SourceTitle(v string) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldSourceTitle, v))
|
||||
@@ -194,6 +199,66 @@ 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))
|
||||
}
|
||||
|
||||
// EpisodeNumsNotNil applies the NotNil predicate on the "episode_nums" field.
|
||||
func EpisodeNumsNotNil() predicate.History {
|
||||
return predicate.History(sql.FieldNotNull(FieldEpisodeNums))
|
||||
}
|
||||
|
||||
// SeasonNumEQ applies the EQ predicate on the "season_num" field.
|
||||
func SeasonNumEQ(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumNEQ applies the NEQ predicate on the "season_num" field.
|
||||
func SeasonNumNEQ(v int) predicate.History {
|
||||
return predicate.History(sql.FieldNEQ(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumIn applies the In predicate on the "season_num" field.
|
||||
func SeasonNumIn(vs ...int) predicate.History {
|
||||
return predicate.History(sql.FieldIn(FieldSeasonNum, vs...))
|
||||
}
|
||||
|
||||
// SeasonNumNotIn applies the NotIn predicate on the "season_num" field.
|
||||
func SeasonNumNotIn(vs ...int) predicate.History {
|
||||
return predicate.History(sql.FieldNotIn(FieldSeasonNum, vs...))
|
||||
}
|
||||
|
||||
// SeasonNumGT applies the GT predicate on the "season_num" field.
|
||||
func SeasonNumGT(v int) predicate.History {
|
||||
return predicate.History(sql.FieldGT(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumGTE applies the GTE predicate on the "season_num" field.
|
||||
func SeasonNumGTE(v int) predicate.History {
|
||||
return predicate.History(sql.FieldGTE(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumLT applies the LT predicate on the "season_num" field.
|
||||
func SeasonNumLT(v int) predicate.History {
|
||||
return predicate.History(sql.FieldLT(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumLTE applies the LTE predicate on the "season_num" field.
|
||||
func SeasonNumLTE(v int) predicate.History {
|
||||
return predicate.History(sql.FieldLTE(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumIsNil applies the IsNil predicate on the "season_num" field.
|
||||
func SeasonNumIsNil() predicate.History {
|
||||
return predicate.History(sql.FieldIsNull(FieldSeasonNum))
|
||||
}
|
||||
|
||||
// SeasonNumNotNil applies the NotNil predicate on the "season_num" field.
|
||||
func SeasonNumNotNil() predicate.History {
|
||||
return predicate.History(sql.FieldNotNull(FieldSeasonNum))
|
||||
}
|
||||
|
||||
// SourceTitleEQ applies the EQ predicate on the "source_title" field.
|
||||
func SourceTitleEQ(v string) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldSourceTitle, v))
|
||||
|
||||
@@ -40,6 +40,26 @@ func (hc *HistoryCreate) SetNillableEpisodeID(i *int) *HistoryCreate {
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetEpisodeNums sets the "episode_nums" field.
|
||||
func (hc *HistoryCreate) SetEpisodeNums(i []int) *HistoryCreate {
|
||||
hc.mutation.SetEpisodeNums(i)
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetSeasonNum sets the "season_num" field.
|
||||
func (hc *HistoryCreate) SetSeasonNum(i int) *HistoryCreate {
|
||||
hc.mutation.SetSeasonNum(i)
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetNillableSeasonNum sets the "season_num" field if the given value is not nil.
|
||||
func (hc *HistoryCreate) SetNillableSeasonNum(i *int) *HistoryCreate {
|
||||
if i != nil {
|
||||
hc.SetSeasonNum(*i)
|
||||
}
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetSourceTitle sets the "source_title" field.
|
||||
func (hc *HistoryCreate) SetSourceTitle(s string) *HistoryCreate {
|
||||
hc.mutation.SetSourceTitle(s)
|
||||
@@ -234,6 +254,14 @@ func (hc *HistoryCreate) createSpec() (*History, *sqlgraph.CreateSpec) {
|
||||
_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
|
||||
}
|
||||
if value, ok := hc.mutation.SeasonNum(); ok {
|
||||
_spec.SetField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
_node.SeasonNum = value
|
||||
}
|
||||
if value, ok := hc.mutation.SourceTitle(); ok {
|
||||
_spec.SetField(history.FieldSourceTitle, field.TypeString, value)
|
||||
_node.SourceTitle = value
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/dialect/sql/sqljson"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
@@ -76,6 +77,51 @@ func (hu *HistoryUpdate) ClearEpisodeID() *HistoryUpdate {
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetEpisodeNums sets the "episode_nums" field.
|
||||
func (hu *HistoryUpdate) SetEpisodeNums(i []int) *HistoryUpdate {
|
||||
hu.mutation.SetEpisodeNums(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// AppendEpisodeNums appends i to the "episode_nums" field.
|
||||
func (hu *HistoryUpdate) AppendEpisodeNums(i []int) *HistoryUpdate {
|
||||
hu.mutation.AppendEpisodeNums(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// ClearEpisodeNums clears the value of the "episode_nums" field.
|
||||
func (hu *HistoryUpdate) ClearEpisodeNums() *HistoryUpdate {
|
||||
hu.mutation.ClearEpisodeNums()
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetSeasonNum sets the "season_num" field.
|
||||
func (hu *HistoryUpdate) SetSeasonNum(i int) *HistoryUpdate {
|
||||
hu.mutation.ResetSeasonNum()
|
||||
hu.mutation.SetSeasonNum(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetNillableSeasonNum sets the "season_num" field if the given value is not nil.
|
||||
func (hu *HistoryUpdate) SetNillableSeasonNum(i *int) *HistoryUpdate {
|
||||
if i != nil {
|
||||
hu.SetSeasonNum(*i)
|
||||
}
|
||||
return hu
|
||||
}
|
||||
|
||||
// AddSeasonNum adds i to the "season_num" field.
|
||||
func (hu *HistoryUpdate) AddSeasonNum(i int) *HistoryUpdate {
|
||||
hu.mutation.AddSeasonNum(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// ClearSeasonNum clears the value of the "season_num" field.
|
||||
func (hu *HistoryUpdate) ClearSeasonNum() *HistoryUpdate {
|
||||
hu.mutation.ClearSeasonNum()
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetSourceTitle sets the "source_title" field.
|
||||
func (hu *HistoryUpdate) SetSourceTitle(s string) *HistoryUpdate {
|
||||
hu.mutation.SetSourceTitle(s)
|
||||
@@ -316,6 +362,26 @@ func (hu *HistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if hu.mutation.EpisodeIDCleared() {
|
||||
_spec.ClearField(history.FieldEpisodeID, field.TypeInt)
|
||||
}
|
||||
if value, ok := hu.mutation.EpisodeNums(); ok {
|
||||
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := hu.mutation.AppendedEpisodeNums(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, history.FieldEpisodeNums, value)
|
||||
})
|
||||
}
|
||||
if hu.mutation.EpisodeNumsCleared() {
|
||||
_spec.ClearField(history.FieldEpisodeNums, field.TypeJSON)
|
||||
}
|
||||
if value, ok := hu.mutation.SeasonNum(); ok {
|
||||
_spec.SetField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := hu.mutation.AddedSeasonNum(); ok {
|
||||
_spec.AddField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
}
|
||||
if hu.mutation.SeasonNumCleared() {
|
||||
_spec.ClearField(history.FieldSeasonNum, field.TypeInt)
|
||||
}
|
||||
if value, ok := hu.mutation.SourceTitle(); ok {
|
||||
_spec.SetField(history.FieldSourceTitle, field.TypeString, value)
|
||||
}
|
||||
@@ -432,6 +498,51 @@ func (huo *HistoryUpdateOne) ClearEpisodeID() *HistoryUpdateOne {
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetEpisodeNums sets the "episode_nums" field.
|
||||
func (huo *HistoryUpdateOne) SetEpisodeNums(i []int) *HistoryUpdateOne {
|
||||
huo.mutation.SetEpisodeNums(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// AppendEpisodeNums appends i to the "episode_nums" field.
|
||||
func (huo *HistoryUpdateOne) AppendEpisodeNums(i []int) *HistoryUpdateOne {
|
||||
huo.mutation.AppendEpisodeNums(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// ClearEpisodeNums clears the value of the "episode_nums" field.
|
||||
func (huo *HistoryUpdateOne) ClearEpisodeNums() *HistoryUpdateOne {
|
||||
huo.mutation.ClearEpisodeNums()
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetSeasonNum sets the "season_num" field.
|
||||
func (huo *HistoryUpdateOne) SetSeasonNum(i int) *HistoryUpdateOne {
|
||||
huo.mutation.ResetSeasonNum()
|
||||
huo.mutation.SetSeasonNum(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetNillableSeasonNum sets the "season_num" field if the given value is not nil.
|
||||
func (huo *HistoryUpdateOne) SetNillableSeasonNum(i *int) *HistoryUpdateOne {
|
||||
if i != nil {
|
||||
huo.SetSeasonNum(*i)
|
||||
}
|
||||
return huo
|
||||
}
|
||||
|
||||
// AddSeasonNum adds i to the "season_num" field.
|
||||
func (huo *HistoryUpdateOne) AddSeasonNum(i int) *HistoryUpdateOne {
|
||||
huo.mutation.AddSeasonNum(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// ClearSeasonNum clears the value of the "season_num" field.
|
||||
func (huo *HistoryUpdateOne) ClearSeasonNum() *HistoryUpdateOne {
|
||||
huo.mutation.ClearSeasonNum()
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetSourceTitle sets the "source_title" field.
|
||||
func (huo *HistoryUpdateOne) SetSourceTitle(s string) *HistoryUpdateOne {
|
||||
huo.mutation.SetSourceTitle(s)
|
||||
@@ -702,6 +813,26 @@ func (huo *HistoryUpdateOne) sqlSave(ctx context.Context) (_node *History, err e
|
||||
if huo.mutation.EpisodeIDCleared() {
|
||||
_spec.ClearField(history.FieldEpisodeID, field.TypeInt)
|
||||
}
|
||||
if value, ok := huo.mutation.EpisodeNums(); ok {
|
||||
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := huo.mutation.AppendedEpisodeNums(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, history.FieldEpisodeNums, value)
|
||||
})
|
||||
}
|
||||
if huo.mutation.EpisodeNumsCleared() {
|
||||
_spec.ClearField(history.FieldEpisodeNums, field.TypeJSON)
|
||||
}
|
||||
if value, ok := huo.mutation.SeasonNum(); ok {
|
||||
_spec.SetField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := huo.mutation.AddedSeasonNum(); ok {
|
||||
_spec.AddField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
}
|
||||
if huo.mutation.SeasonNumCleared() {
|
||||
_spec.ClearField(history.FieldSeasonNum, field.TypeInt)
|
||||
}
|
||||
if value, ok := huo.mutation.SourceTitle(); ok {
|
||||
_spec.SetField(history.FieldSourceTitle, field.TypeString, value)
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ var (
|
||||
{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},
|
||||
{Name: "date", Type: field.TypeTime},
|
||||
{Name: "target_dir", Type: field.TypeString},
|
||||
@@ -178,7 +180,7 @@ var (
|
||||
StoragesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString, Unique: true},
|
||||
{Name: "implementation", Type: field.TypeEnum, Enums: []string{"webdav", "local"}},
|
||||
{Name: "implementation", Type: field.TypeEnum, Enums: []string{"webdav", "local", "alist"}},
|
||||
{Name: "tv_path", Type: field.TypeString, Nullable: true},
|
||||
{Name: "movie_path", Type: field.TypeString, Nullable: true},
|
||||
{Name: "settings", Type: field.TypeString, Nullable: true},
|
||||
|
||||
199
ent/mutation.go
199
ent/mutation.go
@@ -2336,6 +2336,10 @@ type HistoryMutation struct {
|
||||
addmedia_id *int
|
||||
episode_id *int
|
||||
addepisode_id *int
|
||||
episode_nums *[]int
|
||||
appendepisode_nums []int
|
||||
season_num *int
|
||||
addseason_num *int
|
||||
source_title *string
|
||||
date *time.Time
|
||||
target_dir *string
|
||||
@@ -2578,6 +2582,141 @@ func (m *HistoryMutation) ResetEpisodeID() {
|
||||
delete(m.clearedFields, history.FieldEpisodeID)
|
||||
}
|
||||
|
||||
// SetEpisodeNums sets the "episode_nums" field.
|
||||
func (m *HistoryMutation) SetEpisodeNums(i []int) {
|
||||
m.episode_nums = &i
|
||||
m.appendepisode_nums = nil
|
||||
}
|
||||
|
||||
// EpisodeNums returns the value of the "episode_nums" field in the mutation.
|
||||
func (m *HistoryMutation) EpisodeNums() (r []int, exists bool) {
|
||||
v := m.episode_nums
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldEpisodeNums returns the old "episode_nums" 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) OldEpisodeNums(ctx context.Context) (v []int, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldEpisodeNums is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldEpisodeNums requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldEpisodeNums: %w", err)
|
||||
}
|
||||
return oldValue.EpisodeNums, nil
|
||||
}
|
||||
|
||||
// AppendEpisodeNums adds i to the "episode_nums" field.
|
||||
func (m *HistoryMutation) AppendEpisodeNums(i []int) {
|
||||
m.appendepisode_nums = append(m.appendepisode_nums, i...)
|
||||
}
|
||||
|
||||
// AppendedEpisodeNums returns the list of values that were appended to the "episode_nums" field in this mutation.
|
||||
func (m *HistoryMutation) AppendedEpisodeNums() ([]int, bool) {
|
||||
if len(m.appendepisode_nums) == 0 {
|
||||
return nil, false
|
||||
}
|
||||
return m.appendepisode_nums, true
|
||||
}
|
||||
|
||||
// ClearEpisodeNums clears the value of the "episode_nums" field.
|
||||
func (m *HistoryMutation) ClearEpisodeNums() {
|
||||
m.episode_nums = nil
|
||||
m.appendepisode_nums = nil
|
||||
m.clearedFields[history.FieldEpisodeNums] = struct{}{}
|
||||
}
|
||||
|
||||
// EpisodeNumsCleared returns if the "episode_nums" field was cleared in this mutation.
|
||||
func (m *HistoryMutation) EpisodeNumsCleared() bool {
|
||||
_, ok := m.clearedFields[history.FieldEpisodeNums]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetEpisodeNums resets all changes to the "episode_nums" field.
|
||||
func (m *HistoryMutation) ResetEpisodeNums() {
|
||||
m.episode_nums = nil
|
||||
m.appendepisode_nums = nil
|
||||
delete(m.clearedFields, history.FieldEpisodeNums)
|
||||
}
|
||||
|
||||
// SetSeasonNum sets the "season_num" field.
|
||||
func (m *HistoryMutation) SetSeasonNum(i int) {
|
||||
m.season_num = &i
|
||||
m.addseason_num = nil
|
||||
}
|
||||
|
||||
// SeasonNum returns the value of the "season_num" field in the mutation.
|
||||
func (m *HistoryMutation) SeasonNum() (r int, exists bool) {
|
||||
v := m.season_num
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldSeasonNum returns the old "season_num" 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) OldSeasonNum(ctx context.Context) (v int, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldSeasonNum is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldSeasonNum requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldSeasonNum: %w", err)
|
||||
}
|
||||
return oldValue.SeasonNum, nil
|
||||
}
|
||||
|
||||
// AddSeasonNum adds i to the "season_num" field.
|
||||
func (m *HistoryMutation) AddSeasonNum(i int) {
|
||||
if m.addseason_num != nil {
|
||||
*m.addseason_num += i
|
||||
} else {
|
||||
m.addseason_num = &i
|
||||
}
|
||||
}
|
||||
|
||||
// AddedSeasonNum returns the value that was added to the "season_num" field in this mutation.
|
||||
func (m *HistoryMutation) AddedSeasonNum() (r int, exists bool) {
|
||||
v := m.addseason_num
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ClearSeasonNum clears the value of the "season_num" field.
|
||||
func (m *HistoryMutation) ClearSeasonNum() {
|
||||
m.season_num = nil
|
||||
m.addseason_num = nil
|
||||
m.clearedFields[history.FieldSeasonNum] = struct{}{}
|
||||
}
|
||||
|
||||
// SeasonNumCleared returns if the "season_num" field was cleared in this mutation.
|
||||
func (m *HistoryMutation) SeasonNumCleared() bool {
|
||||
_, ok := m.clearedFields[history.FieldSeasonNum]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetSeasonNum resets all changes to the "season_num" field.
|
||||
func (m *HistoryMutation) ResetSeasonNum() {
|
||||
m.season_num = nil
|
||||
m.addseason_num = nil
|
||||
delete(m.clearedFields, history.FieldSeasonNum)
|
||||
}
|
||||
|
||||
// SetSourceTitle sets the "source_title" field.
|
||||
func (m *HistoryMutation) SetSourceTitle(s string) {
|
||||
m.source_title = &s
|
||||
@@ -3050,13 +3189,19 @@ 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, 11)
|
||||
fields := make([]string, 0, 13)
|
||||
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)
|
||||
}
|
||||
if m.season_num != nil {
|
||||
fields = append(fields, history.FieldSeasonNum)
|
||||
}
|
||||
if m.source_title != nil {
|
||||
fields = append(fields, history.FieldSourceTitle)
|
||||
}
|
||||
@@ -3096,6 +3241,10 @@ func (m *HistoryMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.MediaID()
|
||||
case history.FieldEpisodeID:
|
||||
return m.EpisodeID()
|
||||
case history.FieldEpisodeNums:
|
||||
return m.EpisodeNums()
|
||||
case history.FieldSeasonNum:
|
||||
return m.SeasonNum()
|
||||
case history.FieldSourceTitle:
|
||||
return m.SourceTitle()
|
||||
case history.FieldDate:
|
||||
@@ -3127,6 +3276,10 @@ func (m *HistoryMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
return m.OldMediaID(ctx)
|
||||
case history.FieldEpisodeID:
|
||||
return m.OldEpisodeID(ctx)
|
||||
case history.FieldEpisodeNums:
|
||||
return m.OldEpisodeNums(ctx)
|
||||
case history.FieldSeasonNum:
|
||||
return m.OldSeasonNum(ctx)
|
||||
case history.FieldSourceTitle:
|
||||
return m.OldSourceTitle(ctx)
|
||||
case history.FieldDate:
|
||||
@@ -3168,6 +3321,20 @@ func (m *HistoryMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetEpisodeID(v)
|
||||
return nil
|
||||
case history.FieldEpisodeNums:
|
||||
v, ok := value.([]int)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetEpisodeNums(v)
|
||||
return nil
|
||||
case history.FieldSeasonNum:
|
||||
v, ok := value.(int)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetSeasonNum(v)
|
||||
return nil
|
||||
case history.FieldSourceTitle:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@@ -3245,6 +3412,9 @@ func (m *HistoryMutation) AddedFields() []string {
|
||||
if m.addepisode_id != nil {
|
||||
fields = append(fields, history.FieldEpisodeID)
|
||||
}
|
||||
if m.addseason_num != nil {
|
||||
fields = append(fields, history.FieldSeasonNum)
|
||||
}
|
||||
if m.addsize != nil {
|
||||
fields = append(fields, history.FieldSize)
|
||||
}
|
||||
@@ -3266,6 +3436,8 @@ func (m *HistoryMutation) AddedField(name string) (ent.Value, bool) {
|
||||
return m.AddedMediaID()
|
||||
case history.FieldEpisodeID:
|
||||
return m.AddedEpisodeID()
|
||||
case history.FieldSeasonNum:
|
||||
return m.AddedSeasonNum()
|
||||
case history.FieldSize:
|
||||
return m.AddedSize()
|
||||
case history.FieldDownloadClientID:
|
||||
@@ -3295,6 +3467,13 @@ func (m *HistoryMutation) AddField(name string, value ent.Value) error {
|
||||
}
|
||||
m.AddEpisodeID(v)
|
||||
return nil
|
||||
case history.FieldSeasonNum:
|
||||
v, ok := value.(int)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddSeasonNum(v)
|
||||
return nil
|
||||
case history.FieldSize:
|
||||
v, ok := value.(int)
|
||||
if !ok {
|
||||
@@ -3327,6 +3506,12 @@ func (m *HistoryMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(history.FieldEpisodeID) {
|
||||
fields = append(fields, history.FieldEpisodeID)
|
||||
}
|
||||
if m.FieldCleared(history.FieldEpisodeNums) {
|
||||
fields = append(fields, history.FieldEpisodeNums)
|
||||
}
|
||||
if m.FieldCleared(history.FieldSeasonNum) {
|
||||
fields = append(fields, history.FieldSeasonNum)
|
||||
}
|
||||
if m.FieldCleared(history.FieldDownloadClientID) {
|
||||
fields = append(fields, history.FieldDownloadClientID)
|
||||
}
|
||||
@@ -3356,6 +3541,12 @@ func (m *HistoryMutation) ClearField(name string) error {
|
||||
case history.FieldEpisodeID:
|
||||
m.ClearEpisodeID()
|
||||
return nil
|
||||
case history.FieldEpisodeNums:
|
||||
m.ClearEpisodeNums()
|
||||
return nil
|
||||
case history.FieldSeasonNum:
|
||||
m.ClearSeasonNum()
|
||||
return nil
|
||||
case history.FieldDownloadClientID:
|
||||
m.ClearDownloadClientID()
|
||||
return nil
|
||||
@@ -3382,6 +3573,12 @@ func (m *HistoryMutation) ResetField(name string) error {
|
||||
case history.FieldEpisodeID:
|
||||
m.ResetEpisodeID()
|
||||
return nil
|
||||
case history.FieldEpisodeNums:
|
||||
m.ResetEpisodeNums()
|
||||
return nil
|
||||
case history.FieldSeasonNum:
|
||||
m.ResetSeasonNum()
|
||||
return nil
|
||||
case history.FieldSourceTitle:
|
||||
m.ResetSourceTitle()
|
||||
return nil
|
||||
|
||||
@@ -66,7 +66,7 @@ func init() {
|
||||
historyFields := schema.History{}.Fields()
|
||||
_ = historyFields
|
||||
// historyDescSize is the schema descriptor for size field.
|
||||
historyDescSize := historyFields[5].Descriptor()
|
||||
historyDescSize := historyFields[7].Descriptor()
|
||||
// history.DefaultSize holds the default value on creation for the size field.
|
||||
history.DefaultSize = historyDescSize.Default.(int)
|
||||
indexersFields := schema.Indexers{}.Fields()
|
||||
|
||||
@@ -14,7 +14,9 @@ type History struct {
|
||||
func (History) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("media_id"),
|
||||
field.Int("episode_id").Optional(),
|
||||
field.Int("episode_id").Optional().Comment("deprecated"),
|
||||
field.Ints("episode_nums").Optional(),
|
||||
field.Int("season_num").Optional(),
|
||||
field.String("source_title"),
|
||||
field.Time("date"),
|
||||
field.String("target_dir"),
|
||||
|
||||
@@ -14,7 +14,7 @@ type Storage struct {
|
||||
func (Storage) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name").Unique(),
|
||||
field.Enum("implementation").Values("webdav", "local"),
|
||||
field.Enum("implementation").Values("webdav", "local", "alist"),
|
||||
field.String("tv_path").Optional(),
|
||||
field.String("movie_path").Optional(),
|
||||
field.String("settings").Optional(),
|
||||
|
||||
@@ -67,6 +67,7 @@ type Implementation string
|
||||
const (
|
||||
ImplementationWebdav Implementation = "webdav"
|
||||
ImplementationLocal Implementation = "local"
|
||||
ImplementationAlist Implementation = "alist"
|
||||
)
|
||||
|
||||
func (i Implementation) String() string {
|
||||
@@ -76,7 +77,7 @@ func (i Implementation) String() string {
|
||||
// ImplementationValidator is a validator for the "implementation" field enum values. It is called by the builders before save.
|
||||
func ImplementationValidator(i Implementation) error {
|
||||
switch i {
|
||||
case ImplementationWebdav, ImplementationLocal:
|
||||
case ImplementationWebdav, ImplementationLocal, ImplementationAlist:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("storage: invalid enum value for implementation field: %q", i)
|
||||
|
||||
196
pkg/alist/alist.go
Normal file
196
pkg/alist/alist.go
Normal file
@@ -0,0 +1,196 @@
|
||||
package alist
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Resposne[T any] struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data T `json:"data"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Username string
|
||||
Password string
|
||||
URL string
|
||||
}
|
||||
|
||||
func New(cfg *Config) *Client {
|
||||
cfg.URL = strings.Trim(cfg.URL, "/")
|
||||
return &Client{
|
||||
cfg: cfg,
|
||||
http: http.DefaultClient,
|
||||
}
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
cfg *Config
|
||||
http *http.Client
|
||||
token string
|
||||
}
|
||||
|
||||
func (c *Client) Login() (string, error) {
|
||||
p := map[string]string{
|
||||
"username": c.cfg.Username,
|
||||
"password": c.cfg.Password,
|
||||
}
|
||||
data, _ := json.Marshal(p)
|
||||
resp, err := c.http.Post(c.cfg.URL+loginUrl, "application/json", bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "login")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
d1, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "read body")
|
||||
}
|
||||
var rp Resposne[map[string]string]
|
||||
|
||||
err = json.Unmarshal(d1, &rp)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "json")
|
||||
}
|
||||
if rp.Code != 200 {
|
||||
return "", errors.Errorf("alist error: code %d, %s", rp.Code, rp.Message)
|
||||
}
|
||||
c.token = rp.Data["token"]
|
||||
return c.token, nil
|
||||
}
|
||||
|
||||
type LsInfo struct {
|
||||
Content []struct {
|
||||
Name string `json:"name"`
|
||||
Size int `json:"size"`
|
||||
IsDir bool `json:"is_dir"`
|
||||
Modified time.Time `json:"modified"`
|
||||
Created time.Time `json:"created"`
|
||||
Sign string `json:"sign"`
|
||||
Thumb string `json:"thumb"`
|
||||
Type int `json:"type"`
|
||||
Hashinfo string `json:"hashinfo"`
|
||||
HashInfo any `json:"hash_info"`
|
||||
} `json:"content"`
|
||||
Total int `json:"total"`
|
||||
Readme string `json:"readme"`
|
||||
Header string `json:"header"`
|
||||
Write bool `json:"write"`
|
||||
Provider string `json:"provider"`
|
||||
}
|
||||
|
||||
func (c *Client) Ls(dir string) (*LsInfo, error) {
|
||||
in := map[string]string{
|
||||
"path": dir,
|
||||
}
|
||||
|
||||
resp, err := c.post(c.cfg.URL+lsUrl, in)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "http")
|
||||
}
|
||||
|
||||
var out Resposne[LsInfo]
|
||||
err = json.Unmarshal(resp, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out.Code != 200 {
|
||||
return nil, errors.Errorf("alist error: code %d, %s", out.Code, out.Message)
|
||||
}
|
||||
return &out.Data, nil
|
||||
}
|
||||
|
||||
func (c *Client) Mkdir(dir string) error {
|
||||
in := map[string]string{
|
||||
"path": dir,
|
||||
}
|
||||
resp, err := c.post(c.cfg.URL+mkdirUrl, in)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "http")
|
||||
}
|
||||
var out Resposne[any]
|
||||
err = json.Unmarshal(resp, &out)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if out.Code != 200 {
|
||||
return errors.Errorf("alist error: code %d, %s", out.Code, out.Message)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) post(url string, body interface{}) ([]byte, error) {
|
||||
data, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(data))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "new request")
|
||||
}
|
||||
|
||||
req.Header.Add("Authorization", c.token)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := c.http.Do(req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "http")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
d1, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "read body")
|
||||
}
|
||||
return d1, nil
|
||||
}
|
||||
|
||||
type UploadStreamResponse struct {
|
||||
Task struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
State int `json:"state"`
|
||||
Status string `json:"status"`
|
||||
Progress int `json:"progress"`
|
||||
Error string `json:"error"`
|
||||
} `json:"task"`
|
||||
}
|
||||
|
||||
func (c *Client) UploadStream(reader io.Reader, size int64, toDir string) (*UploadStreamResponse, error) {
|
||||
req, err := http.NewRequest(http.MethodPut, c.cfg.URL+streamUploadUrl, reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Add("Authorization", c.token)
|
||||
req.Header.Add("File-Path", url.PathEscape(toDir))
|
||||
req.Header.Add("As-Task", "true")
|
||||
req.Header.Add("Content-Type", "application/octet-stream")
|
||||
req.ContentLength = size
|
||||
res, err := c.http.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
d1, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var out Resposne[UploadStreamResponse]
|
||||
err = json.Unmarshal(d1, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out.Code != 200 {
|
||||
return nil, errors.Errorf("alist error: code %d, %s", out.Code, out.Message)
|
||||
}
|
||||
|
||||
return &out.Data, nil
|
||||
}
|
||||
46
pkg/alist/alist_test.go
Normal file
46
pkg/alist/alist_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package alist
|
||||
|
||||
import (
|
||||
"os"
|
||||
"polaris/log"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLogin(t *testing.T) {
|
||||
c := New(&Config{
|
||||
URL: "http://10.0.0.8:5244/",
|
||||
Username: "",
|
||||
Password: "",
|
||||
})
|
||||
cre, err := c.Login()
|
||||
if err != nil {
|
||||
log.Errorf("login fail: %v", err)
|
||||
t.Fail()
|
||||
} else {
|
||||
log.Errorf("login success: %s", cre)
|
||||
}
|
||||
info, err := c.Ls("/aliyun")
|
||||
if err != nil {
|
||||
log.Errorf("ls fail: %v", err)
|
||||
t.Fail()
|
||||
} else {
|
||||
log.Infof("ls results: %+v", info)
|
||||
}
|
||||
|
||||
f, err := os.Open("/Users/simonding/Downloads/Steam Link_1.3.9_APKPure.apk")
|
||||
if err != nil {
|
||||
log.Errorf("openfile: %v", err)
|
||||
t.Fail()
|
||||
} else {
|
||||
defer f.Close()
|
||||
ss, _ := f.Stat()
|
||||
log.Infof("upload file size %d", ss.Size())
|
||||
info, err := c.UploadStream(f, ss.Size(), "/aliyun/Steam Link_1.3.9_APKPure.apk")
|
||||
if err != nil {
|
||||
log.Errorf("upload error: %v", err)
|
||||
t.Fail()
|
||||
} else {
|
||||
log.Infof("upload success: %+v", info)
|
||||
}
|
||||
}
|
||||
}
|
||||
8
pkg/alist/url.go
Normal file
8
pkg/alist/url.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package alist
|
||||
|
||||
const (
|
||||
loginUrl = "/api/auth/login"
|
||||
lsUrl = "/api/fs/list"
|
||||
mkdirUrl = "/api/fs/mkdir"
|
||||
streamUploadUrl = "/api/fs/put"
|
||||
)
|
||||
@@ -7,242 +7,104 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Metadata struct {
|
||||
type Info struct {
|
||||
NameEn string
|
||||
NameCn string
|
||||
Year int
|
||||
Season int
|
||||
Episode int
|
||||
StartEpisode int
|
||||
EndEpisode int
|
||||
Resolution string
|
||||
IsSeasonPack bool
|
||||
}
|
||||
|
||||
func (m *Metadata) IsAcceptable(names... string) bool {
|
||||
func (m *Info) ParseExtraDescription(desc string) {
|
||||
if m.IsSeasonPack { //try to parse episode number with description
|
||||
mm := ParseTv(desc)
|
||||
if mm.StartEpisode > 0 { //sometimes they put episode info in desc text
|
||||
m.IsSeasonPack = false
|
||||
m.StartEpisode = mm.StartEpisode
|
||||
m.EndEpisode = mm.EndEpisode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Info) IsAcceptable(names ...string) bool {
|
||||
re := regexp.MustCompile(`[^\p{L}\w\s]`)
|
||||
|
||||
nameCN := re.ReplaceAllString(strings.ToLower(m.NameCn), " ")
|
||||
nameEN := re.ReplaceAllString(strings.ToLower(m.NameEn), " ")
|
||||
nameCN = strings.Join(strings.Fields(nameCN), " ")
|
||||
nameEN = strings.Join(strings.Fields(nameEN), " ")
|
||||
|
||||
for _, name := range names {
|
||||
re := regexp.MustCompile(`[^\p{L}\w\s]`)
|
||||
name = re.ReplaceAllString(strings.ToLower(name), " ")
|
||||
nameCN := re.ReplaceAllString(strings.ToLower(m.NameCn), " ")
|
||||
nameEN := re.ReplaceAllString(strings.ToLower(m.NameEn), " ")
|
||||
name = strings.Join(strings.Fields(name), " ")
|
||||
nameCN = strings.Join(strings.Fields(nameCN), " ")
|
||||
nameEN = strings.Join(strings.Fields(nameEN), " ")
|
||||
if utils.IsASCII(name) { //ascii name should match words
|
||||
re := regexp.MustCompile(`\b` + name + `\b`)
|
||||
return re.MatchString(nameCN) || re.MatchString(nameEN)
|
||||
if re.MatchString(nameCN) || re.MatchString(nameEN) {
|
||||
return true
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if strings.Contains(nameCN, name) || strings.Contains(nameEN, name) {
|
||||
if strings.Contains(nameCN, name) || strings.Contains(nameEN, name) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
func ParseTv(name string) *Metadata {
|
||||
func ParseTv(name string) *Info {
|
||||
name = strings.ToLower(name)
|
||||
name = strings.ReplaceAll(name, "\u200b", "") //remove unicode hidden character
|
||||
if utils.ContainsChineseChar(name) {
|
||||
return parseChineseName(name)
|
||||
}
|
||||
return parseEnglishName(name)
|
||||
|
||||
return parseName(name)
|
||||
}
|
||||
|
||||
func parseEnglishName(name string) *Metadata {
|
||||
re := regexp.MustCompile(`[^\p{L}\w\s]`)
|
||||
name = re.ReplaceAllString(strings.ToLower(name), " ")
|
||||
newSplits := strings.Split(strings.TrimSpace(name), " ")
|
||||
|
||||
seasonRe := regexp.MustCompile(`^s\d{1,2}`)
|
||||
resRe := regexp.MustCompile(`^\d{3,4}p`)
|
||||
episodeRe := regexp.MustCompile(`e\d{1,3}`)
|
||||
|
||||
var seasonIndex = -1
|
||||
var episodeIndex = -1
|
||||
var resIndex = -1
|
||||
for i, p := range newSplits {
|
||||
p = strings.TrimSpace(p)
|
||||
if p == "" {
|
||||
continue
|
||||
}
|
||||
if seasonRe.MatchString(p) {
|
||||
//season part
|
||||
seasonIndex = i
|
||||
} else if resRe.MatchString(p) {
|
||||
resIndex = i
|
||||
}
|
||||
if i >= seasonIndex && episodeRe.MatchString(p) {
|
||||
episodeIndex = i
|
||||
func adjacentNumber(s string, start int) (n1 int, l int) {
|
||||
runes := []rune(s)
|
||||
if start > len(runes)-1 { //out of bound
|
||||
return -1, -1
|
||||
}
|
||||
var n []rune
|
||||
for i := start; i < len(runes); i++ {
|
||||
k := runes[i]
|
||||
if (k < '0' || k > '9') && !chineseNum[k] { //not digit anymore
|
||||
break
|
||||
}
|
||||
n = append(n, k)
|
||||
}
|
||||
|
||||
meta := &Metadata{
|
||||
Season: -1,
|
||||
Episode: -1,
|
||||
if len(n) == 0 {
|
||||
return -1, -1
|
||||
}
|
||||
if seasonIndex != -1 {
|
||||
//season exists
|
||||
ss := seasonRe.FindAllString(newSplits[seasonIndex], -1)
|
||||
if len(ss) != 0 {
|
||||
//season info
|
||||
|
||||
ssNum := strings.TrimLeft(ss[0], "s")
|
||||
n, err := strconv.Atoi(ssNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", ssNum, err))
|
||||
}
|
||||
meta.Season = n
|
||||
}
|
||||
} else { //maybe like Season 1?
|
||||
seasonRe := regexp.MustCompile(`season \d{1,2}`)
|
||||
matches := seasonRe.FindAllString(name, -1)
|
||||
if len(matches) > 0 {
|
||||
for i, s := range newSplits {
|
||||
if s == "season" {
|
||||
seasonIndex = i
|
||||
}
|
||||
}
|
||||
numRe := regexp.MustCompile(`\d{1,2}`)
|
||||
seNum := numRe.FindAllString(matches[0], -1)[0]
|
||||
n, err := strconv.Atoi(seNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", seNum, err))
|
||||
}
|
||||
meta.Season = n
|
||||
|
||||
}
|
||||
m, err := strconv.Atoi(string(n))
|
||||
if err != nil {
|
||||
return chinese2Num[string(n)], len(n)
|
||||
}
|
||||
if episodeIndex != -1 {
|
||||
ep := episodeRe.FindAllString(newSplits[episodeIndex], -1)
|
||||
if len(ep) > 0 {
|
||||
//episode info exists
|
||||
epNum := strings.TrimLeft(ep[0], "e")
|
||||
n, err := strconv.Atoi(epNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", epNum, err))
|
||||
}
|
||||
meta.Episode = n
|
||||
}
|
||||
} else { //no episode, maybe like One Punch Man S2 - 08 [1080p].mkv
|
||||
|
||||
// numRe := regexp.MustCompile(`^\d{1,2}$`)
|
||||
// for i, p := range newSplits {
|
||||
// if numRe.MatchString(p) {
|
||||
// if i > 0 && strings.Contains(newSplits[i-1], "season") { //last word cannot be season
|
||||
// continue
|
||||
// }
|
||||
// if i < seasonIndex {
|
||||
// //episode number most likely should comes alfter season number
|
||||
// continue
|
||||
// }
|
||||
// //episodeIndex = i
|
||||
// n, err := strconv.Atoi(p)
|
||||
// if err != nil {
|
||||
// panic(fmt.Sprintf("convert %s error: %v", p, err))
|
||||
// }
|
||||
// meta.Episode = n
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
if resIndex != -1 {
|
||||
//resolution exists
|
||||
meta.Resolution = newSplits[resIndex]
|
||||
}
|
||||
if meta.Episode == -1 {
|
||||
meta.Episode = -1
|
||||
meta.IsSeasonPack = true
|
||||
}
|
||||
|
||||
if seasonIndex > 0 {
|
||||
//name exists
|
||||
names := newSplits[0:seasonIndex]
|
||||
meta.NameEn = strings.TrimSpace(strings.Join(names, " "))
|
||||
} else {
|
||||
meta.NameEn = name
|
||||
}
|
||||
|
||||
return meta
|
||||
return m, len(n)
|
||||
}
|
||||
|
||||
func parseChineseName(name string) *Metadata {
|
||||
var meta = parseEnglishName(name)
|
||||
if meta.Season != -1 && (meta.Episode != -1 || meta.IsSeasonPack) {
|
||||
return meta
|
||||
}
|
||||
meta = &Metadata{Season: 1}
|
||||
//season pack
|
||||
packRe := regexp.MustCompile(`(\d{1,2}-\d{1,2})|(全集)`)
|
||||
if packRe.MatchString(name) {
|
||||
meta.IsSeasonPack = true
|
||||
}
|
||||
//resolution
|
||||
resRe := regexp.MustCompile(`\d{3,4}p`)
|
||||
resMatches := resRe.FindAllString(name, -1)
|
||||
if len(resMatches) != 0 {
|
||||
meta.Resolution = resMatches[0]
|
||||
} else {
|
||||
if strings.Contains(name, "720") {
|
||||
meta.Resolution = "720p"
|
||||
} else if strings.Contains(name, "1080") {
|
||||
meta.Resolution = "1080p"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//episode number
|
||||
re1 := regexp.MustCompile(`\[\d{1,3}\]`)
|
||||
episodeMatches1 := re1.FindAllString(name, -1)
|
||||
if len(episodeMatches1) > 0 { //[11] [1080p]
|
||||
epNum := strings.TrimRight(strings.TrimLeft(episodeMatches1[0], "["), "]")
|
||||
n, err := strconv.Atoi(epNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", epNum, err))
|
||||
}
|
||||
meta.Episode = n
|
||||
} else { //【第09話】
|
||||
re2 := regexp.MustCompile(`第\d{1,4}(话|話|集)`)
|
||||
episodeMatches1 := re2.FindAllString(name, -1)
|
||||
if len(episodeMatches1) > 0 {
|
||||
re := regexp.MustCompile(`\d{1,4}`)
|
||||
epNum := re.FindAllString(episodeMatches1[0], -1)[0]
|
||||
n, err := strconv.Atoi(epNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", epNum, err))
|
||||
}
|
||||
meta.Episode = n
|
||||
} else { //SHY 靦腆英雄 / Shy -05 ( CR 1920x1080 AVC AAC MKV)
|
||||
re3 := regexp.MustCompile(`[^\d\w]\d{1,2}[^\d\w]`)
|
||||
epNums := re3.FindAllString(name, -1)
|
||||
if len(epNums) > 0 {
|
||||
|
||||
re3 := regexp.MustCompile(`\d{1,2}`)
|
||||
epNum := re3.FindAllString(epNums[0], -1)[0]
|
||||
n, err := strconv.Atoi(epNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", epNum, err))
|
||||
}
|
||||
meta.Episode = n
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func findSeason(s string) (n int, p int) {
|
||||
//season numner
|
||||
seasonRe1 := regexp.MustCompile(`s\d{1,2}`)
|
||||
seasonMatches := seasonRe1.FindAllString(name, -1)
|
||||
seasonMatches := seasonRe1.FindAllString(s, -1)
|
||||
if len(seasonMatches) > 0 {
|
||||
seNum := seasonMatches[0][1:]
|
||||
n, err := strconv.Atoi(seNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", seNum, err))
|
||||
}
|
||||
meta.Season = n
|
||||
|
||||
return n, strings.Index(s, seNum)
|
||||
} else {
|
||||
seasonRe1 := regexp.MustCompile(`season \d{1,2}`)
|
||||
seasonMatches := seasonRe1.FindAllString(name, -1)
|
||||
seasonMatches := seasonRe1.FindAllString(s, -1)
|
||||
if len(seasonMatches) > 0 {
|
||||
re3 := regexp.MustCompile(`\d{1,2}`)
|
||||
seNum := re3.FindAllString(seasonMatches[0], -1)[0]
|
||||
@@ -250,10 +112,10 @@ func parseChineseName(name string) *Metadata {
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", seNum, err))
|
||||
}
|
||||
meta.Season = n
|
||||
return n, strings.Index(s, seasonMatches[0])
|
||||
} else {
|
||||
seasonRe1 := regexp.MustCompile(`第.{1,2}季`)
|
||||
seasonMatches := seasonRe1.FindAllString(name, -1)
|
||||
seasonMatches := seasonRe1.FindAllString(s, -1)
|
||||
if len(seasonMatches) > 0 {
|
||||
m1 := []rune(seasonMatches[0])
|
||||
seNum := m1[1 : len(m1)-1]
|
||||
@@ -262,58 +124,364 @@ func parseChineseName(name string) *Metadata {
|
||||
log.Warnf("parse season number %v error: %v, try to parse using chinese", seNum, err)
|
||||
n = chinese2Num[string(seNum)]
|
||||
}
|
||||
meta.Season = n
|
||||
return n, strings.Index(s, seasonMatches[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1, -1
|
||||
}
|
||||
|
||||
func findEpisodes(s string) (start int, end int) {
|
||||
var episodeCn = map[rune]bool{
|
||||
'话': true,
|
||||
'話': true,
|
||||
'集': true,
|
||||
}
|
||||
|
||||
rr := []rune(s)
|
||||
for i := 0; i < len(rr); i++ {
|
||||
r := rr[i]
|
||||
if r == 'e' {
|
||||
n, l := adjacentNumber(s, i+1)
|
||||
|
||||
if n > 0 {
|
||||
foundDash := false
|
||||
for j := i + l + 1; j < len(rr); j++ {
|
||||
r1 := rr[j]
|
||||
if r1 == '-' {
|
||||
foundDash = true
|
||||
continue
|
||||
}
|
||||
if r1 == ' ' || r1 == 'e' {
|
||||
continue
|
||||
}
|
||||
|
||||
if foundDash {
|
||||
if r1 == 's' {
|
||||
s1, l1 := adjacentNumber(s, j+1)
|
||||
if s1 > 0 { //S01E01-S01E21
|
||||
n1, _ := adjacentNumber(s, j+l1+2)
|
||||
if n1 > 0 {
|
||||
return n, n1
|
||||
}
|
||||
}
|
||||
}
|
||||
n1, _ := adjacentNumber(s, j)
|
||||
if n1 > 0 {
|
||||
return n, n1
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return n, n
|
||||
}
|
||||
} else if r == '第' {
|
||||
n, l := adjacentNumber(s, i+1)
|
||||
if len(rr) > i+l+1 && episodeCn[rr[i+l+1]] {
|
||||
return n, n
|
||||
} else if len(rr) > i+l+1 {
|
||||
if rr[i+l+1] == '-' {
|
||||
n1, l1 := adjacentNumber(s, i+l+2)
|
||||
if episodeCn[rr[i+l+2+l1]] {
|
||||
return n, n1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//episode number
|
||||
re1 := regexp.MustCompile(`\[\d{1,4}\]`)
|
||||
episodeMatches1 := re1.FindAllString(s, -1)
|
||||
if len(episodeMatches1) > 0 { //[11] [1080p], [2022][113][HEVC][GB][4K]
|
||||
for _, m := range episodeMatches1 {
|
||||
epNum := strings.TrimRight(strings.TrimLeft(m, "["), "]")
|
||||
n, err := strconv.Atoi(epNum)
|
||||
if err != nil {
|
||||
log.Debugf("convert %s error: %v", epNum, err)
|
||||
continue
|
||||
}
|
||||
nowYear := time.Now().Year()
|
||||
if n > nowYear-50 { //high possibility is year number
|
||||
continue
|
||||
}
|
||||
return n, n
|
||||
}
|
||||
} else { //【第09話】
|
||||
re2 := regexp.MustCompile(`第\d{1,4}([话話集])`)
|
||||
episodeMatches1 := re2.FindAllString(s, -1)
|
||||
if len(episodeMatches1) > 0 {
|
||||
re := regexp.MustCompile(`\d{1,4}`)
|
||||
epNum := re.FindAllString(episodeMatches1[0], -1)[0]
|
||||
n, err := strconv.Atoi(epNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", epNum, err))
|
||||
}
|
||||
return n, n
|
||||
} else { //The Road Season 2 Episode 12 XviD-AFG
|
||||
re3 := regexp.MustCompile(`episode \d{1,4}`)
|
||||
epNums := re3.FindAllString(s, -1)
|
||||
if len(epNums) > 0 {
|
||||
re3 := regexp.MustCompile(`\d{1,4}`)
|
||||
epNum := re3.FindAllString(epNums[0], -1)[0]
|
||||
n, err := strconv.Atoi(epNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", epNum, err))
|
||||
}
|
||||
return n, n
|
||||
|
||||
} else { //SHY 靦腆英雄 / Shy -05 ( CR 1920x1080 AVC AAC MKV)
|
||||
if maybeSeasonPack(s) { //avoid miss match, season pack not use this rule
|
||||
return -1, -1
|
||||
}
|
||||
re3 := regexp.MustCompile(`[^(season)][^\d\w]\d{1,2}[^\d\w]`)
|
||||
epNums := re3.FindAllString(s, -1)
|
||||
if len(epNums) > 0 {
|
||||
|
||||
re3 := regexp.MustCompile(`\d{1,2}`)
|
||||
epNum := re3.FindAllString(epNums[0], -1)[0]
|
||||
n, err := strconv.Atoi(epNum)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("convert %s error: %v", epNum, err))
|
||||
}
|
||||
return n, n
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if meta.IsSeasonPack && meta.Episode != 0 {
|
||||
meta.Season = meta.Episode
|
||||
meta.Episode = -1
|
||||
return -1, -1
|
||||
}
|
||||
|
||||
func matchResolution(s string) string {
|
||||
//resolution
|
||||
resRe := regexp.MustCompile(`\d{3,4}p`)
|
||||
resMatches := resRe.FindAllString(s, -1)
|
||||
if len(resMatches) != 0 {
|
||||
return resMatches[0]
|
||||
} else {
|
||||
if strings.Contains(s, "720") {
|
||||
return "720p"
|
||||
} else if strings.Contains(s, "1080") {
|
||||
return "1080p"
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func maybeSeasonPack(s string) bool {
|
||||
//season pack
|
||||
packRe := regexp.MustCompile(`((\d{1,2}-\d{1,2}))|(complete)|(全集)`)
|
||||
if packRe.MatchString(s) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//func parseEnglishName(name string) *Info {
|
||||
// meta := &Info{
|
||||
// //Season: -1,
|
||||
// Episode: -1,
|
||||
// }
|
||||
//
|
||||
// start, end := findEpisodes(name)
|
||||
// if start > 0 && end > 0 {
|
||||
// meta.Episode = start
|
||||
// }
|
||||
//
|
||||
// re := regexp.MustCompile(`[^\p{L}\w\s]`)
|
||||
// name = re.ReplaceAllString(strings.ToLower(name), " ")
|
||||
// newSplits := strings.Split(strings.TrimSpace(name), " ")
|
||||
//
|
||||
// seasonRe := regexp.MustCompile(`^s\d{1,2}`)
|
||||
// resRe := regexp.MustCompile(`^\d{3,4}p`)
|
||||
// episodeRe := regexp.MustCompile(`e\d{1,3}`)
|
||||
//
|
||||
// var seasonIndex = -1
|
||||
// var episodeIndex = -1
|
||||
// var resIndex = -1
|
||||
// for i, p := range newSplits {
|
||||
// p = strings.TrimSpace(p)
|
||||
// if p == "" {
|
||||
// continue
|
||||
// }
|
||||
// if seasonRe.MatchString(p) {
|
||||
// //season part
|
||||
// seasonIndex = i
|
||||
// } else if resRe.MatchString(p) {
|
||||
// resIndex = i
|
||||
// }
|
||||
// if i >= seasonIndex && episodeRe.MatchString(p) {
|
||||
// episodeIndex = i
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if seasonIndex != -1 {
|
||||
// //season exists
|
||||
// ss := seasonRe.FindAllString(newSplits[seasonIndex], -1)
|
||||
// if len(ss) != 0 {
|
||||
// //season info
|
||||
//
|
||||
// ssNum := strings.TrimLeft(ss[0], "s")
|
||||
// n, err := strconv.Atoi(ssNum)
|
||||
// if err != nil {
|
||||
// panic(fmt.Sprintf("convert %s error: %v", ssNum, err))
|
||||
// }
|
||||
// meta.Season = n
|
||||
// }
|
||||
// } else { //maybe like Season 1?
|
||||
// seasonRe := regexp.MustCompile(`season \d{1,2}`)
|
||||
// matches := seasonRe.FindAllString(name, -1)
|
||||
// if len(matches) > 0 {
|
||||
// for i, s := range newSplits {
|
||||
// if s == "season" {
|
||||
// seasonIndex = i
|
||||
// }
|
||||
// }
|
||||
// numRe := regexp.MustCompile(`\d{1,2}`)
|
||||
// seNum := numRe.FindAllString(matches[0], -1)[0]
|
||||
// n, err := strconv.Atoi(seNum)
|
||||
// if err != nil {
|
||||
// panic(fmt.Sprintf("convert %s error: %v", seNum, err))
|
||||
// }
|
||||
// meta.Season = n
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if episodeIndex != -1 {
|
||||
// // ep := episodeRe.FindAllString(newSplits[episodeIndex], -1)
|
||||
// //if len(ep) > 0 {
|
||||
// // //episode info exists
|
||||
// // epNum := strings.TrimLeft(ep[0], "e")
|
||||
// // n, err := strconv.Atoi(epNum)
|
||||
// // if err != nil {
|
||||
// // panic(fmt.Sprintf("convert %s error: %v", epNum, err))
|
||||
// // }
|
||||
// // meta.Episode = n
|
||||
// //}
|
||||
// } else { //no episode, maybe like One Punch Man S2 - 08 [1080p].mkv
|
||||
//
|
||||
// // numRe := regexp.MustCompile(`^\d{1,2}$`)
|
||||
// // for i, p := range newSplits {
|
||||
// // if numRe.MatchString(p) {
|
||||
// // if i > 0 && strings.Contains(newSplits[i-1], "season") { //last word cannot be season
|
||||
// // continue
|
||||
// // }
|
||||
// // if i < seasonIndex {
|
||||
// // //episode number most likely should comes alfter season number
|
||||
// // continue
|
||||
// // }
|
||||
// // //episodeIndex = i
|
||||
// // n, err := strconv.Atoi(p)
|
||||
// // if err != nil {
|
||||
// // panic(fmt.Sprintf("convert %s error: %v", p, err))
|
||||
// // }
|
||||
// // meta.Episode = n
|
||||
//
|
||||
// // }
|
||||
// // }
|
||||
//
|
||||
// }
|
||||
// if resIndex != -1 {
|
||||
// //resolution exists
|
||||
// meta.Resolution = newSplits[resIndex]
|
||||
// }
|
||||
// if meta.Episode == -1 {
|
||||
// meta.Episode = -1
|
||||
// meta.IsSeasonPack = true
|
||||
// }
|
||||
//
|
||||
// if seasonIndex > 0 {
|
||||
// //name exists
|
||||
// names := newSplits[0:seasonIndex]
|
||||
// meta.NameEn = strings.TrimSpace(strings.Join(names, " "))
|
||||
// } else {
|
||||
// meta.NameEn = name
|
||||
// }
|
||||
//
|
||||
// return meta
|
||||
//}
|
||||
|
||||
func parseName(name string) *Info {
|
||||
meta := &Info{Season: 1}
|
||||
if strings.TrimSpace(name) == "" {
|
||||
return meta
|
||||
}
|
||||
|
||||
season, p := findSeason(name)
|
||||
if season == -1 {
|
||||
log.Debugf("not find season info: %s", name)
|
||||
if !utils.IsASCII(name) {
|
||||
season = 1
|
||||
}
|
||||
p = len(name) - 1
|
||||
}
|
||||
meta.Season = season
|
||||
|
||||
start, end := findEpisodes(name)
|
||||
if start > 0 && end > 0 {
|
||||
meta.StartEpisode = start
|
||||
meta.EndEpisode = end
|
||||
} else {
|
||||
meta.IsSeasonPack = true
|
||||
}
|
||||
|
||||
meta.Resolution = matchResolution(name)
|
||||
|
||||
//if meta.IsSeasonPack && meta.Episode != 0 {
|
||||
// meta.Season = meta.Episode
|
||||
// meta.Episode = -1
|
||||
//}
|
||||
|
||||
//tv name
|
||||
|
||||
fields := strings.FieldsFunc(name, func(r rune) bool {
|
||||
return r == '[' || r == ']' || r == '【' || r == '】'
|
||||
})
|
||||
titleCn := ""
|
||||
title := ""
|
||||
for _, p := range fields { //寻找匹配的最长的字符串,最有可能是名字
|
||||
if utils.ContainsChineseChar(p) && len([]rune(p)) > len([]rune(titleCn)) { //最长含中文字符串
|
||||
titleCn = p
|
||||
}
|
||||
if len([]rune(p)) > len([]rune(title)) { //最长字符串
|
||||
title = p
|
||||
}
|
||||
}
|
||||
re := regexp.MustCompile(`[^\p{L}\w\s]`)
|
||||
title = re.ReplaceAllString(strings.TrimSpace(strings.ToLower(title)), "") //去除标点符号
|
||||
titleCn = re.ReplaceAllString(strings.TrimSpace(strings.ToLower(titleCn)), "")
|
||||
|
||||
meta.NameCn = titleCn
|
||||
cnRe := regexp.MustCompile(`\p{Han}.*\p{Han}`)
|
||||
cnmatches := cnRe.FindAllString(titleCn, -1)
|
||||
|
||||
//titleCn中最长的中文字符
|
||||
if len(cnmatches) > 0 {
|
||||
for _, t := range cnmatches {
|
||||
if len([]rune(t)) > len([]rune(meta.NameCn)) {
|
||||
meta.NameCn = strings.ToLower(t)
|
||||
if utils.IsASCII(name) && p < len(name) && p-1 > 0 {
|
||||
meta.NameEn = strings.TrimSpace(name[:p-1])
|
||||
meta.NameCn = meta.NameEn
|
||||
} else {
|
||||
fields := strings.FieldsFunc(name, func(r rune) bool {
|
||||
return r == '[' || r == ']' || r == '【' || r == '】'
|
||||
})
|
||||
titleCn := ""
|
||||
title := ""
|
||||
for _, p := range fields { //寻找匹配的最长的字符串,最有可能是名字
|
||||
if utils.ContainsChineseChar(p) && len([]rune(p)) > len([]rune(titleCn)) { //最长含中文字符串
|
||||
titleCn = p
|
||||
}
|
||||
if len([]rune(p)) > len([]rune(title)) { //最长字符串
|
||||
title = p
|
||||
}
|
||||
}
|
||||
}
|
||||
re := regexp.MustCompile(`[^\p{L}\w\s]`)
|
||||
title = re.ReplaceAllString(strings.TrimSpace(strings.ToLower(title)), "") //去除标点符号
|
||||
titleCn = re.ReplaceAllString(strings.TrimSpace(strings.ToLower(titleCn)), "")
|
||||
|
||||
//匹配title中最长拉丁字符串
|
||||
enRe := regexp.MustCompile(`[[:ascii:]]*`)
|
||||
enM := enRe.FindAllString(title, -1)
|
||||
if len(enM) > 0 {
|
||||
for _, t := range enM {
|
||||
if len(t) > len(meta.NameEn) {
|
||||
meta.NameEn = strings.TrimSpace(strings.ToLower(t))
|
||||
meta.NameCn = titleCn
|
||||
cnRe := regexp.MustCompile(`\p{Han}.*\p{Han}`)
|
||||
cnmatches := cnRe.FindAllString(titleCn, -1)
|
||||
|
||||
//titleCn中最长的中文字符
|
||||
if len(cnmatches) > 0 {
|
||||
for _, t := range cnmatches {
|
||||
if len([]rune(t)) > len([]rune(meta.NameCn)) {
|
||||
meta.NameCn = strings.ToLower(t)
|
||||
}
|
||||
}
|
||||
}
|
||||
meta.NameEn = title
|
||||
|
||||
////匹配title中最长拉丁字符串
|
||||
//enRe := regexp.MustCompile(`[[:ascii:]]*`)
|
||||
//enM := enRe.FindAllString(title, -1)
|
||||
//if len(enM) > 0 {
|
||||
// for _, t := range enM {
|
||||
// if len(t) > len(meta.NameEn) {
|
||||
// meta.NameEn = strings.TrimSpace(strings.ToLower(t))
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
return meta
|
||||
@@ -330,3 +498,15 @@ var chinese2Num = map[string]int{
|
||||
"八": 8,
|
||||
"九": 9,
|
||||
}
|
||||
|
||||
var chineseNum = map[rune]bool{
|
||||
'一': true,
|
||||
'二': true,
|
||||
'三': true,
|
||||
'四': true,
|
||||
'五': true,
|
||||
'六': true,
|
||||
'七': true,
|
||||
'八': true,
|
||||
'九': true,
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func Test_ParseTV2(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, m.Season, 1)
|
||||
assert.Equal(t, m.Episode, 4)
|
||||
assert.Equal(t, m.StartEpisode, 4)
|
||||
assert.Equal(t, m.IsSeasonPack, false)
|
||||
assert.Equal(t, m.Resolution, "1080p")
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func Test_ParseTV3(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, m.Season, 37)
|
||||
assert.Equal(t, m.Episode, 219)
|
||||
assert.Equal(t, m.StartEpisode, 219)
|
||||
assert.Equal(t, m.IsSeasonPack, false)
|
||||
//assert.Equal(t, m.Resolution, "1080p")
|
||||
}
|
||||
@@ -41,8 +41,8 @@ func Test_ParseTV4(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, m.Season, 2)
|
||||
//assert.Equal(t, m.Episode, 219)
|
||||
assert.Equal(t, m.IsSeasonPack, true)
|
||||
assert.Equal(t, m.StartEpisode, 12)
|
||||
assert.Equal(t, m.IsSeasonPack, false)
|
||||
//assert.Equal(t, m.Resolution, "1080p")
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func Test_ParseTV6(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, m.Season, 1)
|
||||
assert.Equal(t, m.Episode, 3)
|
||||
assert.Equal(t, m.StartEpisode, 3)
|
||||
assert.Equal(t, m.IsSeasonPack, false)
|
||||
assert.Equal(t, m.Resolution, "1080p")
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func Test_ParseTV7(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, m.Season, 1)
|
||||
assert.Equal(t, m.Episode, 1113)
|
||||
assert.Equal(t, m.StartEpisode, 1113)
|
||||
assert.Equal(t, m.IsSeasonPack, false)
|
||||
assert.Equal(t, m.Resolution, "1080p")
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func Test_ParseTV8(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, m.Season, 1)
|
||||
assert.Equal(t, m.Episode, 4)
|
||||
assert.Equal(t, m.StartEpisode, 4)
|
||||
assert.Equal(t, m.IsSeasonPack, false)
|
||||
assert.Equal(t, m.Resolution, "1080p")
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func Test_ParseTV9(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, m.Season, 1)
|
||||
assert.Equal(t, m.Episode, 16)
|
||||
assert.Equal(t, m.StartEpisode, 16)
|
||||
assert.Equal(t, m.IsSeasonPack, false)
|
||||
assert.Equal(t, m.Resolution, "1080p")
|
||||
}
|
||||
@@ -111,7 +111,7 @@ func Test_ParseTV11(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, 2, m.Season)
|
||||
assert.Equal(t, 4, m.Episode)
|
||||
assert.Equal(t, 4, m.StartEpisode)
|
||||
assert.Equal(t, false, m.IsSeasonPack)
|
||||
assert.Equal(t, "1080p", m.Resolution)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func Test_ParseTV12(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, 2, m.Season)
|
||||
assert.Equal(t, 4, m.Episode)
|
||||
assert.Equal(t, 4, m.StartEpisode)
|
||||
assert.Equal(t, false, m.IsSeasonPack)
|
||||
assert.Equal(t, "1080p", m.Resolution)
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func Test_ParseTV13(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, 2, m.Season)
|
||||
assert.Equal(t, 8, m.Episode)
|
||||
assert.Equal(t, 8, m.StartEpisode)
|
||||
assert.Equal(t, false, m.IsSeasonPack)
|
||||
assert.Equal(t, "1080p", m.Resolution)
|
||||
}
|
||||
@@ -141,10 +141,11 @@ func Test_ParseTV14(t *testing.T) {
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
assert.Equal(t, 5, m.Season)
|
||||
assert.Equal(t, 113, m.Episode)
|
||||
assert.Equal(t, 113, m.StartEpisode)
|
||||
assert.Equal(t, false, m.IsSeasonPack)
|
||||
//assert.Equal(t, "720p", m.Resolution)
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
func Test_ParseTV15(t *testing.T) {
|
||||
@@ -157,4 +158,58 @@ func Test_ParseTV15(t *testing.T) {
|
||||
//assert.Equal(t, 113, m.Episode)
|
||||
//assert.Equal(t, false, m.IsSeasonPack)
|
||||
//assert.Equal(t, "720p", m.Resolution)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_ParseTV16(t *testing.T) {
|
||||
s1 := "Romance in the Alley 2024 S01 E24-E25 1080p WEB-DL H.264 AAC-PTerWEB"
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
|
||||
assert.Equal(t, 1, m.Season)
|
||||
assert.Equal(t, 24, m.StartEpisode)
|
||||
assert.Equal(t, 25, m.EndEpisode)
|
||||
//assert.Equal(t, false, m.IsSeasonPack)
|
||||
//assert.Equal(t, "720p", m.Resolution)
|
||||
}
|
||||
|
||||
func Test_ParseTV17(t *testing.T) {
|
||||
s1 := "小巷人家/Romance in the Alley 第24-25集 "
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
|
||||
assert.Equal(t, 1, m.Season)
|
||||
assert.Equal(t, 24, m.StartEpisode)
|
||||
assert.Equal(t, 25, m.EndEpisode)
|
||||
//assert.Equal(t, false, m.IsSeasonPack)
|
||||
//assert.Equal(t, "720p", m.Resolution)
|
||||
}
|
||||
|
||||
// Romance in the Alley 2024 S01E01-S01E21 2160p WEB-DL HEVC AAC-UBWEB
|
||||
func Test_ParseTV18(t *testing.T) {
|
||||
s1 := "Romance in the Alley 2024 S01E01-S01E21 2160p WEB-DL HEVC AAC-UBWEB "
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
|
||||
assert.Equal(t, 1, m.Season)
|
||||
assert.Equal(t, 1, m.StartEpisode)
|
||||
assert.Equal(t, 21, m.EndEpisode)
|
||||
//assert.Equal(t, false, m.IsSeasonPack)
|
||||
//assert.Equal(t, "720p", m.Resolution)
|
||||
}
|
||||
|
||||
// The Day of the Jackal (Season 1) WEB-DL 1080p
|
||||
func Test_ParseTV19(t *testing.T) {
|
||||
s1 := "The Day of the Jackal (Season 1) WEB-DL 1080p "
|
||||
m := ParseTv(s1)
|
||||
log.Infof("results: %+v", m)
|
||||
|
||||
assert.Equal(t, 1, m.Season)
|
||||
assert.Equal(t, true, m.IsSeasonPack)
|
||||
//assert.Equal(t, "720p", m.Resolution)
|
||||
}
|
||||
|
||||
func Test_Name(t *testing.T) {
|
||||
m := Info{NameEn: "word кибердеревня новый год 2023 webrip 1080p"}
|
||||
b := m.IsAcceptable("word")
|
||||
assert.True(t, b)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,13 @@ import (
|
||||
"golift.io/starr/prowlarr"
|
||||
)
|
||||
|
||||
type ProwlarrSupportType string
|
||||
|
||||
const (
|
||||
TV ProwlarrSupportType = "tv"
|
||||
Movie ProwlarrSupportType = "movie"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
p *prowlarr.Prowlarr
|
||||
apiKey string
|
||||
@@ -24,7 +31,7 @@ func New(apiKey, url string) *Client {
|
||||
return &Client{p: p, apiKey: apiKey, url: url}
|
||||
}
|
||||
|
||||
func (c *Client) GetIndexers() ([]*db.TorznabInfo, error) {
|
||||
func (c *Client) GetIndexers(t ProwlarrSupportType) ([]*db.TorznabInfo, error) {
|
||||
ins, err := c.p.GetIndexers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -34,6 +41,11 @@ func (c *Client) GetIndexers() ([]*db.TorznabInfo, error) {
|
||||
if !in.Enable {
|
||||
continue
|
||||
}
|
||||
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
|
||||
}
|
||||
seedRatio := 0.0
|
||||
for _, f := range in.Fields {
|
||||
if f.Name == "torrentBaseSettings.seedRatio" && f.Value != nil {
|
||||
@@ -57,7 +69,7 @@ func (c *Client) GetIndexers() ([]*db.TorznabInfo, error) {
|
||||
}
|
||||
|
||||
indexers = append(indexers, &db.TorznabInfo{
|
||||
Indexers: &entIndexer,
|
||||
Indexers: &entIndexer,
|
||||
TorznabSetting: setting,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func Test111(t *testing.T) {
|
||||
c := New("", "http://10.0.0.8:9696/")
|
||||
apis , err := c.GetIndexers()
|
||||
apis , err := c.GetIndexers("tv")
|
||||
log.Infof("errors: %v", err)
|
||||
log.Infof("indexers: %+v", apis[0])
|
||||
}
|
||||
|
||||
72
pkg/storage/alist.go
Normal file
72
pkg/storage/alist.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"polaris/pkg/alist"
|
||||
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
)
|
||||
|
||||
func NewAlist(cfg *alist.Config, dir string) (*Alist, error) {
|
||||
cl := alist.New(cfg)
|
||||
_, err := cl.Login()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Alist{baseDir: dir, cfg: cfg, client: cl}, nil
|
||||
}
|
||||
|
||||
type Alist struct {
|
||||
baseDir string
|
||||
cfg *alist.Config
|
||||
client *alist.Client
|
||||
progresser func() float64
|
||||
}
|
||||
|
||||
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 {
|
||||
b, err := NewBase(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.progresser = b.Progress
|
||||
|
||||
uploadFunc := func(destPath string, destInfo fs.FileInfo, srcReader io.Reader, mimeType *mimetype.MIME) error {
|
||||
_, err := a.client.UploadStream(srcReader, destInfo.Size(), destPath)
|
||||
return err
|
||||
}
|
||||
mkdirFunc := func(dir string) error {
|
||||
return a.client.Mkdir(dir)
|
||||
}
|
||||
|
||||
baseDest := filepath.Join(a.baseDir, dest)
|
||||
return b.Upload(baseDest, false, false, false, uploadFunc, mkdirFunc)
|
||||
}
|
||||
|
||||
func (a *Alist) ReadDir(dir string) ([]fs.FileInfo, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *Alist) ReadFile(s string) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *Alist) WriteFile(s string, bytes []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Alist) UploadProgress() float64 {
|
||||
if a.progresser == nil {
|
||||
return 0
|
||||
}
|
||||
return a.progresser()
|
||||
}
|
||||
132
pkg/storage/base.go
Normal file
132
pkg/storage/base.go
Normal file
@@ -0,0 +1,132 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"polaris/log"
|
||||
"polaris/pkg/utils"
|
||||
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
type Storage interface {
|
||||
Move(src, dest string) error
|
||||
Copy(src, dest string) error
|
||||
ReadDir(dir string) ([]fs.FileInfo, error)
|
||||
ReadFile(string) ([]byte, error)
|
||||
WriteFile(string, []byte) error
|
||||
UploadProgress() float64
|
||||
}
|
||||
|
||||
|
||||
type uploadFunc func(destPath string, destInfo fs.FileInfo, srcReader io.Reader, mimeType *mimetype.MIME) error
|
||||
|
||||
type Base struct {
|
||||
src string
|
||||
totalSize int64
|
||||
uploadedSize int64
|
||||
}
|
||||
|
||||
func NewBase(src string) (*Base, error) {
|
||||
b := &Base{src: src}
|
||||
err := b.calculateSize()
|
||||
return b, err
|
||||
}
|
||||
|
||||
func (b *Base) Upload(destDir string, tryLink, detectMime, changeMediaHash bool, upload uploadFunc, mkdir func(string) error) error {
|
||||
os.MkdirAll(destDir, os.ModePerm)
|
||||
|
||||
targetBase := filepath.Join(destDir, filepath.Base(b.src)) //文件的场景,要加上文件名, move filename ./dir/
|
||||
info, err := os.Stat(b.src)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "read source dir")
|
||||
}
|
||||
if info.IsDir() { //如果是路径,则只移动路径里面的文件,不管当前路径, 行为类似 move dirname/* target_dir/
|
||||
targetBase = destDir
|
||||
}
|
||||
log.Debugf("local storage target base dir is: %v", targetBase)
|
||||
|
||||
err = filepath.Walk(b.src, func(path string, info fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rel, err := filepath.Rel(b.src, path)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "relation between %s and %s", b.src, path)
|
||||
}
|
||||
destName := filepath.Join(targetBase, rel)
|
||||
|
||||
if info.IsDir() {
|
||||
mkdir(destName)
|
||||
} else { //is file
|
||||
if tryLink {
|
||||
if err := os.Link(path, destName); err == nil {
|
||||
return nil //link success
|
||||
}
|
||||
log.Warnf("hard link file error: %v, will try copy file, source: %s, dest: %s", err, path, destName)
|
||||
}
|
||||
if changeMediaHash {
|
||||
if err := utils.ChangeFileHash(path); err != nil {
|
||||
log.Errorf("change file %v hash error: %v", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
if f, err := os.OpenFile(path, os.O_RDONLY, os.ModePerm); err != nil {
|
||||
return errors.Wrapf(err, "read file %v", path)
|
||||
} else { //open success
|
||||
defer f.Close()
|
||||
var mtype *mimetype.MIME
|
||||
if detectMime {
|
||||
mtype, err = mimetype.DetectFile(path)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "mime type error")
|
||||
}
|
||||
}
|
||||
return upload(destName, info, &progressReader{R: f, Add: func(i int) {
|
||||
b.uploadedSize += int64(i)
|
||||
}}, mtype)
|
||||
}
|
||||
|
||||
}
|
||||
log.Infof("file copy complete: %v", destName)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "move file error")
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (b *Base) calculateSize() error {
|
||||
var size int64
|
||||
err := filepath.Walk(b.src, func(_ string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
size += info.Size()
|
||||
}
|
||||
return err
|
||||
})
|
||||
b.totalSize = size
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *Base) Progress() float64 {
|
||||
return float64(b.uploadedSize)/float64(b.totalSize)
|
||||
}
|
||||
|
||||
|
||||
type progressReader struct {
|
||||
R io.Reader
|
||||
Add func(int)
|
||||
}
|
||||
|
||||
func (pr *progressReader) Read(p []byte) (int, error) {
|
||||
n, err := pr.R.Read(p)
|
||||
pr.Add(n)
|
||||
return n, err
|
||||
}
|
||||
@@ -6,22 +6,14 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"polaris/log"
|
||||
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Storage interface {
|
||||
Move(src, dest string) error
|
||||
Copy(src, dest string) error
|
||||
ReadDir(dir string) ([]fs.FileInfo, error)
|
||||
ReadFile(string) ([]byte, error)
|
||||
WriteFile(string, []byte) error
|
||||
}
|
||||
|
||||
func NewLocalStorage(dir string) (*LocalStorage, error) {
|
||||
os.MkdirAll(dir, 0655)
|
||||
|
||||
return &LocalStorage{dir: dir}, nil
|
||||
}
|
||||
|
||||
@@ -30,57 +22,28 @@ type LocalStorage struct {
|
||||
}
|
||||
|
||||
func (l *LocalStorage) Copy(src, destDir string) error {
|
||||
os.MkdirAll(filepath.Join(l.dir, destDir), os.ModePerm)
|
||||
|
||||
targetBase := filepath.Join(l.dir, destDir, filepath.Base(src)) //文件的场景,要加上文件名, move filename ./dir/
|
||||
info, err := os.Stat(src)
|
||||
b, err := NewBase(src)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "read source dir")
|
||||
return err
|
||||
}
|
||||
if info.IsDir() { //如果是路径,则只移动路径里面的文件,不管当前路径, 行为类似 move dirname/* target_dir/
|
||||
targetBase = filepath.Join(l.dir, destDir)
|
||||
}
|
||||
log.Debugf("local storage target base dir is: %v", targetBase)
|
||||
|
||||
err = filepath.Walk(src, func(path string, info fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rel, err := filepath.Rel(src, path)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "relation between %s and %s", src, path)
|
||||
}
|
||||
destName := filepath.Join(targetBase, rel)
|
||||
|
||||
if info.IsDir() {
|
||||
os.Mkdir(destName, os.ModePerm)
|
||||
} else { //is file
|
||||
if err := os.Link(path, destName); err != nil {
|
||||
log.Warnf("hard link file error: %v, will try copy file, source: %s, dest: %s", err, path, destName)
|
||||
if writer, err := os.OpenFile(destName, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.ModePerm); err != nil {
|
||||
return errors.Wrapf(err, "create file %s", destName)
|
||||
} else {
|
||||
defer writer.Close()
|
||||
if f, err := os.OpenFile(path, os.O_RDONLY, os.ModePerm); err != nil {
|
||||
return errors.Wrapf(err, "read file %v", path)
|
||||
} else { //open success
|
||||
defer f.Close()
|
||||
_, err := io.Copy(writer, f)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "transmitting data error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
baseDest := filepath.Join(l.dir, destDir)
|
||||
uploadFunc := func(destPath string, destInfo fs.FileInfo, srcReader io.Reader, mimeType *mimetype.MIME) error {
|
||||
if writer, err := os.OpenFile(destPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.ModePerm); err != nil {
|
||||
return errors.Wrapf(err, "create file %s", destPath)
|
||||
} else {
|
||||
defer writer.Close()
|
||||
_, err := io.Copy(writer, srcReader)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "transmitting data error")
|
||||
}
|
||||
|
||||
}
|
||||
log.Infof("file copy complete: %v", destName)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "move file error")
|
||||
}
|
||||
return nil
|
||||
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 {
|
||||
@@ -103,3 +66,7 @@ func (l *LocalStorage) WriteFile(name string, data []byte) error {
|
||||
os.MkdirAll(filepath.Dir(path), os.ModePerm)
|
||||
return os.WriteFile(path, data, os.ModePerm)
|
||||
}
|
||||
|
||||
func (l *LocalStorage) UploadProgress() float64 {
|
||||
return 0
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"polaris/log"
|
||||
"polaris/pkg/gowebdav"
|
||||
"polaris/pkg/utils"
|
||||
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
"github.com/pkg/errors"
|
||||
@@ -17,6 +16,7 @@ type WebdavStorage struct {
|
||||
fs *gowebdav.Client
|
||||
dir string
|
||||
changeMediaHash bool
|
||||
progresser func() float64
|
||||
}
|
||||
|
||||
func NewWebdavStorage(url, user, password, path string, changeMediaHash bool) (*WebdavStorage, error) {
|
||||
@@ -31,67 +31,29 @@ func NewWebdavStorage(url, user, password, path string, changeMediaHash bool) (*
|
||||
}
|
||||
|
||||
func (w *WebdavStorage) Copy(local, remoteDir string) error {
|
||||
remoteBase := filepath.Join(w.dir, remoteDir, filepath.Base(local))
|
||||
info, err := os.Stat(local)
|
||||
b, err := NewBase(local)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "read source dir")
|
||||
}
|
||||
if info.IsDir() { //如果是路径,则只移动路径里面的文件,不管当前路径, 行为类似 move dirname/* target_dir/
|
||||
remoteBase = filepath.Join(w.dir, remoteDir)
|
||||
return err
|
||||
}
|
||||
|
||||
//log.Infof("remove all content in %s", remoteBase)
|
||||
//w.fs.RemoveAll(remoteBase)
|
||||
err = filepath.Walk(local, func(path string, info fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "read file %v", path)
|
||||
w.progresser = b.Progress
|
||||
|
||||
uploadFunc := func(destPath string, destInfo fs.FileInfo, srcReader io.Reader, mtype *mimetype.MIME) error {
|
||||
callback := func(r *http.Request) {
|
||||
r.Header.Set("Content-Type", mtype.String())
|
||||
r.ContentLength = destInfo.Size()
|
||||
}
|
||||
|
||||
rel, err := filepath.Rel(local, path)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "path relation")
|
||||
if err := w.fs.WriteStream(destPath, srcReader, 0666, callback); err != nil {
|
||||
return errors.Wrap(err, "transmitting data error")
|
||||
}
|
||||
remoteName := filepath.Join(remoteBase, rel)
|
||||
return nil
|
||||
|
||||
if info.IsDir() {
|
||||
log.Infof("skip dir %v, webdav will mkdir automatically", info.Name())
|
||||
}
|
||||
|
||||
// if err := w.fs.Mkdir(remoteName, 0666); err != nil {
|
||||
// return errors.Wrapf(err, "mkdir %v", remoteName)
|
||||
// }
|
||||
|
||||
} else { //is file
|
||||
if w.changeMediaHash {
|
||||
if err := utils.ChangeFileHash(path); err != nil {
|
||||
log.Errorf("change file %v hash error: %v", path, err)
|
||||
}
|
||||
}
|
||||
if f, err := os.OpenFile(path, os.O_RDONLY, 0666); err != nil {
|
||||
return errors.Wrapf(err, "read file %v", path)
|
||||
} else { //open success
|
||||
defer f.Close()
|
||||
mtype, err := mimetype.DetectFile(path)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "mime type error")
|
||||
}
|
||||
|
||||
callback := func(r *http.Request) {
|
||||
r.Header.Set("Content-Type", mtype.String())
|
||||
r.ContentLength = info.Size()
|
||||
}
|
||||
|
||||
if err := w.fs.WriteStream(remoteName, f, 0666, callback); err != nil {
|
||||
return errors.Wrap(err, "transmitting data error")
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Infof("file copy complete: %v", remoteName)
|
||||
return b.Upload(filepath.Join(w.dir, remoteDir), false, true, w.changeMediaHash, uploadFunc, func(s string) error {
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "move file error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *WebdavStorage) Move(local, remoteDir string) error {
|
||||
@@ -112,3 +74,10 @@ func (w *WebdavStorage) ReadFile(name string) ([]byte, error) {
|
||||
func (w *WebdavStorage) WriteFile(name string, data []byte) error {
|
||||
return w.fs.Write(filepath.Join(w.dir, name), data, os.ModePerm)
|
||||
}
|
||||
|
||||
func (w *WebdavStorage) UploadProgress() float64 {
|
||||
if w.progresser == nil {
|
||||
return 0
|
||||
}
|
||||
return w.progresser()
|
||||
}
|
||||
@@ -85,14 +85,21 @@ func (r *Response) ToResults(indexer *db.TorznabInfo) []Result {
|
||||
// log.Warnf("converting link to magnet error, error: %v, link: %v", err, item.Link)
|
||||
// continue
|
||||
// }
|
||||
imdb := ""
|
||||
if item.GetAttr("imdbid") != "" {
|
||||
imdb = item.GetAttr("imdbid")
|
||||
} else if item.GetAttr("imdb") != "" {
|
||||
imdb = item.GetAttr("imdb")
|
||||
}
|
||||
r := Result{
|
||||
Name: item.Title,
|
||||
Description: item.Description,
|
||||
Link: item.Link,
|
||||
Size: mustAtoI(item.Size),
|
||||
Seeders: mustAtoI(item.GetAttr("seeders")),
|
||||
Peers: mustAtoI(item.GetAttr("peers")),
|
||||
Category: mustAtoI(item.GetAttr("category")),
|
||||
ImdbId: item.GetAttr("imdbid"),
|
||||
ImdbId: imdb,
|
||||
DownloadVolumeFactor: tryParseFloat(item.GetAttr("downloadvolumefactor")),
|
||||
UploadVolumeFactor: tryParseFloat(item.GetAttr("uploadvolumefactor")),
|
||||
Source: indexer.Name,
|
||||
@@ -124,7 +131,7 @@ func tryParseFloat(s string) float32 {
|
||||
}
|
||||
|
||||
func Search(indexer *db.TorznabInfo, keyWord string) ([]Result, error) {
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, indexer.URL, nil)
|
||||
@@ -174,6 +181,7 @@ func doRequest(req *http.Request) (*Response, error) {
|
||||
|
||||
type Result struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Link string `json:"link"`
|
||||
Size int `json:"size"`
|
||||
Seeders int `json:"seeders"`
|
||||
|
||||
86
pkg/uploader/uploader.go
Normal file
86
pkg/uploader/uploader.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package uploader
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"polaris/pkg/utils"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
type StreamWriter interface {
|
||||
WriteStream(path string, stream io.Reader, _ os.FileMode) error
|
||||
}
|
||||
|
||||
type Uploader struct {
|
||||
sw StreamWriter
|
||||
progress atomic.Int64
|
||||
dir string
|
||||
size int64
|
||||
}
|
||||
|
||||
func NewUploader(dir string, sw StreamWriter) (*Uploader, error) {
|
||||
size, err := utils.DirSize(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Uploader{sw: sw, dir: dir, size: size, progress: atomic.Int64{}}, nil
|
||||
}
|
||||
|
||||
func (u *Uploader) Upload() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type ProgressReader struct {
|
||||
Reader io.Reader
|
||||
Progress atomic.Int64
|
||||
Size int64
|
||||
Name string
|
||||
Once bool
|
||||
Done atomic.Bool
|
||||
}
|
||||
|
||||
func (progressReader *ProgressReader) NewLoop() {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
var op int64
|
||||
for range ticker.C {
|
||||
p := progressReader.Progress.Load()
|
||||
KB := (p - op) / 1024
|
||||
var percent int64
|
||||
if progressReader.Size != 0 {
|
||||
percent = p * 100 / progressReader.Size
|
||||
} else {
|
||||
percent = 100
|
||||
}
|
||||
if KB < 1024 {
|
||||
fmt.Printf("%s: %dKB/s %d%%\n", progressReader.Name, KB, percent)
|
||||
} else {
|
||||
fmt.Printf("%s: %.2fMB/s %d%%\n", progressReader.Name, float64(KB)/1024, percent)
|
||||
}
|
||||
|
||||
if progressReader.Done.Load() {
|
||||
ticker.Stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (progressReader *ProgressReader) Read(p []byte) (int, error) {
|
||||
n, err := progressReader.Reader.Read(p)
|
||||
progressReader.Progress.Add(int64(n))
|
||||
if !progressReader.Once {
|
||||
progressReader.Once = true
|
||||
go progressReader.NewLoop()
|
||||
}
|
||||
if err != nil {
|
||||
progressReader.Done.Store(true)
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (progressReader *ProgressReader) Close() error {
|
||||
progressReader.Done.Store(true)
|
||||
return nil
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -230,7 +231,7 @@ func Link2Magnet(link string) (string, error) {
|
||||
return http.ErrUseLastResponse //do not follow redirects
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
resp, err := client.Get(link)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "get link")
|
||||
@@ -252,7 +253,6 @@ func Link2Magnet(link string) (string, error) {
|
||||
return mg.String(), nil
|
||||
}
|
||||
|
||||
|
||||
func MagnetHash(link string) (string, error) {
|
||||
if mi, err := metainfo.ParseMagnetV2Uri(link); err != nil {
|
||||
return "", errors.Errorf("magnet link is not valid: %v", err)
|
||||
@@ -271,4 +271,18 @@ func MagnetHash(link string) (string, error) {
|
||||
}
|
||||
return hash, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func DirSize(path string) (int64, error) {
|
||||
var size int64
|
||||
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
size += info.Size()
|
||||
}
|
||||
return err
|
||||
})
|
||||
return size, err
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ import (
|
||||
|
||||
type Activity struct {
|
||||
*ent.History
|
||||
Progress int `json:"progress"`
|
||||
SeedRatio float64 `json:"seed_ratio"`
|
||||
Progress int `json:"progress"`
|
||||
SeedRatio float64 `json:"seed_ratio"`
|
||||
UploadProgress float64 `json:"upload_progress"`
|
||||
}
|
||||
|
||||
func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
|
||||
@@ -44,6 +45,9 @@ func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
|
||||
} else {
|
||||
a.SeedRatio = r
|
||||
}
|
||||
if task.UploadProgresser != nil {
|
||||
a.UploadProgress = task.UploadProgresser()
|
||||
}
|
||||
}
|
||||
}
|
||||
activities = append(activities, a)
|
||||
|
||||
@@ -44,7 +44,7 @@ func (c *Client) registerCronJob(name string, cron string, f func() error) {
|
||||
}
|
||||
|
||||
func (c *Client) Init() {
|
||||
c.reloadTasks()
|
||||
go c.reloadTasks()
|
||||
c.addSysCron()
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ func (c *Client) reloadTasks() {
|
||||
}
|
||||
|
||||
}
|
||||
log.Infof("------ task reloading done ------")
|
||||
}
|
||||
|
||||
func (c *Client) GetDownloadClient() (pkg.Downloader, *ent.DownloadClients, error) {
|
||||
|
||||
@@ -4,13 +4,13 @@ import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"polaris/db"
|
||||
"polaris/ent/media"
|
||||
storage1 "polaris/ent/storage"
|
||||
"polaris/log"
|
||||
"polaris/pkg/alist"
|
||||
"polaris/pkg/metadata"
|
||||
"polaris/pkg/notifier"
|
||||
"polaris/pkg/storage"
|
||||
@@ -18,6 +18,8 @@ import (
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (c *Client) writeNfoFile(historyId int) error {
|
||||
@@ -218,6 +220,13 @@ func (c *Client) getStorage(storageId int, mediaType media.MediaType) (storage.S
|
||||
return nil, errors.Wrap(err, "new webdav")
|
||||
}
|
||||
return storageImpl1, nil
|
||||
case storage1.ImplementationAlist:
|
||||
cfg := st.ToWebDavSetting()
|
||||
storageImpl1, err := storage.NewAlist(&alist.Config{URL: cfg.URL, Username: cfg.User, Password: cfg.Password}, targetPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "alist")
|
||||
}
|
||||
return storageImpl1, nil
|
||||
}
|
||||
return nil, errors.New("no storage found")
|
||||
}
|
||||
@@ -300,9 +309,9 @@ func (c *Client) findEpisodeFilesPreMoving(historyId int) error {
|
||||
}
|
||||
|
||||
meta := metadata.ParseTv(f.Name())
|
||||
if meta.Episode > 0 {
|
||||
if meta.StartEpisode > 0 {
|
||||
//episode exists
|
||||
ep, err := c.db.GetEpisode(his.MediaID, seasonNum, meta.Episode)
|
||||
ep, err := c.db.GetEpisode(his.MediaID, seasonNum, meta.StartEpisode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"polaris/ent"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
"polaris/log"
|
||||
"polaris/pkg/metadata"
|
||||
"polaris/pkg/notifier/message"
|
||||
"polaris/pkg/torznab"
|
||||
"polaris/pkg/utils"
|
||||
@@ -13,7 +15,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum, episodeNum int) (*string, error) {
|
||||
func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum int, episodeNums ...int) (*string, error) {
|
||||
trc, dlc, err := c.GetDownloadClient()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "connect transmission")
|
||||
@@ -31,39 +33,42 @@ func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum,
|
||||
return nil, errors.New("no enough space")
|
||||
}
|
||||
|
||||
var ep *ent.Episode
|
||||
if episodeNum > 0 {
|
||||
for _, e := range series.Episodes {
|
||||
if e.SeasonNumber == seasonNum && e.EpisodeNumber == episodeNum {
|
||||
ep = e
|
||||
}
|
||||
}
|
||||
if ep == nil {
|
||||
return nil, errors.Errorf("no episode of season %d episode %d", seasonNum, episodeNum)
|
||||
}
|
||||
} else { //season package download
|
||||
ep = &ent.Episode{}
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
torrent, err := trc.Download(magnet, downloadDir)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "downloading")
|
||||
}
|
||||
torrent.Start()
|
||||
|
||||
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,
|
||||
EpisodeID: ep.ID,
|
||||
SourceTitle: r1.Name,
|
||||
TargetDir: dir,
|
||||
Status: history.StatusRunning,
|
||||
Size: r1.Size,
|
||||
MediaID: seriesId,
|
||||
EpisodeNums: episodeNums,
|
||||
SeasonNum: seasonNum,
|
||||
SourceTitle: r1.Name,
|
||||
TargetDir: dir,
|
||||
Status: history.StatusRunning,
|
||||
Size: r1.Size,
|
||||
//Saved: torrent.Save(),
|
||||
Link: magnet,
|
||||
DownloadClientID: dlc.ID,
|
||||
@@ -72,39 +77,119 @@ func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum,
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "save record")
|
||||
}
|
||||
if episodeNum > 0 {
|
||||
if ep.Status == episode.StatusMissing {
|
||||
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
|
||||
}
|
||||
} else {
|
||||
c.db.SetSeasonAllEpisodeStatus(seriesId, seasonNum, episode.StatusDownloading)
|
||||
|
||||
torrent, err := trc.Download(magnet, downloadDir)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "downloading")
|
||||
}
|
||||
torrent.Start()
|
||||
|
||||
c.tasks[history.ID] = &Task{Torrent: torrent}
|
||||
c.sendMsg(fmt.Sprintf(message.BeginDownload, r1.Name))
|
||||
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
|
||||
|
||||
}
|
||||
func (c *Client) SearchAndDownload(seriesId, seasonNum, episodeNum int) (*string, error) {
|
||||
var episodes []int
|
||||
if episodeNum > 0 {
|
||||
episodes = append(episodes, episodeNum)
|
||||
|
||||
/*
|
||||
tmdb 校验获取的资源名,如果用资源名在tmdb搜索出来的结果能匹配上想要的资源,则认为资源有效,否则无效
|
||||
解决名称过于简单的影视会匹配过多资源的问题, 例如:梦魇绝镇 FROM
|
||||
*/
|
||||
func (c *Client) checkBtReourceWithTmdb(r *torznab.Result, seriesId int) bool {
|
||||
m := metadata.ParseTv(r.Name)
|
||||
se, err := c.MustTMDB().SearchMedia(m.NameEn, "", 1)
|
||||
if err != nil {
|
||||
log.Warnf("tmdb search error, consider this torrent ok: %v", err)
|
||||
return true
|
||||
} else {
|
||||
if len(se.Results) == 0 {
|
||||
log.Debugf("tmdb search no result, consider this torrent ok: %s", r.Name) //because tv name parse is not accurate
|
||||
return true
|
||||
}
|
||||
series := c.db.GetMediaDetails(seriesId)
|
||||
|
||||
se0 := se.Results[0]
|
||||
if se0.ID != int64(series.TmdbID) {
|
||||
log.Warnf("bt reosurce name not match tmdb id: %s", r.Name)
|
||||
return false
|
||||
} else { //resource tmdb id match
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) SearchAndDownload(seriesId, seasonNum int, episodeNums ...int) ([]string, error) {
|
||||
|
||||
res, err := SearchTvSeries(c.db, &SearchParam{
|
||||
MediaId: seriesId,
|
||||
SeasonNum: seasonNum,
|
||||
Episodes: episodes,
|
||||
Episodes: episodeNums,
|
||||
CheckFileSize: true,
|
||||
CheckResolution: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r1 := res[0]
|
||||
log.Infof("found resource to download: %+v", r1)
|
||||
return c.DownloadEpisodeTorrent(r1, seriesId, seasonNum, episodeNum)
|
||||
wanted := make(map[int]bool, len(episodeNums))
|
||||
for _, ep := range episodeNums {
|
||||
wanted[ep] = true
|
||||
}
|
||||
var torrentNames []string
|
||||
lo:
|
||||
for _, r := range res {
|
||||
if !c.checkBtReourceWithTmdb(&r, seriesId) {
|
||||
continue
|
||||
}
|
||||
m := metadata.ParseTv(r.Name)
|
||||
m.ParseExtraDescription(r.Description)
|
||||
if len(episodeNums) == 0 { //want season pack
|
||||
if m.IsSeasonPack {
|
||||
name, err := c.DownloadEpisodeTorrent(r, seriesId, seasonNum)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
torrentNames = append(torrentNames, *name)
|
||||
break lo
|
||||
}
|
||||
} else {
|
||||
torrentEpisodes := make([]int, 0)
|
||||
for i := m.StartEpisode; i <= m.EndEpisode; i++ {
|
||||
if !wanted[i] { //torrent has episode not wanted
|
||||
continue lo
|
||||
}
|
||||
torrentEpisodes = append(torrentEpisodes, i)
|
||||
}
|
||||
name, err := c.DownloadEpisodeTorrent(r, seriesId, seasonNum, torrentEpisodes...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
torrentNames = append(torrentNames, *name)
|
||||
|
||||
for _, num := range torrentEpisodes {
|
||||
delete(wanted, num) //delete downloaded episode from wanted
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(wanted) > 0 {
|
||||
log.Warnf("still wanted but not downloaded episodes: %v", wanted)
|
||||
}
|
||||
return torrentNames, nil
|
||||
}
|
||||
|
||||
func (c *Client) DownloadMovie(m *ent.Media, link, name string, size int, indexerID int) (*string, error) {
|
||||
@@ -129,12 +214,12 @@ func (c *Client) DownloadMovie(m *ent.Media, link, name string, size int, indexe
|
||||
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: size,
|
||||
MediaID: m.ID,
|
||||
EpisodeID: ep.ID,
|
||||
SourceTitle: name,
|
||||
TargetDir: m.TargetDir,
|
||||
Status: history.StatusRunning,
|
||||
Size: size,
|
||||
//Saved: torrent.Save(),
|
||||
Link: magnet,
|
||||
DownloadClientID: dlc.ID,
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"polaris/pkg"
|
||||
"polaris/pkg/notifier/message"
|
||||
"polaris/pkg/utils"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -36,6 +37,7 @@ func (c *Client) addSysCron() {
|
||||
return true
|
||||
})
|
||||
c.cron.Start()
|
||||
log.Infof("--------- add cron jobs done --------")
|
||||
}
|
||||
|
||||
func (c *Client) mustAddCron(spec string, cmd func()) {
|
||||
@@ -113,6 +115,38 @@ func (c *Client) postTaskProcessing(id int) {
|
||||
}
|
||||
}
|
||||
|
||||
func getSeasonNum(h *ent.History) int {
|
||||
if h.SeasonNum != 0 {
|
||||
return h.SeasonNum
|
||||
}
|
||||
seasonNum, err := utils.SeasonId(h.TargetDir)
|
||||
if err != nil {
|
||||
log.Errorf("no season id: %v", h.TargetDir)
|
||||
seasonNum = -1
|
||||
}
|
||||
return seasonNum
|
||||
}
|
||||
|
||||
func (c *Client) GetEpisodeIds(r *ent.History) []int {
|
||||
var episodeIds []int
|
||||
seasonNum := getSeasonNum(r)
|
||||
|
||||
if r.EpisodeID > 0 {
|
||||
episodeIds = append(episodeIds, r.EpisodeID)
|
||||
}
|
||||
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 {
|
||||
episodeIds = append(episodeIds, ep.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return episodeIds
|
||||
}
|
||||
|
||||
func (c *Client) moveCompletedTask(id int) (err1 error) {
|
||||
torrent := c.tasks[id]
|
||||
r := c.db.GetHistory(id)
|
||||
@@ -121,11 +155,7 @@ func (c *Client) moveCompletedTask(id int) (err1 error) {
|
||||
return nil
|
||||
}
|
||||
c.db.SetHistoryStatus(r.ID, history.StatusUploading)
|
||||
seasonNum, err := utils.SeasonId(r.TargetDir)
|
||||
if err != nil {
|
||||
log.Errorf("no season id: %v", r.TargetDir)
|
||||
seasonNum = -1
|
||||
}
|
||||
|
||||
downloadclient, err := c.db.GetDownloadClient(r.DownloadClientID)
|
||||
if err != nil {
|
||||
log.Errorf("get task download client error: %v, use default one", err)
|
||||
@@ -136,13 +166,19 @@ 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 r.EpisodeID != 0 {
|
||||
if !c.db.IsEpisodeDownloadingOrDownloaded(r.EpisodeID) {
|
||||
c.db.SetEpisodeStatus(r.EpisodeID, episode.StatusMissing)
|
||||
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)
|
||||
@@ -171,10 +207,13 @@ func (c *Client) moveCompletedTask(id int) (err1 error) {
|
||||
if err := stImpl.Copy(filepath.Join(c.db.GetDownloadDir(), torrentName), r.TargetDir); err != nil {
|
||||
return errors.Wrap(err, "move file")
|
||||
}
|
||||
torrent.UploadProgresser = stImpl.UploadProgress
|
||||
|
||||
c.db.SetHistoryStatus(r.ID, history.StatusSeeding)
|
||||
if r.EpisodeID != 0 {
|
||||
c.db.SetEpisodeStatus(r.EpisodeID, episode.StatusDownloaded)
|
||||
if len(episodeIds) > 0 {
|
||||
for _, id := range episodeIds {
|
||||
c.db.SetEpisodeStatus(id, episode.StatusDownloaded)
|
||||
}
|
||||
} else {
|
||||
c.db.SetSeasonAllEpisodeStatus(r.MediaID, seasonNum, episode.StatusDownloaded)
|
||||
}
|
||||
@@ -247,6 +286,7 @@ func (c *Client) CheckDownloadedSeriesFiles(m *ent.Media) error {
|
||||
type Task struct {
|
||||
//Processing bool
|
||||
pkg.Torrent
|
||||
UploadProgresser func() float64
|
||||
}
|
||||
|
||||
func (c *Client) DownloadSeriesAllEpisodes(id int) []string {
|
||||
@@ -261,40 +301,53 @@ func (c *Client) DownloadSeriesAllEpisodes(id int) []string {
|
||||
continue
|
||||
}
|
||||
wantedSeasonPack := true
|
||||
seasonEpisodesWanted := make(map[int][]int, 0)
|
||||
for _, ep := range epsides {
|
||||
if !ep.Monitored {
|
||||
wantedSeasonPack = false
|
||||
continue
|
||||
}
|
||||
if ep.Status != episode.StatusMissing {
|
||||
wantedSeasonPack = false
|
||||
continue
|
||||
}
|
||||
if ep.AirDate != "" {
|
||||
t, err := time.Parse("2006-01-02", ep.AirDate)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
/*
|
||||
-------- now ------ t -----
|
||||
t - 1day < now 要检测的剧集
|
||||
提前一天开始检测
|
||||
*/
|
||||
if time.Now().Before(t.Add(-24 * time.Hour)) { //not aired
|
||||
wantedSeasonPack = false
|
||||
continue
|
||||
}
|
||||
}
|
||||
seasonEpisodesWanted[ep.SeasonNumber] = append(seasonEpisodesWanted[ep.SeasonNumber], ep.EpisodeNumber)
|
||||
}
|
||||
if wantedSeasonPack {
|
||||
name, err := c.SearchAndDownload(id, seasonNum, -1)
|
||||
names, err := c.SearchAndDownload(id, seasonNum)
|
||||
if err == nil {
|
||||
allNames = append(allNames, *name)
|
||||
log.Infof("begin download torrent resource: %v", name)
|
||||
allNames = append(allNames, names...)
|
||||
log.Infof("begin download torrent resource: %v", names)
|
||||
} else {
|
||||
log.Warnf("finding season pack error: %v", err)
|
||||
wantedSeasonPack = false
|
||||
}
|
||||
|
||||
}
|
||||
if !wantedSeasonPack {
|
||||
for _, ep := range epsides {
|
||||
if !ep.Monitored {
|
||||
continue
|
||||
}
|
||||
if ep.Status != episode.StatusMissing {
|
||||
continue
|
||||
}
|
||||
name, err := c.SearchAndDownload(id, ep.SeasonNumber, ep.EpisodeNumber)
|
||||
|
||||
for se, eps := range seasonEpisodesWanted {
|
||||
names, err := c.SearchAndDownload(id, se, eps...)
|
||||
if err != nil {
|
||||
log.Warnf("finding resoruces of season %d episode %d error: %v", ep.SeasonNumber, ep.EpisodeNumber, err)
|
||||
log.Warnf("finding resoruces of season %d episode %v error: %v", se, eps, err)
|
||||
continue
|
||||
} else {
|
||||
allNames = append(allNames, *name)
|
||||
log.Infof("begin download torrent resource: %v", name)
|
||||
allNames = append(allNames, names...)
|
||||
log.Infof("begin download torrent resource: %v", names)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,12 +429,12 @@ func (c *Client) downloadMovieSingleEpisode(ep *ent.Episode, targetDir string) (
|
||||
torrent.Start()
|
||||
|
||||
history, err := c.db.SaveHistoryRecord(ent.History{
|
||||
MediaID: ep.MediaID,
|
||||
EpisodeID: ep.ID,
|
||||
SourceTitle: r1.Name,
|
||||
TargetDir: targetDir,
|
||||
Status: history.StatusRunning,
|
||||
Size: r1.Size,
|
||||
MediaID: ep.MediaID,
|
||||
EpisodeID: ep.ID,
|
||||
SourceTitle: r1.Name,
|
||||
TargetDir: targetDir,
|
||||
Status: history.StatusRunning,
|
||||
Size: r1.Size,
|
||||
//Saved: torrent.Save(),
|
||||
Link: magnet,
|
||||
DownloadClientID: dlc.ID,
|
||||
|
||||
@@ -33,15 +33,15 @@ func SearchTvSeries(db1 *db.Client, param *SearchParam) ([]torznab.Result, error
|
||||
}
|
||||
log.Debugf("check tv series %s, season %d, episode %v", series.NameEn, param.SeasonNum, param.Episodes)
|
||||
|
||||
res := searchWithTorznab(db1, series.NameEn, series.NameCn, series.OriginalName)
|
||||
res := searchWithTorznab(db1, prowlarr.TV, series.NameEn, series.NameCn, series.OriginalName)
|
||||
|
||||
var filtered []torznab.Result
|
||||
lo:
|
||||
for _, r := range res {
|
||||
//log.Infof("torrent resource: %+v", r)
|
||||
meta := metadata.ParseTv(r.Name)
|
||||
if meta == nil { //cannot parse name
|
||||
continue
|
||||
}
|
||||
meta.ParseExtraDescription(r.Description)
|
||||
|
||||
if isImdbidNotMatch(series.ImdbID, r.ImdbId) { //has imdb id and not match
|
||||
continue
|
||||
}
|
||||
@@ -61,9 +61,15 @@ func SearchTvSeries(db1 *db.Client, param *SearchParam) ([]torznab.Result, error
|
||||
continue
|
||||
}
|
||||
|
||||
if len(param.Episodes) > 0 && !slices.Contains(param.Episodes, meta.Episode) { //not season pack, but episode number not equal
|
||||
continue
|
||||
|
||||
if len(param.Episodes) > 0 { //not season pack, but episode number not equal
|
||||
if meta.StartEpisode <= 0 {
|
||||
continue lo
|
||||
}
|
||||
for i := meta.StartEpisode; i <= meta.EndEpisode; i++ {
|
||||
if !slices.Contains(param.Episodes, i) {
|
||||
continue lo
|
||||
}
|
||||
}
|
||||
} else if len(param.Episodes) == 0 && !meta.IsSeasonPack { //want season pack, but not season pack
|
||||
continue
|
||||
}
|
||||
@@ -74,7 +80,7 @@ func SearchTvSeries(db1 *db.Client, param *SearchParam) ([]torznab.Result, error
|
||||
continue
|
||||
}
|
||||
|
||||
if !torrentSizeOk(series, r.Size, param) {
|
||||
if !torrentSizeOk(series, r.Size, meta.EndEpisode+1-meta.StartEpisode, param) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -108,7 +114,7 @@ func imdbIDMatchExact(id1, id2 string) bool {
|
||||
return id1 == id2
|
||||
}
|
||||
|
||||
func torrentSizeOk(detail *db.MediaDetails, torrentSize int, param *SearchParam) bool {
|
||||
func torrentSizeOk(detail *db.MediaDetails, torrentSize int, torrentEpisodeNum int, param *SearchParam) bool {
|
||||
defaultMinSize := 80 * 1000 * 1000 //tv, 80M min
|
||||
if detail.MediaType == media.MediaTypeMovie {
|
||||
defaultMinSize = 200 * 1000 * 1000 // movie, 200M min
|
||||
@@ -117,9 +123,13 @@ func torrentSizeOk(detail *db.MediaDetails, torrentSize int, param *SearchParam)
|
||||
defaultMinSize = detail.Limiter.SizeMin
|
||||
}
|
||||
|
||||
multiplier := 1 //大小倍数,正常为1,如果是季包则为季内集数
|
||||
if detail.MediaType == media.MediaTypeTv && len(param.Episodes) == 0 { //tv season pack
|
||||
multiplier = seasonEpisodeCount(detail, param.SeasonNum)
|
||||
multiplier := 1 //大小倍数,正常为1,如果是季包则为季内集数
|
||||
if detail.MediaType == media.MediaTypeTv {
|
||||
if len(param.Episodes) == 0 { //want tv season pack
|
||||
multiplier = seasonEpisodeCount(detail, param.SeasonNum)
|
||||
} else {
|
||||
multiplier = torrentEpisodeNum
|
||||
}
|
||||
}
|
||||
|
||||
if param.CheckFileSize { //check file size when trigger automatic download
|
||||
@@ -171,9 +181,9 @@ func SearchMovie(db1 *db.Client, param *SearchParam) ([]torznab.Result, error) {
|
||||
return nil, errors.New("no media found of id")
|
||||
}
|
||||
|
||||
res := searchWithTorznab(db1, movieDetail.NameEn, movieDetail.NameCn, movieDetail.OriginalName)
|
||||
res := searchWithTorznab(db1, prowlarr.Movie, movieDetail.NameEn, movieDetail.NameCn, movieDetail.OriginalName)
|
||||
if movieDetail.Extras.IsJav() {
|
||||
res1 := searchWithTorznab(db1, movieDetail.Extras.JavId)
|
||||
res1 := searchWithTorznab(db1, prowlarr.Movie, movieDetail.Extras.JavId)
|
||||
res = append(res, res1...)
|
||||
}
|
||||
|
||||
@@ -211,7 +221,7 @@ func SearchMovie(db1 *db.Client, param *SearchParam) ([]torznab.Result, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if !torrentSizeOk(movieDetail, r.Size, param) {
|
||||
if !torrentSizeOk(movieDetail, r.Size, 1, param) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -227,15 +237,15 @@ func SearchMovie(db1 *db.Client, param *SearchParam) ([]torznab.Result, error) {
|
||||
|
||||
}
|
||||
|
||||
func searchWithTorznab(db *db.Client, queries ...string) []torznab.Result {
|
||||
func searchWithTorznab(db *db.Client, t prowlarr.ProwlarrSupportType, queries ...string) []torznab.Result {
|
||||
|
||||
var res []torznab.Result
|
||||
allTorznab := db.GetAllTorznabInfo()
|
||||
|
||||
p, err := db.GetProwlarrSetting()
|
||||
if err == nil { //prowlarr exists
|
||||
if err == nil && !p.Disabled { //prowlarr exists
|
||||
c := prowlarr.New(p.ApiKey, p.URL)
|
||||
all, err := c.GetIndexers()
|
||||
all, err := c.GetIndexers(t)
|
||||
if err != nil {
|
||||
log.Warnf("get prowlarr all indexer error: %v", err)
|
||||
} else {
|
||||
|
||||
@@ -28,7 +28,7 @@ func (s *Server) searchAndDownloadSeasonPackage(seriesId, seasonNum int) (*strin
|
||||
|
||||
r1 := res[0]
|
||||
log.Infof("found resource to download: %+v", r1)
|
||||
return s.core.DownloadEpisodeTorrent(r1, seriesId, seasonNum, -1)
|
||||
return s.core.DownloadEpisodeTorrent(r1, seriesId, seasonNum)
|
||||
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func (s *Server) SearchTvAndDownload(c *gin.Context) (interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "download")
|
||||
}
|
||||
name = *name1
|
||||
name = name1[0]
|
||||
}
|
||||
|
||||
return gin.H{
|
||||
@@ -154,7 +154,7 @@ func (s *Server) DownloadTorrent(c *gin.Context) (interface{}, error) {
|
||||
name = fmt.Sprintf("%v S%02d", m.OriginalName, in.Season)
|
||||
}
|
||||
res := torznab.Result{Name: name, Link: in.Link, Size: in.Size}
|
||||
return s.core.DownloadEpisodeTorrent(res, in.MediaID, in.Season, -1)
|
||||
return s.core.DownloadEpisodeTorrent(res, in.MediaID, in.Season)
|
||||
}
|
||||
name := in.Name
|
||||
if name == "" {
|
||||
@@ -175,6 +175,10 @@ func (s *Server) DownloadAll(c *gin.Context) (interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "convert")
|
||||
}
|
||||
return s.downloadAllEpisodes(id)
|
||||
}
|
||||
|
||||
func (s *Server) downloadAllEpisodes(id int) (interface{}, error) {
|
||||
m, err := s.db.GetMedia(id)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get media")
|
||||
@@ -186,3 +190,27 @@ func (s *Server) DownloadAll(c *gin.Context) (interface{}, error) {
|
||||
|
||||
return []string{name}, err
|
||||
}
|
||||
|
||||
func (s *Server) DownloadAllTv(c *gin.Context) (interface{}, error) {
|
||||
tvs := s.db.GetMediaWatchlist(media.MediaTypeTv)
|
||||
var allNames []string
|
||||
for _, tv := range tvs {
|
||||
names, err := s.downloadAllEpisodes(tv.ID)
|
||||
if err == nil {
|
||||
allNames = append(allNames, names.([]string)...)
|
||||
}
|
||||
}
|
||||
return allNames, nil
|
||||
}
|
||||
|
||||
func (s *Server) DownloadAllMovies(c *gin.Context) (interface{}, error) {
|
||||
movies := s.db.GetMediaWatchlist(media.MediaTypeMovie)
|
||||
var allNames []string
|
||||
for _, mv := range movies {
|
||||
names, err := s.downloadAllEpisodes(mv.ID)
|
||||
if err == nil {
|
||||
allNames = append(allNames, names.([]string)...)
|
||||
}
|
||||
}
|
||||
return allNames, nil
|
||||
}
|
||||
|
||||
@@ -96,6 +96,8 @@ func (s *Server) Serve() error {
|
||||
tv.GET("/suggest/tv/:tmdb_id", HttpHandler(s.SuggestedSeriesFolderName))
|
||||
tv.GET("/suggest/movie/:tmdb_id", HttpHandler(s.SuggestedMovieFolderName))
|
||||
tv.GET("/downloadall/:id", HttpHandler(s.DownloadAll))
|
||||
tv.GET("/download/tv", HttpHandler(s.DownloadAllTv))
|
||||
tv.GET("/download/movie", HttpHandler(s.DownloadAllMovies))
|
||||
}
|
||||
indexer := api.Group("/indexer")
|
||||
{
|
||||
@@ -130,6 +132,7 @@ func (s *Server) Serve() error {
|
||||
importlist.POST("/add", HttpHandler(s.addImportlist))
|
||||
importlist.DELETE("/delete", HttpHandler(s.deleteImportList))
|
||||
}
|
||||
log.Infof("----------- Polaris Server Successfully Started ------------")
|
||||
|
||||
return s.r.Run(":8080")
|
||||
}
|
||||
|
||||
@@ -71,7 +71,6 @@ func (s *Server) SetSetting(c *gin.Context) (interface{}, error) {
|
||||
if _, err := template.New("test").Parse(in.MovieNamingFormat); err != nil {
|
||||
return nil, errors.Wrap(err, "movie format")
|
||||
}
|
||||
|
||||
s.db.SetSetting(db.SettingMovieNamingFormat, in.MovieNamingFormat)
|
||||
} else {
|
||||
s.db.SetSetting(db.SettingMovieNamingFormat, "")
|
||||
@@ -105,6 +104,7 @@ func (s *Server) SetSetting(c *gin.Context) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
func (s *Server) GetSetting(c *gin.Context) (interface{}, error) {
|
||||
tmdb := s.db.GetSetting(db.SettingTmdbApiKey)
|
||||
downloadDir := s.db.GetSetting(db.SettingDownloadDir)
|
||||
@@ -317,9 +317,11 @@ func (s *Server) SaveProwlarrSetting(c *gin.Context) (interface{}, error) {
|
||||
if err := c.ShouldBindJSON(&in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client := prowlarr.New(in.ApiKey, in.URL)
|
||||
if _, err := client.GetIndexers(); err != nil {
|
||||
return nil, errors.Wrap(err, "connect to prowlarr error")
|
||||
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")
|
||||
}
|
||||
}
|
||||
err := s.db.SaveProwlarrSetting(&in)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,9 +2,11 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"polaris/db"
|
||||
|
||||
"polaris/log"
|
||||
"polaris/pkg/alist"
|
||||
"polaris/pkg/storage"
|
||||
"polaris/pkg/utils"
|
||||
"strconv"
|
||||
@@ -39,6 +41,21 @@ func (s *Server) AddStorage(c *gin.Context) (interface{}, error) {
|
||||
for _, f := range fs {
|
||||
log.Infof("file name: %v", f.Name())
|
||||
}
|
||||
} else if in.Implementation == "alist" {
|
||||
cfg := in.ToAlistSetting()
|
||||
_, err := storage.NewAlist(&alist.Config{URL: cfg.URL, Username: cfg.User, Password: cfg.Password}, in.TvPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "alist")
|
||||
}
|
||||
} else if in.Implementation == "local" {
|
||||
_, err := os.Stat(in.TvPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = os.Stat(in.MoviePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
log.Infof("received add storage input: %v", in)
|
||||
err := s.db.AddStorage(&in)
|
||||
|
||||
BIN
ui/assets/wechat.jpg
Normal file
BIN
ui/assets/wechat.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
@@ -148,7 +148,7 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
|
||||
},
|
||||
));
|
||||
},
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
})
|
||||
],
|
||||
|
||||
118
ui/lib/init_wizard.dart
Normal file
118
ui/lib/init_wizard.dart
Normal file
@@ -0,0 +1,118 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:ui/settings/downloader.dart';
|
||||
import 'package:ui/settings/prowlarr.dart';
|
||||
import 'package:ui/settings/storage.dart';
|
||||
|
||||
class InitWizard extends ConsumerStatefulWidget {
|
||||
const InitWizard({super.key});
|
||||
static final String route = "/init_wizard";
|
||||
@override
|
||||
ConsumerState<ConsumerStatefulWidget> createState() {
|
||||
return _InitWizardState();
|
||||
}
|
||||
}
|
||||
|
||||
class _InitWizardState extends ConsumerState<InitWizard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SelectionArea(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(50),
|
||||
child: ListView(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
"Polaris 影视追踪下载",
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 10, top: 30, bottom: 30),
|
||||
child: Text(
|
||||
"设置向导",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
),
|
||||
tmdbSetting(),
|
||||
downloaderSetting(),
|
||||
indexerSetting(),
|
||||
storageSetting(),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget tmdbSetting() {
|
||||
return ExpansionTile(
|
||||
title: Text(
|
||||
"第一步:TMDB设置",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
childrenPadding: EdgeInsets.only(left: 100, right: 20),
|
||||
initiallyExpanded: true,
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text("TMDB API Key 设置,用来获取各种影视的信息,API Key获取方式参考官网"),
|
||||
),
|
||||
FormBuilder(
|
||||
child: Column(
|
||||
children: [
|
||||
FormBuilderTextField(
|
||||
name: "tmdb",
|
||||
decoration: InputDecoration(labelText: "TMDB API Key"),
|
||||
),
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: ElevatedButton(onPressed: null, child: Text("保存")),
|
||||
))
|
||||
],
|
||||
))
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget indexerSetting() {
|
||||
return ExpansionTile(
|
||||
initiallyExpanded: true,
|
||||
childrenPadding: EdgeInsets.only(left: 100, right: 20),
|
||||
title: Text(
|
||||
"第三步:Prowlarr设置",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: [ProwlarrSettingPage()],
|
||||
);
|
||||
}
|
||||
|
||||
Widget downloaderSetting() {
|
||||
return ExpansionTile(
|
||||
childrenPadding: EdgeInsets.only(left: 100, right: 20),
|
||||
initiallyExpanded: true,
|
||||
title: Text("第二步:下载客户端", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
children: [
|
||||
DownloaderSettings(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget storageSetting() {
|
||||
return ExpansionTile(
|
||||
childrenPadding: EdgeInsets.only(left: 100, right: 20),
|
||||
title: Text("第四步:存储设置", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
initiallyExpanded: true,
|
||||
children: [StorageSettings()],
|
||||
);
|
||||
}
|
||||
}
|
||||
353
ui/lib/main.dart
353
ui/lib/main.dart
@@ -5,6 +5,7 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:ui/activity.dart';
|
||||
import 'package:ui/calendar.dart';
|
||||
import 'package:ui/init_wizard.dart';
|
||||
import 'package:ui/login_page.dart';
|
||||
import 'package:ui/movie_watchlist.dart';
|
||||
import 'package:ui/providers/APIs.dart';
|
||||
@@ -49,81 +50,92 @@ class _MyAppState extends ConsumerState<MyApp> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var padding = isSmallScreen(context) ? 5.0 : 20.0;
|
||||
// GoRouter configuration
|
||||
final shellRoute = ShellRoute(
|
||||
builder: (BuildContext context, GoRouterState state, Widget child) {
|
||||
return SelectionArea(
|
||||
child: MainSkeleton(
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(left: padding, right: padding, top: 5, bottom: 5),
|
||||
child: child),
|
||||
),
|
||||
final shellRoute = StatefulShellRoute.indexedStack(
|
||||
builder: (BuildContext context, GoRouterState state,
|
||||
StatefulNavigationShell navigationShell) {
|
||||
return MainSkeleton(
|
||||
body: navigationShell,
|
||||
);
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: "/",
|
||||
redirect: (context, state) => WelcomePage.routeTv,
|
||||
),
|
||||
GoRoute(
|
||||
path: WelcomePage.routeTv,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context, state: state, child: const WelcomePage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: WelcomePage.routeMoivie,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context, state: state, child: const WelcomePage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: TvDetailsPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context,
|
||||
state: state,
|
||||
child: TvDetailsPage(seriesId: state.pathParameters['id']!)),
|
||||
),
|
||||
GoRoute(
|
||||
path: MovieDetailsPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context,
|
||||
state: state,
|
||||
child: MovieDetailsPage(id: state.pathParameters['id']!)),
|
||||
),
|
||||
GoRoute(
|
||||
path: SearchPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context,
|
||||
state: state,
|
||||
child: SearchPage(query: state.uri.queryParameters["query"])),
|
||||
),
|
||||
GoRoute(
|
||||
path: SystemSettingsPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context,
|
||||
state: state,
|
||||
child: const SystemSettingsPage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: ActivityPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context, state: state, child: const ActivityPage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: SystemPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context, state: state, child: const SystemPage()),
|
||||
)
|
||||
branches: [
|
||||
StatefulShellBranch(initialLocation: WelcomePage.routeTv, routes: [
|
||||
GoRoute(
|
||||
path: WelcomePage.routeTv,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context, state: state, child: const WelcomePage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: TvDetailsPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context,
|
||||
state: state,
|
||||
child: TvDetailsPage(seriesId: state.pathParameters['id']!)),
|
||||
),
|
||||
GoRoute(
|
||||
path: SearchPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context,
|
||||
state: state,
|
||||
child: SearchPage(query: state.uri.queryParameters["query"])),
|
||||
),
|
||||
]),
|
||||
StatefulShellBranch(initialLocation: WelcomePage.routeMoivie, routes: [
|
||||
GoRoute(
|
||||
path: WelcomePage.routeMoivie,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context, state: state, child: const WelcomePage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: MovieDetailsPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context,
|
||||
state: state,
|
||||
child: MovieDetailsPage(id: state.pathParameters['id']!)),
|
||||
),
|
||||
]),
|
||||
StatefulShellBranch(routes: [
|
||||
GoRoute(
|
||||
path: ActivityPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context, state: state, child: const ActivityPage()),
|
||||
),
|
||||
]),
|
||||
StatefulShellBranch(routes: [
|
||||
GoRoute(
|
||||
path: SystemSettingsPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context,
|
||||
state: state,
|
||||
child: const SystemSettingsPage()),
|
||||
),
|
||||
]),
|
||||
StatefulShellBranch(routes: [
|
||||
GoRoute(
|
||||
path: SystemPage.route,
|
||||
pageBuilder: (context, state) => buildPageWithDefaultTransition(
|
||||
context: context, state: state, child: const SystemPage()),
|
||||
)
|
||||
]),
|
||||
],
|
||||
);
|
||||
|
||||
final router = GoRouter(
|
||||
navigatorKey: APIs.navigatorKey,
|
||||
initialLocation: WelcomePage.routeTv,
|
||||
routes: [
|
||||
shellRoute,
|
||||
GoRoute(
|
||||
path: "/",
|
||||
redirect: (context, state) => WelcomePage.routeTv,
|
||||
),
|
||||
GoRoute(
|
||||
path: LoginScreen.route,
|
||||
builder: (context, state) => const LoginScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: InitWizard.route,
|
||||
builder: (context, state) => const InitWizard(),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -153,7 +165,7 @@ class _MyAppState extends ConsumerState<MyApp> {
|
||||
}
|
||||
|
||||
class MainSkeleton extends StatefulWidget {
|
||||
final Widget body;
|
||||
final StatefulNavigationShell body;
|
||||
const MainSkeleton({super.key, required this.body});
|
||||
|
||||
@override
|
||||
@@ -163,111 +175,17 @@ class MainSkeleton extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MainSkeletonState extends State<MainSkeleton> {
|
||||
var _selectedTab;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var uri = GoRouterState.of(context).uri.toString();
|
||||
if (uri.contains(WelcomePage.routeTv)) {
|
||||
_selectedTab = 0;
|
||||
} else if (uri.contains(WelcomePage.routeMoivie)) {
|
||||
_selectedTab = 1;
|
||||
} else if (uri.contains(ActivityPage.route)) {
|
||||
_selectedTab = 2;
|
||||
} else if (uri.contains(SystemSettingsPage.route)) {
|
||||
_selectedTab = 3;
|
||||
} else if (uri.contains(SystemPage.route)) {
|
||||
_selectedTab = 4;
|
||||
}
|
||||
|
||||
var padding = isSmallScreen(context) ? 5.0 : 20.0;
|
||||
return AdaptiveScaffold(
|
||||
appBarBreakpoint: Breakpoints.standard,
|
||||
appBar: AppBar(
|
||||
// TRY THIS: Try changing the color here to a specific color (to
|
||||
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
|
||||
// change color while the other colors stay the same.
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: TextButton(
|
||||
onPressed: () => context.go(WelcomePage.routeTv),
|
||||
child: const Text(
|
||||
"Polaris",
|
||||
overflow: TextOverflow.clip,
|
||||
style: TextStyle(fontSize: 28),
|
||||
),
|
||||
),
|
||||
|
||||
actions: [
|
||||
SearchAnchor(
|
||||
builder: (BuildContext context, SearchController controller) {
|
||||
return Container(
|
||||
constraints: const BoxConstraints(maxWidth: 250, maxHeight: 40),
|
||||
child: Opacity(
|
||||
opacity: 0.8,
|
||||
child: SearchBar(
|
||||
hintText: "搜索...",
|
||||
leading: const Icon(Icons.search),
|
||||
controller: controller,
|
||||
shadowColor: WidgetStateColor.transparent,
|
||||
backgroundColor: WidgetStatePropertyAll(
|
||||
Theme.of(context).colorScheme.primaryContainer),
|
||||
onSubmitted: (value) => context.go(Uri(
|
||||
path: SearchPage.route,
|
||||
queryParameters: {'query': value}).toString()),
|
||||
),
|
||||
),
|
||||
);
|
||||
}, suggestionsBuilder:
|
||||
(BuildContext context, SearchController controller) {
|
||||
return [Text("dadada")];
|
||||
}),
|
||||
IconButton(
|
||||
onPressed: () => showCalendar(context),
|
||||
icon: Icon(Icons.calendar_month)),
|
||||
MenuAnchor(
|
||||
menuChildren: [
|
||||
MenuItemButton(
|
||||
leadingIcon: const Icon(Icons.exit_to_app),
|
||||
child: const Text("登出"),
|
||||
onPressed: () async {
|
||||
await APIs.logout();
|
||||
},
|
||||
),
|
||||
],
|
||||
builder: (context, controller, child) {
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
if (controller.isOpen) {
|
||||
controller.close();
|
||||
} else {
|
||||
controller.open();
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.account_circle),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
appBar: appBar(),
|
||||
useDrawer: false,
|
||||
selectedIndex: _selectedTab,
|
||||
onSelectedIndexChange: (int index) {
|
||||
setState(() {
|
||||
_selectedTab = index;
|
||||
});
|
||||
if (index == 0) {
|
||||
context.go(WelcomePage.routeTv);
|
||||
} else if (index == 1) {
|
||||
context.go(WelcomePage.routeMoivie);
|
||||
} else if (index == 2) {
|
||||
context.go(ActivityPage.route);
|
||||
} else if (index == 3) {
|
||||
context.go(SystemSettingsPage.route);
|
||||
} else if (index == 4) {
|
||||
context.go(SystemPage.route);
|
||||
}
|
||||
},
|
||||
selectedIndex: widget.body.currentIndex,
|
||||
onSelectedIndexChange: (p0) => widget.body
|
||||
.goBranch(p0, initialLocation: p0 == widget.body.currentIndex),
|
||||
|
||||
destinations: const <NavigationDestination>[
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.live_tv_outlined),
|
||||
@@ -295,11 +213,118 @@ class _MainSkeletonState extends State<MainSkeleton> {
|
||||
label: '系统',
|
||||
),
|
||||
],
|
||||
body: (context) => SafeArea(child: widget.body),
|
||||
body: (context) => SafeArea(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: padding, right: padding, top: 5, bottom: 5),
|
||||
child: widget.body)),
|
||||
// Define a default secondaryBody.
|
||||
// Override the default secondaryBody during the smallBreakpoint to be
|
||||
// empty. Must use AdaptiveScaffold.emptyBuilder to ensure it is properly
|
||||
// overridden.
|
||||
);
|
||||
}
|
||||
|
||||
showDonate(BuildContext context) {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("项目开发不易,给开发者加个鸡腿:"),
|
||||
content: SizedBox(
|
||||
width: 350,
|
||||
height: 400,
|
||||
child: Ink.image(
|
||||
fit: BoxFit.fitWidth,
|
||||
image: AssetImage("assets/wechat.jpg"))),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
AppBar appBar() {
|
||||
return AppBar(
|
||||
// TRY THIS: Try changing the color here to a specific color (to
|
||||
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
|
||||
// change color while the other colors stay the same.
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
leading: Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton(
|
||||
onPressed: () => context.go(WelcomePage.routeTv),
|
||||
child: const Text(
|
||||
"Polaris",
|
||||
overflow: TextOverflow.clip,
|
||||
style: TextStyle(fontSize: 28),
|
||||
),
|
||||
),
|
||||
),
|
||||
leadingWidth: isSmallScreen(context) ? 0 : 190,
|
||||
title: Container(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: SearchAnchor(
|
||||
builder: (BuildContext context, SearchController controller) {
|
||||
return Container(
|
||||
constraints: const BoxConstraints(maxWidth: 250, maxHeight: 40),
|
||||
child: Opacity(
|
||||
opacity: 0.8,
|
||||
child: SearchBar(
|
||||
hintText: "在此搜索...",
|
||||
leading: const Icon(Icons.search),
|
||||
controller: controller,
|
||||
shadowColor: WidgetStateColor.transparent,
|
||||
backgroundColor: WidgetStatePropertyAll(
|
||||
Theme.of(context).colorScheme.primaryContainer),
|
||||
onSubmitted: (value) => context.go(Uri(
|
||||
path: SearchPage.route,
|
||||
queryParameters: {'query': value}).toString()),
|
||||
),
|
||||
),
|
||||
);
|
||||
}, suggestionsBuilder:
|
||||
(BuildContext context, SearchController controller) {
|
||||
return [Text("dadada")];
|
||||
}),
|
||||
),
|
||||
|
||||
actions: [
|
||||
// IconButton(
|
||||
// onPressed: () => showCalendar(context),
|
||||
// icon: Icon(Icons.calendar_month)),
|
||||
IconButton(
|
||||
onPressed: () => showDonate(context),
|
||||
icon: Icon(
|
||||
Icons.favorite_rounded,
|
||||
color: Colors.red,
|
||||
)),
|
||||
|
||||
MenuAnchor(
|
||||
menuChildren: [
|
||||
MenuItemButton(
|
||||
leadingIcon: const Icon(Icons.exit_to_app),
|
||||
child: const Text("登出"),
|
||||
onPressed: () async {
|
||||
await APIs.logout();
|
||||
},
|
||||
),
|
||||
],
|
||||
builder: (context, controller, child) {
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
if (controller.isOpen) {
|
||||
controller.close();
|
||||
} else {
|
||||
controller.open();
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.account_circle),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,21 +28,22 @@ class _MovieDetailsPageState extends ConsumerState<MovieDetailsPage> {
|
||||
Widget build(BuildContext context) {
|
||||
var seriesDetails = ref.watch(mediaDetailsProvider(widget.id));
|
||||
|
||||
return seriesDetails.when(
|
||||
data: (details) {
|
||||
return ListView(
|
||||
children: [
|
||||
DetailCard(details: details),
|
||||
NestedTabBar(
|
||||
id: widget.id,
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
error: (err, trace) {
|
||||
return Text("$err");
|
||||
},
|
||||
loading: () => const MyProgressIndicator());
|
||||
return SelectionArea(
|
||||
child: seriesDetails.when(
|
||||
data: (details) {
|
||||
return ListView(
|
||||
children: [
|
||||
DetailCard(details: details),
|
||||
NestedTabBar(
|
||||
id: widget.id,
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
error: (err, trace) {
|
||||
return Text("$err");
|
||||
},
|
||||
loading: () => const MyProgressIndicator()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -8,9 +10,12 @@ class APIs {
|
||||
static final _baseUrl = baseUrl();
|
||||
static final searchUrl = "$_baseUrl/api/v1/media/search";
|
||||
static final editMediaUrl = "$_baseUrl/api/v1/media/edit";
|
||||
static final downloadAllUrl = "$_baseUrl/api/v1/media/downloadall/";
|
||||
static final downloadAllEpisodesUrl = "$_baseUrl/api/v1/media/downloadall/";
|
||||
static final downloadAllTvUrl = "$_baseUrl/api/v1/media/download/tv";
|
||||
static final downloadAllMovieUrl = "$_baseUrl/api/v1/media/download/movie";
|
||||
static final settingsUrl = "$_baseUrl/api/v1/setting/do";
|
||||
static final settingsGeneralUrl = "$_baseUrl/api/v1/setting/general";
|
||||
//static final singleSettingUrl = "$_baseUrl/api/v1/setting/";
|
||||
static final watchlistTvUrl = "$_baseUrl/api/v1/media/tv/watchlist";
|
||||
static final watchlistMovieUrl = "$_baseUrl/api/v1/media/movie/watchlist";
|
||||
static final availableTorrentsUrl = "$_baseUrl/api/v1/media/torrents/";
|
||||
@@ -50,6 +55,9 @@ class APIs {
|
||||
|
||||
static final cronJobUrl = "$_baseUrl/api/v1/setting/cron/trigger";
|
||||
|
||||
static final tvParseUrl = "$_baseUrl/api/v1/setting/parse/tv";
|
||||
static final movieParseUrl = "$_baseUrl/api/v1/setting/parse/movie";
|
||||
|
||||
static const tmdbApiKey = "tmdb_api_key";
|
||||
static const downloadDirKey = "download_dir";
|
||||
|
||||
@@ -114,4 +122,50 @@ class APIs {
|
||||
throw sp.message;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<String>> downloadAllTv() async {
|
||||
var resp = await getDio().get(APIs.downloadAllTvUrl);
|
||||
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
}
|
||||
return sp.data==null? []:sp.data as List<String>;
|
||||
}
|
||||
|
||||
static Future<List<String>> downloadAllMovies() async {
|
||||
var resp = await getDio().get(APIs.downloadAllMovieUrl);
|
||||
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
}
|
||||
return sp.data==null? []:sp.data as List<String>;
|
||||
}
|
||||
|
||||
static Future<String> parseTvName(String s) async {
|
||||
var resp = await getDio().post(APIs.tvParseUrl, data: {"s": s});
|
||||
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
}
|
||||
JsonEncoder encoder = new JsonEncoder.withIndent(' ');
|
||||
return encoder.convert(sp.data);
|
||||
}
|
||||
|
||||
static Future<String> parseMovieName(String s) async {
|
||||
var resp = await getDio().post(APIs.movieParseUrl, data: {"s": s});
|
||||
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
}
|
||||
JsonEncoder encoder = new JsonEncoder.withIndent(' ');
|
||||
return encoder.convert(sp.data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,6 @@ class ActivityData
|
||||
extends AutoDisposeFamilyAsyncNotifier<List<Activity>, String> {
|
||||
@override
|
||||
FutureOr<List<Activity>> build(String arg) async {
|
||||
if (arg == "active") {
|
||||
//refresh active downloads
|
||||
Timer(const Duration(seconds: 5),
|
||||
ref.invalidateSelf); //Periodically Refresh
|
||||
}
|
||||
|
||||
final dio = await APIs.getDio();
|
||||
var resp =
|
||||
await dio.get(APIs.activityUrl, queryParameters: {"status": arg});
|
||||
@@ -44,6 +38,12 @@ class ActivityData
|
||||
for (final a in sp.data as List) {
|
||||
activities.add(Activity.fromJson(a));
|
||||
}
|
||||
|
||||
if (arg == "active") {
|
||||
//refresh active downloads
|
||||
Timer(const Duration(seconds: 5),
|
||||
() => ref.invalidateSelf()); //Periodically Refresh
|
||||
}
|
||||
return activities;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class Activity {
|
||||
required this.saved,
|
||||
required this.progress,
|
||||
required this.size,
|
||||
required this.seedRatio});
|
||||
required this.seedRatio, required this.uploadProgress});
|
||||
|
||||
final int? id;
|
||||
final int? mediaId;
|
||||
@@ -86,6 +86,7 @@ class Activity {
|
||||
final int? progress;
|
||||
final int? size;
|
||||
final double seedRatio;
|
||||
final double uploadProgress;
|
||||
|
||||
factory Activity.fromJson(Map<String, dynamic> json) {
|
||||
return Activity(
|
||||
@@ -99,6 +100,8 @@ class Activity {
|
||||
saved: json["saved"],
|
||||
progress: json["progress"],
|
||||
seedRatio: json["seed_ratio"],
|
||||
size: json["size"]);
|
||||
size: json["size"],
|
||||
uploadProgress: json["upload_progress"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class SeriesDetailData
|
||||
|
||||
Future<dynamic> downloadall() async {
|
||||
final dio = APIs.getDio();
|
||||
var resp = await dio.get(APIs.downloadAllUrl + id!);
|
||||
var resp = await dio.get(APIs.downloadAllEpisodesUrl + id!);
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
|
||||
@@ -32,7 +32,7 @@ var prowlarrSettingDataProvider =
|
||||
class EditSettingData extends AutoDisposeAsyncNotifier<GeneralSetting> {
|
||||
@override
|
||||
FutureOr<GeneralSetting> build() async {
|
||||
final dio = await APIs.getDio();
|
||||
final dio = APIs.getDio();
|
||||
|
||||
var resp = await dio.get(APIs.settingsGeneralUrl);
|
||||
var rrr = ServerResponse.fromJson(resp.data);
|
||||
@@ -509,14 +509,20 @@ class ImportListData extends AutoDisposeAsyncNotifier<List<ImportList>> {
|
||||
}
|
||||
|
||||
class ProwlarrSetting {
|
||||
final bool disabled;
|
||||
final String apiKey;
|
||||
final String url;
|
||||
ProwlarrSetting({required this.apiKey, required this.url});
|
||||
ProwlarrSetting(
|
||||
{required this.apiKey, required this.url, required this.disabled});
|
||||
factory ProwlarrSetting.fromJson(Map<String, dynamic> json) {
|
||||
return ProwlarrSetting(apiKey: json["api_key"], url: json["url"]);
|
||||
return ProwlarrSetting(
|
||||
apiKey: json["api_key"],
|
||||
url: json["url"],
|
||||
disabled: json["disabled"] ?? false);
|
||||
}
|
||||
|
||||
Map<String, dynamic> tojson() => {"api_key": apiKey, "url": url};
|
||||
Map<String, dynamic> tojson() =>
|
||||
{"api_key": apiKey, "url": url, "disabled": disabled};
|
||||
}
|
||||
|
||||
class ProwlarrSettingData extends AutoDisposeAsyncNotifier<ProwlarrSetting> {
|
||||
|
||||
@@ -115,7 +115,7 @@ class SearchPageData
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
}
|
||||
//ref.invalidate(tvWatchlistDataProvider);
|
||||
ref.invalidate(tvWatchlistDataProvider);
|
||||
} else {
|
||||
var resp = await dio.post(APIs.watchlistMovieUrl, data: {
|
||||
"tmdb_id": tmdbId,
|
||||
@@ -129,6 +129,7 @@ class SearchPageData
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
}
|
||||
ref.invalidate(movieWatchlistDataProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:ui/providers/APIs.dart';
|
||||
import 'package:ui/providers/welcome_data.dart';
|
||||
import 'package:ui/search_page/submit_dialog.dart';
|
||||
import 'package:ui/widgets/progress_indicator.dart';
|
||||
import 'package:ui/widgets/widgets.dart';
|
||||
|
||||
class SearchPage extends ConsumerStatefulWidget {
|
||||
const SearchPage({super.key, this.query});
|
||||
@@ -110,7 +111,7 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
||||
}
|
||||
return cards;
|
||||
},
|
||||
error: (err, trace) => [Text("$err")],
|
||||
error: (err, trace) => [PoError(msg: "网络错误,请确认TMDB Key正确配置,并且能够正常连接到TMDB网站", err: err)],
|
||||
loading: () => [const MyProgressIndicator()]);
|
||||
|
||||
var f = NotificationListener(
|
||||
|
||||
@@ -94,7 +94,7 @@ class _AuthState extends ConsumerState<AuthSettings> {
|
||||
],
|
||||
));
|
||||
},
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,17 +32,15 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
child: Text(client.name ?? ""));
|
||||
}
|
||||
return SettingsCard(
|
||||
onTap: () => showDownloadClientDetails(DownloadClient()),
|
||||
child: const Icon(Icons.add));
|
||||
onTap: () => showSelections(), child: const Icon(Icons.add));
|
||||
})),
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
}
|
||||
|
||||
Future<void> showDownloadClientDetails(DownloadClient client) {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
var _enableAuth = isNotBlank(client.user);
|
||||
String selectImpl = "transmission";
|
||||
|
||||
final body =
|
||||
StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
@@ -53,29 +51,12 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
"url": client.url,
|
||||
"user": client.user,
|
||||
"password": client.password,
|
||||
"impl": client.implementation,
|
||||
"remove_completed_downloads": client.removeCompletedDownloads,
|
||||
"remove_failed_downloads": client.removeFailedDownloads,
|
||||
"priority": client.priority.toString(),
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
FormBuilderDropdown<String>(
|
||||
name: "impl",
|
||||
decoration: const InputDecoration(labelText: "类型"),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectImpl = value!;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
value: "transmission", child: Text("Transmission")),
|
||||
DropdownMenuItem(
|
||||
value: "qbittorrent", child: Text("qBittorrent")),
|
||||
],
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
FormBuilderTextField(
|
||||
name: "name",
|
||||
decoration: const InputDecoration(labelText: "名称"),
|
||||
@@ -90,7 +71,8 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
),
|
||||
FormBuilderTextField(
|
||||
name: "priority",
|
||||
decoration: const InputDecoration(labelText: "优先级", helperText: "1-50, 1最高优先级,50最低优先级"),
|
||||
decoration: const InputDecoration(
|
||||
labelText: "优先级", helperText: "1-50, 1最高优先级,50最低优先级"),
|
||||
validator: FormBuilderValidators.integer(),
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction),
|
||||
FormBuilderSwitch(
|
||||
@@ -151,7 +133,7 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
return ref.read(dwonloadClientsProvider.notifier).addDownloadClients(
|
||||
DownloadClient(
|
||||
name: values["name"],
|
||||
implementation: values["impl"],
|
||||
implementation: client.implementation,
|
||||
url: values["url"],
|
||||
user: _enableAuth ? values["user"] : null,
|
||||
password: _enableAuth ? values["password"] : null,
|
||||
@@ -163,7 +145,58 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
}
|
||||
}
|
||||
|
||||
var title = "下载器";
|
||||
if (client.implementation == "transmission") {
|
||||
title = "Transmission";
|
||||
} else if (client.implementation == "qbittorrent") {
|
||||
title = "qBittorrent";
|
||||
}
|
||||
|
||||
return showSettingDialog(
|
||||
context, "下载器", client.id != null, body, onSubmit, onDelete);
|
||||
context, title, client.id != null, body, onSubmit, onDelete);
|
||||
}
|
||||
|
||||
Future<void> showSelections() {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content: SizedBox(
|
||||
height: 500,
|
||||
width: 500,
|
||||
child: Wrap(
|
||||
children: [
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("Transmission"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showDownloadClientDetails(DownloadClient(
|
||||
implementation: "transmission",
|
||||
name: "Transmission"));
|
||||
},
|
||||
),
|
||||
),
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("qBittorrent"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showDownloadClientDetails(DownloadClient(
|
||||
implementation: "qbittorrent",
|
||||
name: "qBittorrent"));
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ class _GeneralState extends ConsumerState<GeneralSettings> {
|
||||
),
|
||||
);
|
||||
},
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:ui/providers/settings.dart';
|
||||
import 'package:ui/settings/dialog.dart';
|
||||
import 'package:ui/widgets/progress_indicator.dart';
|
||||
import 'package:ui/widgets/widgets.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class Importlist extends ConsumerStatefulWidget {
|
||||
const Importlist({super.key});
|
||||
@@ -31,11 +32,11 @@ class _ImportlistState extends ConsumerState<Importlist> {
|
||||
child: Text(indexer.name ?? ""));
|
||||
}
|
||||
return SettingsCard(
|
||||
onTap: () => showImportlistDetails(ImportList()),
|
||||
onTap: () => showSelections(),
|
||||
child: const Icon(Icons.add));
|
||||
}),
|
||||
),
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
}
|
||||
|
||||
@@ -55,24 +56,16 @@ class _ImportlistState extends ConsumerState<Importlist> {
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
FormBuilderDropdown(
|
||||
name: "type",
|
||||
decoration: const InputDecoration(
|
||||
labelText: "类型",
|
||||
hintText:
|
||||
"Plex Watchlist: https://support.plex.tv/articles/universal-watchlist/"),
|
||||
items: const [
|
||||
DropdownMenuItem(value: "plex", child: Text("Plex Watchlist")),
|
||||
],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedType = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
_selectedType == "plex"
|
||||
? const Text(
|
||||
"Plex Watchlist: https://support.plex.tv/articles/universal-watchlist/")
|
||||
list.type == "plex"
|
||||
? Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: InkWell(
|
||||
onTap: () => launchUrl(Uri.parse(
|
||||
"https://support.plex.tv/articles/universal-watchlist/")),
|
||||
child: const Text(
|
||||
"https://support.plex.tv/articles/universal-watchlist/"),
|
||||
),
|
||||
)
|
||||
: const Text(""),
|
||||
FormBuilderTextField(
|
||||
name: "name",
|
||||
@@ -141,7 +134,42 @@ class _ImportlistState extends ConsumerState<Importlist> {
|
||||
}
|
||||
}
|
||||
|
||||
var title = "监控列表";
|
||||
if (list.type == "plex") {
|
||||
title = "Plex Watchlist";
|
||||
}
|
||||
|
||||
return showSettingDialog(
|
||||
context, "监控列表", list.id != null, body, onSubmit, onDelete);
|
||||
context, title, list.id != null, body, onSubmit, onDelete);
|
||||
}
|
||||
|
||||
Future<void> showSelections() {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content: SizedBox(
|
||||
height: 500,
|
||||
width: 500,
|
||||
child: Wrap(
|
||||
children: [
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("Plex Watchlist"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showImportlistDetails(
|
||||
ImportList(type: "plex", name: "PlexWatchlist1"));
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class _IndexerState extends ConsumerState<IndexerSettings> {
|
||||
child: const Icon(Icons.add));
|
||||
}),
|
||||
),
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class _NotifierState extends ConsumerState<NotifierSettings> {
|
||||
child: const Icon(Icons.add));
|
||||
}),
|
||||
),
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,11 @@ class ProwlarrSettingState extends ConsumerState<ProwlarrSettingPage> {
|
||||
data: (v) => FormBuilder(
|
||||
key: _formKey, //设置globalKey,用于后面获取FormState
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
initialValue: {"api_key": v.apiKey, "url": v.url},
|
||||
initialValue: {
|
||||
"api_key": v.apiKey,
|
||||
"url": v.url,
|
||||
"disabled": v.disabled
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
FormBuilderTextField(
|
||||
@@ -44,6 +48,12 @@ class ProwlarrSettingState extends ConsumerState<ProwlarrSettingPage> {
|
||||
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),
|
||||
@@ -55,18 +65,22 @@ class ProwlarrSettingState extends ConsumerState<ProwlarrSettingPage> {
|
||||
.read(prowlarrSettingDataProvider.notifier)
|
||||
.save(ProwlarrSetting(
|
||||
apiKey: values["api_key"],
|
||||
url: values["url"]))
|
||||
url: values["url"],
|
||||
disabled: values["disabled"]))
|
||||
.then((v) => showSnakeBar("更新成功"));
|
||||
showLoadingWithFuture(f);
|
||||
}
|
||||
},
|
||||
child: const Padding(padding: EdgeInsets.all(10), child: Text("保存"),)),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Text("保存"),
|
||||
)),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ class SystemSettingsPage extends ConsumerStatefulWidget {
|
||||
class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
return SelectionArea(
|
||||
child: ListView(
|
||||
children: [
|
||||
getExpansionTile("常规", const GeneralSettings()),
|
||||
getExpansionTile("索引器", const IndexerSettings()),
|
||||
@@ -33,7 +34,7 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
|
||||
getExpansionTile("监控列表", const Importlist()),
|
||||
getExpansionTile("认证", const AuthSettings())
|
||||
],
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
Widget getExpansionTile(String name, Widget body) {
|
||||
|
||||
@@ -31,18 +31,17 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
child: Text(storage.name ?? ""));
|
||||
}
|
||||
return SettingsCard(
|
||||
onTap: () => showStorageDetails(Storage()),
|
||||
onTap: () => showSelections(),
|
||||
child: const Icon(Icons.add));
|
||||
}),
|
||||
),
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
}
|
||||
|
||||
Future<void> showStorageDetails(Storage s) {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
|
||||
String selectImpl = s.implementation == null ? "local" : s.implementation!;
|
||||
final widgets =
|
||||
StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
return FormBuilder(
|
||||
@@ -50,7 +49,6 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
autovalidateMode: AutovalidateMode.disabled,
|
||||
initialValue: {
|
||||
"name": s.name,
|
||||
"impl": s.implementation == null ? "local" : s.implementation!,
|
||||
"user": s.settings != null ? s.settings!["user"] ?? "" : "",
|
||||
"password": s.settings != null ? s.settings!["password"] ?? "" : "",
|
||||
"tv_path": s.tvPath,
|
||||
@@ -65,27 +63,6 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
FormBuilderDropdown<String>(
|
||||
name: "impl",
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
decoration: const InputDecoration(labelText: "类型"),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectImpl = value!;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
value: "local",
|
||||
child: Text("本地存储"),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: "webdav",
|
||||
child: Text("webdav"),
|
||||
)
|
||||
],
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
FormBuilderTextField(
|
||||
name: "name",
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
@@ -93,15 +70,16 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
decoration: const InputDecoration(labelText: "名称"),
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
selectImpl != "local"
|
||||
s.implementation == "webdav" || s.implementation == "alist"
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
FormBuilderTextField(
|
||||
name: "url",
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
decoration:
|
||||
const InputDecoration(labelText: "Webdav地址"),
|
||||
decoration: const InputDecoration(
|
||||
labelText: "网址",
|
||||
hintText: "https://abc.somewebsite.com/"),
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
FormBuilderTextField(
|
||||
@@ -115,13 +93,15 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
decoration: const InputDecoration(labelText: "密码"),
|
||||
obscureText: true,
|
||||
),
|
||||
FormBuilderCheckbox(
|
||||
name: "change_file_hash",
|
||||
title: const Text(
|
||||
"上传时更改文件哈希",
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
s.implementation == "webdav"
|
||||
? FormBuilderCheckbox(
|
||||
name: "change_file_hash",
|
||||
title: const Text(
|
||||
"上传时更改文件哈希",
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
)
|
||||
: Container(),
|
||||
@@ -145,7 +125,7 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
final values = _formKey.currentState!.value;
|
||||
return ref.read(storageSettingProvider.notifier).addStorage(Storage(
|
||||
name: values["name"],
|
||||
implementation: selectImpl,
|
||||
implementation: s.implementation,
|
||||
tvPath: values["tv_path"],
|
||||
moviePath: values["movie_path"],
|
||||
settings: {
|
||||
@@ -167,7 +147,70 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
return ref.read(storageSettingProvider.notifier).deleteStorage(s.id!);
|
||||
}
|
||||
|
||||
var title = "存储";
|
||||
if (s.implementation == "local") {
|
||||
title = "本地存储";
|
||||
} else if (s.implementation == "webdav") {
|
||||
title = "webdav 存储";
|
||||
} else if (s.implementation == "alist") {
|
||||
title = "Alist 存储";
|
||||
}
|
||||
|
||||
return showSettingDialog(
|
||||
context, '存储', s.id != null, widgets, onSubmit, onDelete);
|
||||
context, title, s.id != null, widgets, onSubmit, onDelete);
|
||||
}
|
||||
|
||||
Future<void> showSelections() {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content: SizedBox(
|
||||
height: 500,
|
||||
width: 500,
|
||||
child: Wrap(
|
||||
children: [
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("本地存储"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showStorageDetails(
|
||||
Storage(implementation: "local", name: "本地存储1"));
|
||||
},
|
||||
),
|
||||
),
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("webdav"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showStorageDetails(
|
||||
Storage(implementation: "webdav", name: "webdav1"));
|
||||
},
|
||||
),
|
||||
),
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("Alist"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showStorageDetails(
|
||||
Storage(implementation: "alist", name: "Alist1"));
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ class _SystemPageState extends ConsumerState<SystemPage> {
|
||||
Widget build(BuildContext context) {
|
||||
final logs = ref.watch(logFileDataProvider);
|
||||
final about = ref.watch(aboutDataProvider);
|
||||
return SingleChildScrollView(
|
||||
return SelectionArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
ExpansionTile(
|
||||
@@ -55,7 +56,7 @@ class _SystemPageState extends ConsumerState<SystemPage> {
|
||||
]);
|
||||
}));
|
||||
},
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator())
|
||||
],
|
||||
),
|
||||
@@ -110,7 +111,7 @@ class _SystemPageState extends ConsumerState<SystemPage> {
|
||||
]),
|
||||
]);
|
||||
},
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator())
|
||||
],
|
||||
),
|
||||
@@ -184,12 +185,12 @@ class _SystemPageState extends ConsumerState<SystemPage> {
|
||||
],
|
||||
);
|
||||
},
|
||||
error: (err, trace) => Text("$err"),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator())
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,156 +34,157 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
|
||||
Widget build(BuildContext context) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
var seriesDetails = ref.watch(mediaDetailsProvider(widget.seriesId));
|
||||
return seriesDetails.when(
|
||||
data: (details) {
|
||||
Map<int, List<DataRow>> m = {};
|
||||
for (final ep in details.episodes!) {
|
||||
var row = DataRow(cells: [
|
||||
DataCell(Text("${ep.episodeNumber}")),
|
||||
DataCell(Text("${ep.title}")),
|
||||
DataCell(Opacity(
|
||||
opacity: 0.5,
|
||||
child: Text(ep.airDate ?? "-"),
|
||||
)),
|
||||
DataCell(
|
||||
Opacity(
|
||||
opacity: 0.7,
|
||||
child: ep.status == "downloading"
|
||||
? const IconButton(
|
||||
tooltip: "下载中",
|
||||
onPressed: null,
|
||||
icon: Icon(Icons.downloading))
|
||||
: (ep.status == "downloaded"
|
||||
return SelectionArea(
|
||||
child: seriesDetails.when(
|
||||
data: (details) {
|
||||
Map<int, List<DataRow>> m = {};
|
||||
for (final ep in details.episodes!) {
|
||||
var row = DataRow(cells: [
|
||||
DataCell(Text("${ep.episodeNumber}")),
|
||||
DataCell(Text("${ep.title}")),
|
||||
DataCell(Opacity(
|
||||
opacity: 0.5,
|
||||
child: Text(ep.airDate ?? "-"),
|
||||
)),
|
||||
DataCell(
|
||||
Opacity(
|
||||
opacity: 0.7,
|
||||
child: ep.status == "downloading"
|
||||
? const IconButton(
|
||||
tooltip: "已下载",
|
||||
tooltip: "下载中",
|
||||
onPressed: null,
|
||||
icon: Icon(Icons.download_done))
|
||||
: (ep.monitored == true
|
||||
? IconButton(
|
||||
tooltip: "监控中",
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(mediaDetailsProvider(
|
||||
widget.seriesId)
|
||||
.notifier)
|
||||
.changeMonitoringStatus(
|
||||
ep.id!, false);
|
||||
},
|
||||
icon: const Icon(Icons.alarm))
|
||||
: Opacity(
|
||||
opacity: 0.7,
|
||||
child: IconButton(
|
||||
tooltip: "未监控",
|
||||
icon: Icon(Icons.downloading))
|
||||
: (ep.status == "downloaded"
|
||||
? const IconButton(
|
||||
tooltip: "已下载",
|
||||
onPressed: null,
|
||||
icon: Icon(Icons.download_done))
|
||||
: (ep.monitored == true
|
||||
? IconButton(
|
||||
tooltip: "监控中",
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(mediaDetailsProvider(
|
||||
widget.seriesId)
|
||||
.notifier)
|
||||
.changeMonitoringStatus(
|
||||
ep.id!, true);
|
||||
ep.id!, false);
|
||||
},
|
||||
icon: const Icon(Icons.alarm_off)),
|
||||
)))),
|
||||
),
|
||||
DataCell(Row(
|
||||
children: [
|
||||
LoadingIconButton(
|
||||
tooltip: "搜索下载对应剧集",
|
||||
onPressed: () async {
|
||||
await ref
|
||||
.read(
|
||||
mediaDetailsProvider(widget.seriesId).notifier)
|
||||
.searchAndDownload(widget.seriesId,
|
||||
ep.seasonNumber!, ep.episodeNumber!)
|
||||
.then((v) => showSnakeBar("开始下载: $v"));
|
||||
},
|
||||
icon: Icons.download),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
icon: const Icon(Icons.alarm))
|
||||
: Opacity(
|
||||
opacity: 0.7,
|
||||
child: IconButton(
|
||||
tooltip: "未监控",
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(mediaDetailsProvider(
|
||||
widget.seriesId)
|
||||
.notifier)
|
||||
.changeMonitoringStatus(
|
||||
ep.id!, true);
|
||||
},
|
||||
icon: const Icon(Icons.alarm_off)),
|
||||
)))),
|
||||
),
|
||||
Tooltip(
|
||||
message: "查看可用资源",
|
||||
child: IconButton(
|
||||
onPressed: () => showAvailableTorrents(widget.seriesId,
|
||||
ep.seasonNumber ?? 0, ep.episodeNumber ?? 0),
|
||||
icon: const Icon(Icons.manage_search)),
|
||||
)
|
||||
],
|
||||
))
|
||||
]);
|
||||
|
||||
if (m[ep.seasonNumber] == null) {
|
||||
m[ep.seasonNumber!] = List.empty(growable: true);
|
||||
}
|
||||
m[ep.seasonNumber!]!.add(row);
|
||||
}
|
||||
List<ExpansionTile> list = List.empty(growable: true);
|
||||
for (final k in m.keys.toList().reversed) {
|
||||
final seasonEpisodes = DataTable(columns: [
|
||||
const DataColumn(label: Text("#")),
|
||||
const DataColumn(
|
||||
label: Text("标题"),
|
||||
),
|
||||
const DataColumn(label: Text("播出时间")),
|
||||
const DataColumn(label: Text("状态")),
|
||||
DataColumn(
|
||||
label: Row(
|
||||
children: [
|
||||
LoadingIconButton(
|
||||
tooltip: "搜索下载全部剧集",
|
||||
onPressed: () async {
|
||||
await ref
|
||||
.read(
|
||||
mediaDetailsProvider(widget.seriesId).notifier)
|
||||
.searchAndDownload(widget.seriesId, k, 0)
|
||||
.then((v) => showSnakeBar("开始下载: $v"));
|
||||
//showLoadingWithFuture(f);
|
||||
},
|
||||
icon: Icons.download),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Tooltip(
|
||||
message: "查看可用资源",
|
||||
child: IconButton(
|
||||
onPressed: () =>
|
||||
showAvailableTorrents(widget.seriesId, k, 0),
|
||||
icon: const Icon(Icons.manage_search)),
|
||||
)
|
||||
],
|
||||
))
|
||||
], rows: m[k]!);
|
||||
|
||||
var seasonList = ExpansionTile(
|
||||
tilePadding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
//childrenPadding: const EdgeInsets.fromLTRB(50, 0, 50, 0),
|
||||
initiallyExpanded: false,
|
||||
title: k == 0 ? const Text("特别篇") : Text("第 $k 季"),
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
screenWidth < 600
|
||||
? SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: seasonEpisodes,
|
||||
DataCell(Row(
|
||||
children: [
|
||||
LoadingIconButton(
|
||||
tooltip: "搜索下载对应剧集",
|
||||
onPressed: () async {
|
||||
await ref
|
||||
.read(mediaDetailsProvider(widget.seriesId)
|
||||
.notifier)
|
||||
.searchAndDownload(widget.seriesId,
|
||||
ep.seasonNumber!, ep.episodeNumber!)
|
||||
.then((v) => showSnakeBar("开始下载: $v"));
|
||||
},
|
||||
icon: Icons.download),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Tooltip(
|
||||
message: "查看可用资源",
|
||||
child: IconButton(
|
||||
onPressed: () => showAvailableTorrents(
|
||||
widget.seriesId,
|
||||
ep.seasonNumber ?? 0,
|
||||
ep.episodeNumber ?? 0),
|
||||
icon: const Icon(Icons.manage_search)),
|
||||
)
|
||||
: seasonEpisodes
|
||||
],
|
||||
);
|
||||
list.add(seasonList);
|
||||
}
|
||||
return ListView(
|
||||
children: [
|
||||
DetailCard(details: details),
|
||||
Column(
|
||||
children: list,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
error: (err, trace) {
|
||||
return Text("$err");
|
||||
},
|
||||
loading: () => const MyProgressIndicator());
|
||||
],
|
||||
))
|
||||
]);
|
||||
|
||||
if (m[ep.seasonNumber] == null) {
|
||||
m[ep.seasonNumber!] = List.empty(growable: true);
|
||||
}
|
||||
m[ep.seasonNumber!]!.add(row);
|
||||
}
|
||||
List<ExpansionTile> list = List.empty(growable: true);
|
||||
for (final k in m.keys.toList().reversed) {
|
||||
final seasonEpisodes = DataTable(columns: [
|
||||
const DataColumn(label: Text("#")),
|
||||
const DataColumn(
|
||||
label: Text("标题"),
|
||||
),
|
||||
const DataColumn(label: Text("播出时间")),
|
||||
const DataColumn(label: Text("状态")),
|
||||
DataColumn(
|
||||
label: Row(
|
||||
children: [
|
||||
LoadingIconButton(
|
||||
tooltip: "搜索下载全部剧集",
|
||||
onPressed: () async {
|
||||
await ref
|
||||
.read(mediaDetailsProvider(widget.seriesId)
|
||||
.notifier)
|
||||
.searchAndDownload(widget.seriesId, k, 0)
|
||||
.then((v) => showSnakeBar("开始下载: $v"));
|
||||
//showLoadingWithFuture(f);
|
||||
},
|
||||
icon: Icons.download),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Tooltip(
|
||||
message: "查看可用资源",
|
||||
child: IconButton(
|
||||
onPressed: () =>
|
||||
showAvailableTorrents(widget.seriesId, k, 0),
|
||||
icon: const Icon(Icons.manage_search)),
|
||||
)
|
||||
],
|
||||
))
|
||||
], rows: m[k]!);
|
||||
|
||||
var seasonList = ExpansionTile(
|
||||
tilePadding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
//childrenPadding: const EdgeInsets.fromLTRB(50, 0, 50, 0),
|
||||
initiallyExpanded: false,
|
||||
title: k == 0 ? const Text("特别篇") : Text("第 $k 季"),
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
screenWidth < 600
|
||||
? SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: seasonEpisodes,
|
||||
)
|
||||
: seasonEpisodes
|
||||
],
|
||||
);
|
||||
list.add(seasonList);
|
||||
}
|
||||
return ListView(
|
||||
children: [
|
||||
DetailCard(details: details),
|
||||
Column(
|
||||
children: list,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator()));
|
||||
}
|
||||
|
||||
Future<void> showAvailableTorrents(String id, int season, int episode) {
|
||||
|
||||
@@ -1,59 +1,244 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ui/movie_watchlist.dart';
|
||||
import 'package:ui/providers/APIs.dart';
|
||||
import 'package:ui/providers/welcome_data.dart';
|
||||
import 'package:ui/tv_details.dart';
|
||||
import 'package:ui/widgets/progress_indicator.dart';
|
||||
import 'package:ui/widgets/utils.dart';
|
||||
import 'package:ui/widgets/widgets.dart';
|
||||
|
||||
class WelcomePage extends ConsumerWidget {
|
||||
class WelcomePage extends ConsumerStatefulWidget {
|
||||
const WelcomePage({super.key});
|
||||
static const routeTv = "/series";
|
||||
static const routeMoivie = "/movies";
|
||||
|
||||
const WelcomePage({super.key});
|
||||
@override
|
||||
ConsumerState<ConsumerStatefulWidget> createState() {
|
||||
return WelcomePageState();
|
||||
}
|
||||
}
|
||||
|
||||
class WelcomePageState extends ConsumerState<WelcomePage> {
|
||||
//WelcomePageState({super.key});
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
bool onlyShowUnfinished = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
Widget build(BuildContext context) {
|
||||
var uri = GoRouterState.of(context).uri.toString();
|
||||
|
||||
AsyncValue<List<MediaDetail>> data;
|
||||
if (uri == routeMoivie) {
|
||||
if (uri == WelcomePage.routeMoivie) {
|
||||
data = ref.watch(movieWatchlistDataProvider);
|
||||
} else {
|
||||
data = ref.watch(tvWatchlistDataProvider);
|
||||
}
|
||||
|
||||
return switch (data) {
|
||||
AsyncData(:final value) => SingleChildScrollView(
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.start,
|
||||
spacing: isSmallScreen(context) ? 0 : 10,
|
||||
runSpacing: isSmallScreen(context) ? 10 : 20,
|
||||
children: value.isEmpty
|
||||
? [
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
"啥都没有...",
|
||||
style: TextStyle(fontSize: 16),
|
||||
))
|
||||
]
|
||||
: List.generate(value.length, (i) {
|
||||
final item = value[i];
|
||||
return MediaCard(item: item);
|
||||
}),
|
||||
),
|
||||
),
|
||||
_ => const MyProgressIndicator(),
|
||||
};
|
||||
return SelectionArea(
|
||||
child: Stack(
|
||||
//alignment: Alignment.bottomRight,
|
||||
children: [
|
||||
() {
|
||||
return data.when(
|
||||
data: (value) => SingleChildScrollView(
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.start,
|
||||
spacing: isSmallScreen(context) ? 0 : 10,
|
||||
runSpacing: isSmallScreen(context) ? 10 : 20,
|
||||
children: getMediaAll(value),
|
||||
),
|
||||
),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
}(),
|
||||
getMoreButtonAndActions(uri)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getMoreButtonAndActions(String uri) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: Container()),
|
||||
Column(
|
||||
children: [
|
||||
Expanded(child: Container()),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: MenuAnchor(
|
||||
style: MenuStyle(
|
||||
alignment: Alignment.topLeft,
|
||||
backgroundColor: WidgetStatePropertyAll(Theme.of(context)
|
||||
.colorScheme
|
||||
.inversePrimary
|
||||
.withOpacity(0.7)),
|
||||
),
|
||||
menuChildren: [parseName(), onlyUnfinished(), refreshAll(uri)],
|
||||
builder: (context, controller, child) {
|
||||
return Opacity(
|
||||
opacity: 0.7,
|
||||
child: FloatingActionButton(
|
||||
onPressed: () {
|
||||
if (controller.isOpen) {
|
||||
controller.close();
|
||||
} else {
|
||||
controller.open();
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.more_horiz),
|
||||
));
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget onlyUnfinished() {
|
||||
return CheckboxListTile(
|
||||
value: onlyShowUnfinished,
|
||||
onChanged: (b) {
|
||||
setState(() {
|
||||
onlyShowUnfinished = b!;
|
||||
});
|
||||
},
|
||||
title: const Text(
|
||||
"未完成",
|
||||
style: TextStyle(fontSize: 16),
|
||||
softWrap: false,
|
||||
),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
);
|
||||
}
|
||||
|
||||
Widget refreshAll(String uri) {
|
||||
return LoadingListTile(
|
||||
icon: Icons.refresh,
|
||||
text: "全部更新",
|
||||
onPressed: () async {
|
||||
if (uri == WelcomePage.routeMoivie) {
|
||||
await APIs.downloadAllMovies().then((v) {
|
||||
if (v.isNotEmpty) {
|
||||
showSnakeBar("开始下载电影:$v");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await APIs.downloadAllTv().then((v) {
|
||||
if (v.isNotEmpty) {
|
||||
showSnakeBar("开始下载剧集:$v");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget parseName() {
|
||||
return ListTile(
|
||||
leading: Icon(Icons.calculate),
|
||||
title: Text("测试解析"),
|
||||
onTap: () => _showNameParsingDialog(),
|
||||
);
|
||||
}
|
||||
|
||||
bool isSmallScreen(BuildContext context) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
return screenWidth < 600;
|
||||
}
|
||||
|
||||
List<Widget> getMediaAll(List<MediaDetail> list) {
|
||||
if (list.isEmpty) {
|
||||
return [
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
"啥都没有...",
|
||||
style: TextStyle(fontSize: 16),
|
||||
))
|
||||
];
|
||||
}
|
||||
if (onlyShowUnfinished) {
|
||||
list = list.where((v) => v.downloadedNum != v.monitoredNum).toList();
|
||||
}
|
||||
return List.generate(list.length, (i) {
|
||||
final item = list[i];
|
||||
return MediaCard(item: item);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _showNameParsingDialog() async {
|
||||
final resultController = TextEditingController();
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('测试名称解析'),
|
||||
content: SizedBox(
|
||||
width: 500,
|
||||
height: 400,
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
initialValue: {"name": "", "type": "tv"},
|
||||
child: Column(
|
||||
children: [
|
||||
FormBuilderTextField(
|
||||
name: "name",
|
||||
decoration: InputDecoration(labelText: "要解析的名字"),
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
FormBuilderDropdown(
|
||||
name: "type",
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: "tv",
|
||||
child: const Text("电视剧"),
|
||||
),
|
||||
DropdownMenuItem(value: "movie", child: const Text("电影"))
|
||||
],
|
||||
),
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: LoadingTextButton(
|
||||
onPressed: () async {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
final values = _formKey.currentState!.value;
|
||||
//print(values);
|
||||
if (values["type"] == "tv") {
|
||||
var s = await APIs.parseTvName(values["name"]);
|
||||
resultController.text = s;
|
||||
} else {
|
||||
var s =
|
||||
await APIs.parseMovieName(values["name"]);
|
||||
resultController.text = s;
|
||||
}
|
||||
}
|
||||
return;
|
||||
},
|
||||
label: Text("解析")),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
maxLines: 8,
|
||||
controller: resultController,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MediaCard extends StatelessWidget {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:ui/providers/APIs.dart';
|
||||
import 'dart:io' show Platform;
|
||||
@@ -60,5 +61,5 @@ bool isDesktop() {
|
||||
|
||||
bool isSmallScreen(BuildContext context) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
return screenWidth < 600;
|
||||
return screenWidth < Breakpoints.small.endWidth!.toDouble();
|
||||
}
|
||||
|
||||
@@ -141,8 +141,58 @@ class _MySliderState extends State<MyRangeSlider> {
|
||||
}
|
||||
}
|
||||
|
||||
class LoadingListTile extends StatefulWidget {
|
||||
const LoadingListTile(
|
||||
{super.key,
|
||||
required this.onPressed,
|
||||
required this.icon,
|
||||
required this.text});
|
||||
final Future<void> Function() onPressed;
|
||||
final IconData icon;
|
||||
final String text;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return LoadingListTileState();
|
||||
}
|
||||
}
|
||||
|
||||
class LoadingListTileState extends State<LoadingListTile> {
|
||||
bool loading = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
onTap: loading
|
||||
? null
|
||||
: () async {
|
||||
setState(() => loading = true);
|
||||
try {
|
||||
await widget.onPressed();
|
||||
} catch (e) {
|
||||
showSnakeBar("操作失败:$e");
|
||||
} finally {
|
||||
setState(() => loading = false);
|
||||
}
|
||||
},
|
||||
title: Text(widget.text),
|
||||
leading: loading
|
||||
? Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: const CircularProgressIndicator(
|
||||
color: Colors.grey,
|
||||
strokeWidth: 3,
|
||||
),
|
||||
)
|
||||
: Icon(widget.icon));
|
||||
}
|
||||
}
|
||||
|
||||
class LoadingIconButton extends StatefulWidget {
|
||||
const LoadingIconButton({super.key, required this.onPressed, required this.icon, this.tooltip});
|
||||
const LoadingIconButton(
|
||||
{super.key, required this.onPressed, required this.icon, this.tooltip});
|
||||
final Future<void> Function() onPressed;
|
||||
final IconData icon;
|
||||
final String? tooltip;
|
||||
@@ -159,7 +209,7 @@ class _LoadingIconButtonState extends State<LoadingIconButton> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
tooltip: widget.tooltip,
|
||||
tooltip: widget.tooltip,
|
||||
onPressed: loading
|
||||
? null
|
||||
: () async {
|
||||
@@ -187,7 +237,8 @@ class _LoadingIconButtonState extends State<LoadingIconButton> {
|
||||
}
|
||||
|
||||
class LoadingTextButton extends StatefulWidget {
|
||||
const LoadingTextButton({super.key, required this.onPressed, required this.label});
|
||||
const LoadingTextButton(
|
||||
{super.key, required this.onPressed, required this.label});
|
||||
final Future<void> Function() onPressed;
|
||||
final Widget label;
|
||||
|
||||
@@ -230,3 +281,32 @@ class _LoadingTextButtonState extends State<LoadingTextButton> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PoError extends StatelessWidget {
|
||||
const PoError({super.key, required this.msg, required this.err});
|
||||
final String msg;
|
||||
final dynamic err;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("$msg ", style: TextStyle(color:Theme.of(context).colorScheme.error),),
|
||||
Tooltip(
|
||||
message: "$err",
|
||||
child: Icon(Icons.info,color: Theme.of(context).colorScheme.error,),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PoNetworkError extends StatelessWidget {
|
||||
const PoNetworkError({super.key, required this.err});
|
||||
final dynamic err;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PoError(msg: "网络错误,请检查网络链接", err: err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,10 +143,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_riverpod
|
||||
sha256: "6eda4e247774474c715a0805a2fb8e3cd55fbae4ead641e063c95b4bd5f3b317"
|
||||
sha256: "9532ee6db4a943a1ed8383072a2e3eeda041db5657cdf6d2acecf3c21ecbe7e1"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.6.0"
|
||||
version: "2.6.1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@@ -161,10 +161,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: font_awesome_flutter
|
||||
sha256: "275ff26905134bcb59417cf60ad979136f1f8257f2f449914b2c3e05bbb4cd6f"
|
||||
sha256: d3a89184101baec7f4600d58840a764d2ef760fe1c5a20ef9e6b0e9b24a07a3a
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "10.7.0"
|
||||
version: "10.8.0"
|
||||
form_builder_validators:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -177,10 +177,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
sha256: "6f1b756f6e863259a99135ff3c95026c3cdca17d10ebef2bba2261a25ddc8bbc"
|
||||
sha256: "8ae664a70174163b9f65ea68dd8673e29db8f9095de7b5cd00e167c621f4fef5"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "14.3.0"
|
||||
version: "14.6.0"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -353,10 +353,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: riverpod
|
||||
sha256: bd6e656a764e3d27f211975626e0c4f9b8d06ab16acf3c7ba7a8061e09744c75
|
||||
sha256: "59062512288d3056b2321804332a13ffdd1bf16df70dcc8e506e411280a72959"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.6.0"
|
||||
version: "2.6.1"
|
||||
sign_in_button:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -470,10 +470,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: "8fc3bae0b68c02c47c5c86fa8bfa74471d42687b0eded01b78de87872db745e2"
|
||||
sha256: "6fc2f56536ee873eeb867ad176ae15f304ccccc357848b351f6f0d8d4a40d193"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "6.3.12"
|
||||
version: "6.3.14"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -486,10 +486,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
sha256: e2b9622b4007f97f504cd64c0128309dfb978ae66adbe944125ed9e1750f06af
|
||||
sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
version: "3.2.1"
|
||||
url_launcher_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -30,21 +30,21 @@ environment:
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
dio: ^5.4.3+1
|
||||
dio: ^5.7.0
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.6
|
||||
go_router: ^14.2.0
|
||||
flutter_riverpod: ^2.5.1
|
||||
quiver: ^3.2.1
|
||||
cupertino_icons: ^1.0.8
|
||||
go_router: ^14.3.0
|
||||
flutter_riverpod: ^2.6.1
|
||||
quiver: ^3.2.2
|
||||
flutter_login: ^5.0.0
|
||||
intl: ^0.19.0
|
||||
flutter_adaptive_scaffold: ^0.3.1
|
||||
flutter_form_builder: ^9.3.0
|
||||
flutter_form_builder: ^9.5.0
|
||||
form_builder_validators: ^11.0.0
|
||||
url_launcher: ^6.3.0
|
||||
url_launcher: ^6.3.1
|
||||
timeago: ^3.7.0
|
||||
table_calendar: ^3.1.2
|
||||
|
||||
@@ -71,7 +71,8 @@ flutter:
|
||||
uses-material-design: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
assets:
|
||||
- assets/
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
|
||||
Reference in New Issue
Block a user