Compare commits

...

628 Commits
v0.2.0 ... main

Author SHA1 Message Date
Simon Ding
72ec84e236 add fallback font 2025-12-28 16:11:44 +08:00
Simon Ding
30e8d4f024 feat: update dep and switch to web wasm build 2025-11-15 15:09:50 +08:00
Simon Ding
4341e31251 fix download stats 2025-11-13 00:05:41 +08:00
Simon Ding
53dda90c0f reduce arch support 2025-11-12 23:53:12 +08:00
Simon Ding
12c3b0c69b add log 2025-11-12 17:10:58 +08:00
Simon Ding
4825cda458 batch delete 2025-11-12 17:08:33 +08:00
Simon Ding
6a12c380f1 housekeeping run at 2:00am 2025-11-12 15:01:38 +08:00
Simon Ding
d8944168d2 add log 2025-11-12 14:53:36 +08:00
Simon Ding
0a48657999 add log 2025-11-12 14:09:33 +08:00
Simon Ding
717b098d2f feat: run housekeeping once at start 2025-11-12 14:01:56 +08:00
Simon Ding
1f6b704405 add db housekeeping 2025-11-12 14:00:38 +08:00
Simon Ding
e2ec07aaa2 Merge branch 'main' of github.com:simon-ding/polaris 2025-11-12 13:43:08 +08:00
Simon Ding
3aa72cd6f8 feat: cache downloaded status data every 10min 2025-11-12 13:42:51 +08:00
Simon
8041a8fbf5 Merge pull request #49 from simon-ding/dependabot/go_modules/github.com/spf13/viper-1.21.0
chore(deps): bump github.com/spf13/viper from 1.20.1 to 1.21.0
2025-09-26 19:39:02 +08:00
Simon
13508ce5ad Merge pull request #53 from simon-ding/dependabot/go_modules/golang.org/x/crypto-0.42.0
chore(deps): bump golang.org/x/crypto from 0.41.0 to 0.42.0
2025-09-26 19:38:49 +08:00
dependabot[bot]
63da23405b chore(deps): bump golang.org/x/crypto from 0.41.0 to 0.42.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.41.0 to 0.42.0.
- [Commits](https://github.com/golang/crypto/compare/v0.41.0...v0.42.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.42.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-15 13:37:18 +00:00
dependabot[bot]
59be2a809a chore(deps): bump github.com/spf13/viper from 1.20.1 to 1.21.0
Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.20.1 to 1.21.0.
- [Release notes](https://github.com/spf13/viper/releases)
- [Commits](https://github.com/spf13/viper/compare/v1.20.1...v1.21.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/viper
  dependency-version: 1.21.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-15 12:57:20 +00:00
Simon
3a9b81e4b0 Merge pull request #51 from simon-ding/dependabot/go_modules/golift.io/starr-1.2.0
chore(deps): bump golift.io/starr from 1.1.0 to 1.2.0
2025-09-15 20:56:42 +08:00
Simon
90544f27f4 Merge pull request #48 from simon-ding/dependabot/go_modules/github.com/cyruzin/golang-tmdb-1.8.2
chore(deps): bump github.com/cyruzin/golang-tmdb from 1.8.1 to 1.8.2
2025-09-15 20:56:23 +08:00
Simon
2f9328dea3 Merge pull request #50 from simon-ding/dependabot/go_modules/entgo.io/ent-0.14.5
chore(deps): bump entgo.io/ent from 0.14.4 to 0.14.5
2025-09-15 20:56:11 +08:00
Simon
1a07306078 Merge pull request #47 from simon-ding/dependabot/go_modules/golang.org/x/net-0.44.0
chore(deps): bump golang.org/x/net from 0.43.0 to 0.44.0
2025-09-15 20:21:23 +08:00
Simon Ding
340c1cdc57 feat: add to blacklist if torrent has no video file 2025-09-15 20:17:40 +08:00
dependabot[bot]
08d22aa89c chore(deps): bump golift.io/starr from 1.1.0 to 1.2.0
Bumps [golift.io/starr](https://github.com/golift/starr) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/golift/starr/releases)
- [Commits](https://github.com/golift/starr/compare/v1.1.0...v1.2.0)

---
updated-dependencies:
- dependency-name: golift.io/starr
  dependency-version: 1.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-15 11:35:59 +00:00
dependabot[bot]
5b987484ce chore(deps): bump entgo.io/ent from 0.14.4 to 0.14.5
Bumps [entgo.io/ent](https://github.com/ent/ent) from 0.14.4 to 0.14.5.
- [Release notes](https://github.com/ent/ent/releases)
- [Commits](https://github.com/ent/ent/compare/v0.14.4...v0.14.5)

---
updated-dependencies:
- dependency-name: entgo.io/ent
  dependency-version: 0.14.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-15 11:30:10 +00:00
dependabot[bot]
f93f36cf0a chore(deps): bump github.com/cyruzin/golang-tmdb from 1.8.1 to 1.8.2
Bumps [github.com/cyruzin/golang-tmdb](https://github.com/cyruzin/golang-tmdb) from 1.8.1 to 1.8.2.
- [Release notes](https://github.com/cyruzin/golang-tmdb/releases)
- [Changelog](https://github.com/cyruzin/golang-tmdb/blob/master/changes.go)
- [Commits](https://github.com/cyruzin/golang-tmdb/compare/v1.8.1...v1.8.2)

---
updated-dependencies:
- dependency-name: github.com/cyruzin/golang-tmdb
  dependency-version: 1.8.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-15 11:07:18 +00:00
dependabot[bot]
5f807fe5eb chore(deps): bump golang.org/x/net from 0.43.0 to 0.44.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.43.0 to 0.44.0.
- [Commits](https://github.com/golang/net/compare/v0.43.0...v0.44.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.44.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-15 11:05:15 +00:00
Simon Ding
468b1c79a3 feat: add dummy housekeeping tasks 2025-09-14 15:41:22 +08:00
Simon Ding
f0c89c6da0 fix: web static files serve 2025-09-14 10:57:16 +08:00
Simon
eeee5eb5e6 Merge pull request #42 from simon-ding/dependabot/go_modules/github.com/stretchr/testify-1.11.1
chore(deps): bump github.com/stretchr/testify from 1.10.0 to 1.11.1
2025-09-13 12:25:32 +08:00
Simon
2ce44ef86f Merge pull request #43 from simon-ding/dependabot/go_modules/github.com/gin-contrib/static-1.1.5
chore(deps): bump github.com/gin-contrib/static from 1.1.2 to 1.1.5
2025-09-13 12:25:18 +08:00
Simon
040dfe12a7 Merge pull request #45 from simon-ding/dependabot/go_modules/golang.org/x/sys-0.36.0
chore(deps): bump golang.org/x/sys from 0.35.0 to 0.36.0
2025-09-13 12:25:06 +08:00
Simon
d0409e1aa7 Merge pull request #46 from simon-ding/dependabot/go_modules/github.com/golang-jwt/jwt/v5-5.3.0
chore(deps): bump github.com/golang-jwt/jwt/v5 from 5.2.2 to 5.3.0
2025-09-13 12:24:54 +08:00
Simon
603dc06e57 Merge pull request #44 from simon-ding/dependabot/go_modules/golang.org/x/net-0.43.0
chore(deps): bump golang.org/x/net from 0.42.0 to 0.43.0
2025-09-13 12:24:41 +08:00
Simon Ding
6a5cf9c484 fix: will restore episode status after download fail 2025-09-12 21:28:17 +08:00
dependabot[bot]
9e647b7c44 chore(deps): bump github.com/golang-jwt/jwt/v5 from 5.2.2 to 5.3.0
Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.2.2 to 5.3.0.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v5.2.2...v5.3.0)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v5
  dependency-version: 5.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 10:54:02 +00:00
dependabot[bot]
3b1e358d8d chore(deps): bump golang.org/x/sys from 0.35.0 to 0.36.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.35.0 to 0.36.0.
- [Commits](https://github.com/golang/sys/compare/v0.35.0...v0.36.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 10:53:51 +00:00
dependabot[bot]
1fc160bafa chore(deps): bump golang.org/x/net from 0.42.0 to 0.43.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.42.0 to 0.43.0.
- [Commits](https://github.com/golang/net/compare/v0.42.0...v0.43.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.43.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 10:53:23 +00:00
dependabot[bot]
a770bc1efd chore(deps): bump github.com/gin-contrib/static from 1.1.2 to 1.1.5
Bumps [github.com/gin-contrib/static](https://github.com/gin-contrib/static) from 1.1.2 to 1.1.5.
- [Release notes](https://github.com/gin-contrib/static/releases)
- [Changelog](https://github.com/gin-contrib/static/blob/master/.goreleaser.yaml)
- [Commits](https://github.com/gin-contrib/static/compare/v1.1.2...v1.1.5)

---
updated-dependencies:
- dependency-name: github.com/gin-contrib/static
  dependency-version: 1.1.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 10:52:34 +00:00
dependabot[bot]
0960a57e7d chore(deps): bump github.com/stretchr/testify from 1.10.0 to 1.11.1
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.10.0 to 1.11.1.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.10.0...v1.11.1)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-version: 1.11.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 10:50:38 +00:00
Simon Ding
3519715212 chores(deps): update go_router 2025-09-02 15:52:51 +08:00
Simon Ding
44158b3df0 build using makefile 2025-09-02 15:33:17 +08:00
Simon Ding
bfd97c62d4 update flutter deps 2025-09-02 15:33:05 +08:00
Simon Ding
c6254783b1 chore: add doc 2025-09-01 15:31:00 +08:00
Simon Ding
c9f2cbd01e feat: change underline sqlite driver 2025-09-01 15:28:30 +08:00
Simon Ding
8db1fb4d40 update goreleaser profile 2025-09-01 14:35:17 +08:00
Simon Ding
f538cfc29d add arm v7 2025-09-01 14:27:06 +08:00
Simon Ding
5294ffce71 fix goreleaser version passing 2025-09-01 09:52:25 +08:00
Simon Ding
a331a5b41f fix goreleaser 2025-09-01 01:46:58 +08:00
Simon Ding
ea41fb2e95 fix go mod 2025-09-01 00:37:10 +08:00
Simon Ding
fc5b4f1ce7 fix 2025-09-01 00:19:19 +08:00
Simon Ding
dea4ecb9d4 feat: goreleaser proper handle ldflags 2025-09-01 00:12:35 +08:00
Simon Ding
d15f04e69c feat: handle polaris files on non docker env 2025-08-31 23:55:36 +08:00
Simon Ding
3967e7b77d update 2025-08-31 23:45:00 +08:00
Simon Ding
05d114be66 feat: seprate os and docker default download dir 2025-08-31 23:25:33 +08:00
Simon Ding
94b4db3310 fix: goreleaser 2025-08-31 23:11:19 +08:00
Simon Ding
e5261e7aac restart always 2025-08-31 22:58:43 +08:00
Simon Ding
2778df89c6 port 8080 -> 3322 2025-08-31 22:51:00 +08:00
Simon Ding
a978ae4fba update docker related files 2025-08-31 22:47:38 +08:00
Simon Ding
e27b327f93 chores: update deps 2025-08-31 22:13:24 +08:00
Simon Ding
96e6576f09 Merge branch 'main' of github.com:simon-ding/polaris 2025-08-30 14:47:16 +08:00
Simon Ding
1ddba4ddce feat: add port flag 2025-08-30 14:46:42 +08:00
Simon
8ea5715ce4 Merge pull request #33 from simon-ding/dependabot/go_modules/github.com/gabriel-vasile/mimetype-1.4.9
chore(deps): bump github.com/gabriel-vasile/mimetype from 1.4.4 to 1.4.9
2025-08-27 19:44:43 +08:00
Simon
03454543a3 Merge pull request #41 from simon-ding/dependabot/go_modules/go_modules-e1b2e84e8b
chore(deps): bump github.com/go-viper/mapstructure/v2 from 2.2.1 to 2.4.0 in the go_modules group
2025-08-27 16:48:20 +08:00
dependabot[bot]
8fdfbbd177 chore(deps): bump github.com/gabriel-vasile/mimetype from 1.4.4 to 1.4.9
Bumps [github.com/gabriel-vasile/mimetype](https://github.com/gabriel-vasile/mimetype) from 1.4.4 to 1.4.9.
- [Release notes](https://github.com/gabriel-vasile/mimetype/releases)
- [Commits](https://github.com/gabriel-vasile/mimetype/compare/v1.4.4...v1.4.9)

---
updated-dependencies:
- dependency-name: github.com/gabriel-vasile/mimetype
  dependency-version: 1.4.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-27 04:29:53 +00:00
dependabot[bot]
a169085504 chore(deps): bump github.com/go-viper/mapstructure/v2
Bumps the go_modules group with 1 update: [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure).


Updates `github.com/go-viper/mapstructure/v2` from 2.2.1 to 2.4.0
- [Release notes](https://github.com/go-viper/mapstructure/releases)
- [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.4.0)

---
updated-dependencies:
- dependency-name: github.com/go-viper/mapstructure/v2
  dependency-version: 2.4.0
  dependency-type: indirect
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-26 20:56:06 +00:00
Simon
60161f5c64 Merge pull request #29 from simon-ding/dependabot/go_modules/github.com/PuerkitoBio/goquery-1.10.3
chore(deps): bump github.com/PuerkitoBio/goquery from 1.10.1 to 1.10.3
2025-08-26 11:06:38 +08:00
Simon
90e90cf288 Merge pull request #32 from simon-ding/dependabot/go_modules/github.com/spf13/viper-1.20.1
chore(deps): bump github.com/spf13/viper from 1.19.0 to 1.20.1
2025-08-26 11:06:26 +08:00
dependabot[bot]
c38c6dcf74 chore(deps): bump github.com/spf13/viper from 1.19.0 to 1.20.1
Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.19.0 to 1.20.1.
- [Release notes](https://github.com/spf13/viper/releases)
- [Commits](https://github.com/spf13/viper/compare/v1.19.0...v1.20.1)

---
updated-dependencies:
- dependency-name: github.com/spf13/viper
  dependency-version: 1.20.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-26 02:55:18 +00:00
dependabot[bot]
8b96e30115 chore(deps): bump github.com/PuerkitoBio/goquery from 1.10.1 to 1.10.3
Bumps [github.com/PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery) from 1.10.1 to 1.10.3.
- [Release notes](https://github.com/PuerkitoBio/goquery/releases)
- [Commits](https://github.com/PuerkitoBio/goquery/compare/v1.10.1...v1.10.3)

---
updated-dependencies:
- dependency-name: github.com/PuerkitoBio/goquery
  dependency-version: 1.10.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-26 02:55:15 +00:00
Simon
0ae36d9c88 Merge pull request #39 from simon-ding/dependabot/go_modules/github.com/openai/openai-go-1.12.0
chore(deps): bump github.com/openai/openai-go from 1.6.0 to 1.12.0
2025-08-26 10:41:54 +08:00
Simon
f24d6870de Merge pull request #40 from simon-ding/dependabot/go_modules/github.com/ncruces/go-sqlite3-0.28.0
chore(deps): bump github.com/ncruces/go-sqlite3 from 0.26.1 to 0.28.0
2025-08-26 10:41:33 +08:00
Simon Ding
d265f17712 feat: buildin tmdb dns 2025-08-26 10:19:59 +08:00
dependabot[bot]
f6f9bb5e37 chore(deps): bump github.com/ncruces/go-sqlite3 from 0.26.1 to 0.28.0
Bumps [github.com/ncruces/go-sqlite3](https://github.com/ncruces/go-sqlite3) from 0.26.1 to 0.28.0.
- [Release notes](https://github.com/ncruces/go-sqlite3/releases)
- [Commits](https://github.com/ncruces/go-sqlite3/compare/v0.26.1...v0.28.0)

---
updated-dependencies:
- dependency-name: github.com/ncruces/go-sqlite3
  dependency-version: 0.28.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-25 19:37:38 +00:00
dependabot[bot]
6f3da87bbc chore(deps): bump github.com/openai/openai-go from 1.6.0 to 1.12.0
Bumps [github.com/openai/openai-go](https://github.com/openai/openai-go) from 1.6.0 to 1.12.0.
- [Release notes](https://github.com/openai/openai-go/releases)
- [Changelog](https://github.com/openai/openai-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/openai/openai-go/compare/v1.6.0...v1.12.0)

---
updated-dependencies:
- dependency-name: github.com/openai/openai-go
  dependency-version: 1.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-04 13:57:16 +00:00
Simon
c2881627cc Merge pull request #24 from simon-ding/dependabot/go_modules/golift.io/starr-1.1.0
chore(deps): bump golift.io/starr from 1.0.0 to 1.1.0
2025-06-30 19:57:30 +08:00
dependabot[bot]
360a90414b chore(deps): bump golift.io/starr from 1.0.0 to 1.1.0
Bumps [golift.io/starr](https://github.com/golift/starr) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/golift/starr/releases)
- [Commits](https://github.com/golift/starr/compare/v1.0.0...v1.1.0)

---
updated-dependencies:
- dependency-name: golift.io/starr
  dependency-version: 1.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-30 10:49:04 +00:00
Simon
294cd65ab2 Merge pull request #25 from simon-ding/dependabot/go_modules/github.com/gin-gonic/gin-1.10.1
chore(deps): bump github.com/gin-gonic/gin from 1.10.0 to 1.10.1
2025-06-30 18:44:36 +08:00
Simon
720219433d Merge pull request #27 from simon-ding/dependabot/go_modules/github.com/nikoksr/notify-1.3.0
chore(deps): bump github.com/nikoksr/notify from 1.0.0 to 1.3.0
2025-06-30 18:43:58 +08:00
dependabot[bot]
002823492f chore(deps): bump github.com/nikoksr/notify from 1.0.0 to 1.3.0
Bumps [github.com/nikoksr/notify](https://github.com/nikoksr/notify) from 1.0.0 to 1.3.0.
- [Release notes](https://github.com/nikoksr/notify/releases)
- [Commits](https://github.com/nikoksr/notify/compare/v1.0.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/nikoksr/notify
  dependency-version: 1.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-30 10:33:03 +00:00
Simon
65d58b2e84 Merge pull request #26 from simon-ding/dependabot/go_modules/golang.org/x/net-0.41.0
chore(deps): bump golang.org/x/net from 0.40.0 to 0.41.0
2025-06-30 18:30:38 +08:00
Simon
1f92429fd3 Merge pull request #28 from simon-ding/dependabot/go_modules/entgo.io/ent-0.14.4
chore(deps): bump entgo.io/ent from 0.13.1 to 0.14.4
2025-06-30 18:30:20 +08:00
Simon Ding
9e00e69941 fix: deps 2025-06-30 18:29:51 +08:00
dependabot[bot]
61c8023ff0 chore(deps): bump entgo.io/ent from 0.13.1 to 0.14.4
Bumps [entgo.io/ent](https://github.com/ent/ent) from 0.13.1 to 0.14.4.
- [Release notes](https://github.com/ent/ent/releases)
- [Commits](https://github.com/ent/ent/compare/v0.13.1...v0.14.4)

---
updated-dependencies:
- dependency-name: entgo.io/ent
  dependency-version: 0.14.4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-23 12:55:06 +00:00
dependabot[bot]
bc26d91792 chore(deps): bump golang.org/x/net from 0.40.0 to 0.41.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.40.0 to 0.41.0.
- [Commits](https://github.com/golang/net/compare/v0.40.0...v0.41.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.41.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-23 12:19:36 +00:00
dependabot[bot]
d6d51d97d7 chore(deps): bump github.com/gin-gonic/gin from 1.10.0 to 1.10.1
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/gin-gonic/gin/releases)
- [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gin-gonic/gin/compare/v1.10.0...v1.10.1)

---
updated-dependencies:
- dependency-name: github.com/gin-gonic/gin
  dependency-version: 1.10.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-23 12:06:03 +00:00
Simon
33b5f35bd2 Merge pull request #22 from simon-ding/dependabot/go_modules/github.com/goccy/go-json-0.10.5
chore(deps): bump github.com/goccy/go-json from 0.10.2 to 0.10.5
2025-06-22 12:38:55 +08:00
Simon
d8a717798b Merge pull request #23 from simon-ding/dependabot/go_modules/github.com/cyruzin/golang-tmdb-1.8.1
chore(deps): bump github.com/cyruzin/golang-tmdb from 1.6.3 to 1.8.1
2025-06-22 12:38:43 +08:00
Simon
932d6a88ac Merge pull request #19 from simon-ding/dependabot/go_modules/github.com/openai/openai-go-1.6.0
chore(deps): bump github.com/openai/openai-go from 0.1.0-beta.10 to 1.6.0
2025-06-22 12:38:20 +08:00
dependabot[bot]
b15c761ceb chore(deps): bump github.com/openai/openai-go
Bumps [github.com/openai/openai-go](https://github.com/openai/openai-go) from 0.1.0-beta.10 to 1.6.0.
- [Release notes](https://github.com/openai/openai-go/releases)
- [Changelog](https://github.com/openai/openai-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/openai/openai-go/compare/v0.1.0-beta.10...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/openai/openai-go
  dependency-version: 1.6.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-18 03:38:12 +00:00
Simon
55d786d285 Merge pull request #20 from simon-ding/dependabot/go_modules/github.com/ncruces/go-sqlite3-0.26.1
chore(deps): bump github.com/ncruces/go-sqlite3 from 0.18.4 to 0.26.1
2025-06-18 11:36:47 +08:00
dependabot[bot]
9cb7460432 chore(deps): bump github.com/cyruzin/golang-tmdb from 1.6.3 to 1.8.1
Bumps [github.com/cyruzin/golang-tmdb](https://github.com/cyruzin/golang-tmdb) from 1.6.3 to 1.8.1.
- [Release notes](https://github.com/cyruzin/golang-tmdb/releases)
- [Changelog](https://github.com/cyruzin/golang-tmdb/blob/master/changes.go)
- [Commits](https://github.com/cyruzin/golang-tmdb/compare/v1.6.3...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/cyruzin/golang-tmdb
  dependency-version: 1.8.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-18 02:50:23 +00:00
dependabot[bot]
566dbc43d6 chore(deps): bump github.com/goccy/go-json from 0.10.2 to 0.10.5
Bumps [github.com/goccy/go-json](https://github.com/goccy/go-json) from 0.10.2 to 0.10.5.
- [Release notes](https://github.com/goccy/go-json/releases)
- [Changelog](https://github.com/goccy/go-json/blob/master/CHANGELOG.md)
- [Commits](https://github.com/goccy/go-json/compare/v0.10.2...v0.10.5)

---
updated-dependencies:
- dependency-name: github.com/goccy/go-json
  dependency-version: 0.10.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-18 02:50:19 +00:00
dependabot[bot]
27fb5d3e13 chore(deps): bump github.com/ncruces/go-sqlite3 from 0.18.4 to 0.26.1
Bumps [github.com/ncruces/go-sqlite3](https://github.com/ncruces/go-sqlite3) from 0.18.4 to 0.26.1.
- [Release notes](https://github.com/ncruces/go-sqlite3/releases)
- [Commits](https://github.com/ncruces/go-sqlite3/compare/v0.18.4...v0.26.1)

---
updated-dependencies:
- dependency-name: github.com/ncruces/go-sqlite3
  dependency-version: 0.26.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-18 02:50:14 +00:00
Simon
d1137d2b06 Create dependabot.yml 2025-06-18 10:48:58 +08:00
Simon Ding
19c6e7dd7b fix: not default path 2025-06-11 15:47:37 +08:00
Simon Ding
ee23bb2c3e fix: error mount 2025-06-11 15:00:31 +08:00
Simon
8f3dab6728 Merge pull request #18 from simon-ding/dependabot/go_modules/go_modules-b15aa7f5dc
chore(deps): bump github.com/pion/interceptor from 0.1.37 to 0.1.39 in the go_modules group across 1 directory
2025-06-11 13:31:48 +08:00
dependabot[bot]
4952422df7 chore(deps): bump github.com/pion/interceptor
Bumps the go_modules group with 1 update in the / directory: [github.com/pion/interceptor](https://github.com/pion/interceptor).


Updates `github.com/pion/interceptor` from 0.1.37 to 0.1.39
- [Release notes](https://github.com/pion/interceptor/releases)
- [Changelog](https://github.com/pion/interceptor/blob/master/.goreleaser.yml)
- [Commits](https://github.com/pion/interceptor/compare/v0.1.37...v0.1.39)

---
updated-dependencies:
- dependency-name: github.com/pion/interceptor
  dependency-version: 0.1.39
  dependency-type: indirect
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-09 20:31:52 +00:00
Chuan Ding
ad950f6c28 chores: update deps 2025-05-30 14:46:27 +08:00
Simon Ding
068aa121a4 fix: disable stun proxy feature 2025-05-08 20:35:12 +08:00
Simon Ding
5e143edda3 fix 2025-05-08 18:38:39 +08:00
Simon Ding
a491a5f1ea fix: timer 2025-05-08 17:19:25 +08:00
Simon Ding
094c7a24b9 fix: heartbeat interval 2025-05-08 17:12:14 +08:00
Simon Ding
b80d38788c chore: remove log 2025-05-08 17:11:01 +08:00
Simon Ding
f59a0682c6 update stun proxy 2025-05-08 17:07:54 +08:00
Simon Ding
ead022e17d fix: save setting 2025-05-08 16:52:09 +08:00
Simon Ding
b69100d9b4 doc: update nat traversal 2025-05-08 16:46:57 +08:00
Simon Ding
bb0d5d1b58 feat(ui): add nat traversal option 2025-05-08 16:30:06 +08:00
Simon Ding
992fa7ddd0 feat: update stun proxy logic 2025-05-08 16:13:30 +08:00
Simon Ding
bb2c567da7 chore: update 2025-05-08 10:28:57 +08:00
Simon Ding
2dae168cb2 udp stun proxy 2025-05-07 22:09:57 +08:00
Simon Ding
9719c6a7c9 WIP: stun proxy 2025-05-07 18:16:10 +08:00
Simon Ding
5375f66018 feat: windows app update 2025-04-29 18:54:56 +08:00
Simon Ding
3a73d0c33e fix 2025-04-29 15:55:11 +08:00
Simon Ding
3eb1f37387 feat: windows app update 2025-04-29 15:22:46 +08:00
Simon Ding
9b791ba86f fix 2025-04-29 14:13:02 +08:00
Simon Ding
22db6b15cf feat: windows desktop app complete 2025-04-29 14:11:43 +08:00
Simon Ding
33d82951c1 better match year 2025-04-29 10:01:40 +08:00
Simon Ding
dd77e25b38 feat: refresh page date after download 2025-04-28 15:47:20 +08:00
Simon Ding
c58a038daf feat: match tv release year 2025-04-28 14:31:46 +08:00
Simon Ding
b81c5d327c fix: update parse rule 2025-04-28 11:06:59 +08:00
Simon Ding
04dcbf04e7 Merge branch 'main' of github.com:simon-ding/polaris 2025-04-28 10:50:16 +08:00
Simon Ding
4bf72a7976 WIP: ai deepseek integration 2025-04-28 10:49:58 +08:00
Simon Ding
9e14be7322 chore: update go -> 1.24 2025-04-24 22:48:18 +08:00
Simon Ding
483e1caf83 chore: update 2025-04-23 16:54:59 +08:00
Simon Ding
f074d38f4f feat(ui): show loading animation 2025-04-23 16:49:12 +08:00
Simon Ding
9c7129660c feat: seeding torrent only mark as success 2025-04-23 16:43:39 +08:00
Simon Ding
8b11e72427 feat: adjust indexer priority to the same as prowlarr 2025-04-23 16:24:20 +08:00
Simon Ding
2267b0450a refactor: buildin client 2025-04-23 14:35:18 +08:00
Simon Ding
8973fe9d5d chore: fix prowlarr 2025-04-23 14:03:48 +08:00
Simon Ding
9d3b206762 fix: buildin client progress 2025-04-23 13:45:58 +08:00
Simon Ding
386e5ce100 chore: add remove icon 2025-04-23 13:34:33 +08:00
Simon Ding
78573b71a9 fix: remove history 2025-04-23 11:32:42 +08:00
Simon Ding
62fd7e2c18 fix: judge episode downloading 2025-04-23 11:20:22 +08:00
Simon Ding
2641a5fccd fix: get episode 2025-04-23 11:07:24 +08:00
Simon Ding
98823e251b fix: exclude removed records 2025-04-23 10:58:38 +08:00
Simon Ding
269a5bf030 fix: nothing found 2025-04-23 10:53:15 +08:00
Simon Ding
502d482ea9 fix: blacklist name 2025-04-23 10:45:03 +08:00
Simon Ding
cff83e4d5f fix: null 2025-04-23 10:39:34 +08:00
Simon Ding
9b7527defe chore: fix 2025-04-23 10:32:21 +08:00
Simon Ding
aecbc5f657 chore: format 2025-04-23 10:26:32 +08:00
Simon Ding
9e41a1513c feat: block torrent in blacklist from addng to download client 2025-04-23 10:26:13 +08:00
Simon Ding
0d527c22e5 feat(ui): show blacklist 2025-04-23 09:53:44 +08:00
Simon Ding
0dea185077 feat: add to blacklist ui 2025-04-22 19:04:16 +08:00
Simon Ding
834254b9b8 feat: remove blacklist api 2025-04-22 18:23:24 +08:00
Simon Ding
fdcf7f487c feat: blacklist api 2025-04-22 18:18:32 +08:00
Simon Ding
1a3807acc9 feat: add create_time to db 2025-04-22 16:58:26 +08:00
Simon Ding
549aaf60ca feat: do not modify buildin downloader 2025-04-22 16:17:04 +08:00
Simon Ding
2fad5ea69b feat: no add transmission config 2025-04-22 15:55:25 +08:00
Simon Ding
3c7d7aa263 reafactor: update 2025-04-22 15:44:13 +08:00
Simon Ding
17f357e33a Merge branch 'main' of github.com:simon-ding/polaris 2025-04-22 15:40:08 +08:00
Simon Ding
7ccc73e044 refactor: db code 2025-04-22 15:39:47 +08:00
Simon Ding
ff2f290641 chore: fix typo 2025-04-20 15:31:29 +08:00
Simon Ding
aee32c7bbf chore: reduce log 2025-04-20 10:44:41 +08:00
Simon Ding
8e9ba101c8 fix: get correct movie episode id 2025-04-20 10:41:58 +08:00
Simon Ding
ec3f9b2f96 fix: create dir if not exist 2025-04-20 10:25:05 +08:00
Simon Ding
8f354fff41 fix: handle err 2025-04-20 10:08:00 +08:00
Simon Ding
d44060ff33 feat: use real link to download client 2025-04-19 21:22:06 +08:00
Simon Ding
1ea8246cfc fix: do not cache error result 2025-04-19 20:50:50 +08:00
Simon
8aef9260a1 Merge pull request #17 from simon-ding/dependabot/go_modules/go_modules-bbb8b02913
chore(deps): bump golang.org/x/net from 0.37.0 to 0.38.0 in the go_modules group across 1 directory
2025-04-18 17:51:38 +08:00
dependabot[bot]
ef3b555036 chore(deps): bump golang.org/x/net
Bumps the go_modules group with 1 update in the / directory: [golang.org/x/net](https://github.com/golang/net).


Updates `golang.org/x/net` from 0.37.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.37.0...v0.38.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: direct:production
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-16 23:29:36 +00:00
Simon
26dc488d48 更新 README.md 2025-04-11 16:16:13 +08:00
Simon
14764c7b06 更新 README.md 2025-04-11 16:15:35 +08:00
Simon Ding
951b73bc4e update 2025-04-11 16:08:20 +08:00
Simon Ding
55c2a3c8e2 doc: update 2025-04-11 16:07:39 +08:00
Simon Ding
310c83a27c fix: escape 2025-04-11 16:06:47 +08:00
Simon Ding
75ef1a42ae fix: typo 2025-04-11 16:05:47 +08:00
Simon Ding
fa78e40baf chore: update doc 2025-04-11 16:04:37 +08:00
Simon Ding
aefc4a28c2 chore: remove isdesktop check 2025-04-11 15:29:17 +08:00
Simon Ding
4bc0a44c33 fix: desktop check 2025-04-11 14:47:50 +08:00
Simon Ding
8a5e5ff391 feat: temp disable ffi 2025-04-10 16:00:33 +08:00
Simon Ding
2ceb006f58 feat: no check space available 2025-04-10 15:00:46 +08:00
Simon Ding
6371139607 feat: build windows dll and call dll in flutter 2025-04-10 14:24:46 +08:00
Simon Ding
5ab347845a feat: go build to dll 2025-04-09 14:12:02 +08:00
Simon Ding
eabb39df02 fix: main entry 2025-04-09 11:40:18 +08:00
Simon Ding
9eb8278f78 feat: export C lib 2025-04-09 11:01:37 +08:00
Simon Ding
59fa91a3bf feat: simple eventbus 2025-04-08 17:46:07 +08:00
Simon Ding
2bc71b0c66 refactor: thread safe tasks 2025-04-08 14:01:32 +08:00
Simon Ding
9014f846be featr(ui): add windows support 2025-04-07 14:57:27 +08:00
Simon Ding
3c9f6d0b23 chore: mark as removed instead of delete history 2025-03-31 17:59:04 +08:00
Simon Ding
c23666eabf fix: task percent 2025-03-31 17:45:30 +08:00
Simon Ding
8cc4e288fe feat: buildin task reload 2025-03-31 17:41:52 +08:00
Simon Ding
e680866d54 chore: buildin downloader updates 2025-03-31 16:08:13 +08:00
Simon Ding
eb2450e92b refactor: core client to engine 2025-03-31 11:06:03 +08:00
Simon Ding
6a2ab50d7d Merge remote-tracking branch 'origin/main' 2025-03-31 11:00:48 +08:00
Simon Ding
db22c4cff2 chore: mv config 2025-03-31 11:00:30 +08:00
Simon
8ef31818b3 Merge pull request #14 from simon-ding/dependabot/go_modules/go_modules-036d30de33
chore(deps): bump github.com/golang-jwt/jwt/v5 from 5.2.1 to 5.2.2 in the go_modules group across 1 directory
2025-03-31 09:35:25 +08:00
Simon Ding
050e6446a7 feat: build in torrent client 2025-03-28 17:46:20 +08:00
Simon Ding
74e680c1ee WIP: buildin torrent client 2025-03-28 16:15:54 +08:00
Simon Ding
0f56c97724 feat: return custom error code 2025-03-25 10:36:52 +08:00
dependabot[bot]
577297365f chore(deps): bump github.com/golang-jwt/jwt/v5
Bumps the go_modules group with 1 update in the / directory: [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt).


Updates `github.com/golang-jwt/jwt/v5` from 5.2.1 to 5.2.2
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v5.2.1...v5.2.2)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v5
  dependency-type: direct:production
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-21 22:18:29 +00:00
Simon Ding
c809ca2a70 chore: change error desc 2025-03-19 14:13:34 +08:00
Simon Ding
b4b767d4c2 chore: rename 2025-03-19 13:44:45 +08:00
Simon Ding
6d77bed506 chore: add start script 2025-03-19 11:22:08 +08:00
Simon Ding
dac96c099c feat: allow not set tmdb api key 2025-03-19 11:18:24 +08:00
Simon Ding
be86fd05e1 feat: embed default tmdb api key 2025-03-19 10:49:05 +08:00
Simon Ding
ca06e560e3 chore: go mod tidy 2025-03-13 18:02:38 +08:00
Simon
fd566d3cb2 remove go proxy 2025-03-13 13:52:14 +08:00
Simon
16643d03f5 Merge pull request #13 from simon-ding/dependabot/go_modules/go_modules-c153b83258
chore(deps): bump golang.org/x/net from 0.34.0 to 0.36.0 in the go_modules group across 1 directory
2025-03-13 11:01:26 +08:00
dependabot[bot]
23b1ec1bf5 chore(deps): bump golang.org/x/net
Bumps the go_modules group with 1 update in the / directory: [golang.org/x/net](https://github.com/golang/net).


Updates `golang.org/x/net` from 0.34.0 to 0.36.0
- [Commits](https://github.com/golang/net/compare/v0.34.0...v0.36.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-13 01:58:10 +00:00
Simon Ding
d44f786f9b feat: add serverchan notify client 2025-02-13 12:04:51 +08:00
Simon Ding
8a4566aee8 fix: remove torrent panics 2025-02-13 11:46:35 +08:00
Simon Ding
059c0ee994 fix: refresh 2025-02-10 16:37:15 +08:00
Simon Ding
2f08b5d332 fix button 2025-02-10 16:13:21 +08:00
Simon Ding
ce020566b7 feat: add seeding tab 2025-02-10 16:06:35 +08:00
Simon Ding
f3b2b3bc32 doc: add faq 2025-02-10 15:31:56 +08:00
Simon Ding
e380a624f5 WIP: douban wish list 2025-02-10 15:07:32 +08:00
Simon Ding
80ad9a2a3b feat: horizontal scroll, fix #11 2025-02-10 11:22:25 +08:00
Simon Ding
2a9fdd2a13 fix: db 2025-02-02 13:09:22 +08:00
Simon Ding
88492b3922 feat: deprecate history episodeID and fix related code 2025-02-02 12:49:59 +08:00
Simon Ding
1d9eddf050 fix: episode and history status not match 2025-02-02 12:31:52 +08:00
Simon Ding
8a8bf87c32 fix: torrent hash 2025-02-02 11:55:11 +08:00
Simon Ding
2821d49673 feat: save hash instead of link, and refactor torrent download 2025-02-01 14:22:34 +08:00
Simon Ding
8b6558b2b5 chore: add log 2025-01-31 23:31:32 +08:00
Simon Ding
27515d1368 refactor: history and episode status 2025-01-31 23:21:26 +08:00
Simon Ding
c01924ac3f refactor: copy downloaded file according to torrent info 2025-01-31 19:34:18 +08:00
Simon Ding
1386626712 fix: do not convert torrent to magnet link 2025-01-31 16:34:43 +08:00
Simon Ding
a8b6661ec9 chore: add xml header 2025-01-19 15:44:05 +08:00
Simon Ding
842f8fae09 feat: prowlarr refactor and support prowlarr seed ratio 2025-01-10 11:39:16 +08:00
Simon Ding
03105a1989 chore: update deps 2024-12-22 13:45:11 +08:00
Simon Ding
e169172c68 doc: update 2024-12-13 14:34:34 +08:00
Simon Ding
937b035634 fix 2024-12-13 13:48:58 +08:00
Simon Ding
c639e11b90 fix: debian do not support arm v6 2024-12-13 13:44:32 +08:00
Simon Ding
f2ac688ed8 feat: release build flutter use github action 2024-12-13 13:33:39 +08:00
Simon Ding
369263a55c fix 2024-12-13 13:25:51 +08:00
Simon Ding
9d4848129f feat: build flutter use github action 2024-12-13 13:22:12 +08:00
Simon Ding
f7e82fa464 feat: search with alternative titles 2024-12-13 12:19:02 +08:00
Simon Ding
d2354ab33c feat: ditch html render and update flutter packages 2024-12-13 11:44:42 +08:00
Simon Ding
67014cfb16 feat: save media alternative titles 2024-12-13 11:35:32 +08:00
Simon
60edeacd0d Merge pull request #10 from simon-ding/dependabot/go_modules/go_modules-5a9c29dde4
chore(deps): bump golang.org/x/crypto from 0.27.0 to 0.31.0 in the go_modules group across 1 directory
2024-12-12 12:33:06 +08:00
dependabot[bot]
4c77cf5798 chore(deps): bump golang.org/x/crypto
Bumps the go_modules group with 1 update in the / directory: [golang.org/x/crypto](https://github.com/golang/crypto).


Updates `golang.org/x/crypto` from 0.27.0 to 0.31.0
- [Commits](https://github.com/golang/crypto/compare/v0.27.0...v0.31.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-12 00:29:52 +00:00
Simon Ding
3cf48d1f8e fix: remove files 2024-12-11 21:25:28 +08:00
Simon Ding
6d127c6d00 feat: add option to delete storage media files 2024-12-11 21:09:00 +08:00
Simon Ding
22f76e3f57 fix: monitor new episode 2024-12-11 20:27:51 +08:00
Simon Ding
e947396c04 fix: cache 2024-12-11 20:11:33 +08:00
Simon Ding
1020190c01 feat: cache download status number 2024-12-11 20:04:37 +08:00
Simon Ding
7c05acd1cf feat: in favor of gridview.builder for better performance 2024-12-11 14:44:41 +08:00
Simon Ding
76a9183b52 refactor: reduce default poster image size to w500 2024-12-11 12:24:16 +08:00
Simon Ding
6698d368c3 chore: updates 2024-12-06 11:06:50 +08:00
Simon Ding
acb627d011 feat: add arm v7 2024-11-26 18:50:40 +08:00
Simon Ding
7c64d964e8 ui: cancel timer before calling 2024-11-21 10:01:52 +08:00
Simon Ding
bec3b04705 ui: add macos client 2024-11-21 09:45:44 +08:00
Simon Ding
990da92b75 chore: change env name 2024-11-20 19:21:25 +08:00
Simon Ding
ee14cc63b8 chore: updates 2024-11-20 19:20:14 +08:00
Simon Ding
8df7b8665b chore: add sub ext 2024-11-20 16:25:35 +08:00
Simon Ding
ea90e014b1 feat: remove default internal size limiter 2024-11-20 15:34:57 +08:00
Simon Ding
6372c5c6e6 chore: update error msg 2024-11-20 15:06:26 +08:00
Simon Ding
7b6dba1afe feat: only accept video files and subtitles of known formats 2024-11-20 12:03:56 +08:00
Simon Ding
c833f6fab6 feat: complete size limiter feature 2024-11-19 23:54:27 +08:00
Simon Ding
b4c2002ad1 feat: apply global size limiter 2024-11-19 19:51:06 +08:00
Simon Ding
b2a9f1f83b refactor: size limiter 2024-11-19 19:24:43 +08:00
Simon Ding
b69881d26b WIP: size limiter 2024-11-19 18:22:40 +08:00
Simon Ding
be07e457d0 chore: update doc 2024-11-18 10:45:33 +08:00
Simon Ding
2cdd6e3740 doc: update 2024-11-18 00:28:10 +08:00
Simon Ding
fa2968f01a chore: remove log 2024-11-18 00:10:16 +08:00
Simon Ding
36f24a7e04 feat: alist upload as task 2024-11-17 23:46:31 +08:00
Simon Ding
ecc7465028 feat: use path escape 2024-11-17 23:44:46 +08:00
Simon Ding
3af4ac795e fix: alist upload 2024-11-17 23:40:31 +08:00
Simon Ding
af2a30405c fix 2024-11-17 22:10:24 +08:00
Simon Ding
ba3f6de852 feat: add upload progress and fix panic 2024-11-17 21:57:14 +08:00
Simon Ding
7d5ce8ba97 feat: support alist as a storage 2024-11-17 21:21:21 +08:00
Simon Ding
b136b9167f ui: change ui on add settings 2024-11-17 14:00:02 +08:00
Simon Ding
f0f3281428 feat: improve name parsing 2024-11-16 14:15:45 +08:00
Simon Ding
196ba6635f feat: start download after save to db 2024-11-16 10:27:49 +08:00
Simon Ding
b61b7f082e fix: season pack download 2024-11-16 10:19:46 +08:00
Simon Ding
105b296ba2 ui: submit search will refresh data 2024-11-15 20:15:12 +08:00
Simon Ding
c4d153f15b fix 2024-11-15 17:58:24 +08:00
Simon Ding
d2619120da fix: season pack download more than once 2024-11-15 15:59:32 +08:00
Simon Ding
fbfee65a50 feat: support for torrent with multi episodes 2024-11-15 15:43:07 +08:00
Simon Ding
c433ccaa0e fix: episode match 2024-11-15 13:12:20 +08:00
Simon Ding
58428405b0 fix: episode match 2024-11-15 12:48:12 +08:00
Simon Ding
45cd94f65b feat: parse multi episode like S01E01-S01E21 2024-11-15 12:38:10 +08:00
Simon Ding
53cbca3101 fix: name empty 2024-11-15 12:05:47 +08:00
Simon Ding
576956e271 fix: season position 2024-11-15 11:57:57 +08:00
Simon Ding
31d20b4f36 fix 2024-11-15 11:56:09 +08:00
Simon Ding
d026dc4eec feat: ability to parse multi episode 2024-11-15 11:44:19 +08:00
Simon Ding
e472d67c79 ui: update desc 2024-11-10 20:20:26 +08:00
Simon Ding
2165a8c533 WIP: init wizard 2024-11-10 15:09:16 +08:00
Simon Ding
0c3b5a6907 feat: create timer only after success 2024-11-10 13:47:50 +08:00
Simon Ding
aaa006a322 WIP: init wizard 2024-11-10 13:28:21 +08:00
Simon Ding
a83f860624 feat: no result consider ok 2024-11-09 20:31:14 +08:00
Simon Ding
b0c325bc4b feat: match reource name using tmdb api 2024-11-09 20:12:28 +08:00
Simon Ding
a0431df1ee feat: not query unaired episodes 2024-11-05 19:17:46 +08:00
Simon Ding
7b02eeac51 WIP: upload with progress 2024-11-05 18:54:40 +08:00
Simon Ding
66a307f202 feat: change timeout 2024-11-05 18:44:32 +08:00
Simon Ding
ae611943c3 doc: update 2024-11-05 13:23:37 +08:00
Simon Ding
4fd11540cd update 2024-11-05 13:16:28 +08:00
Simon Ding
587a28127b ui: improve search error display 2024-11-05 13:00:23 +08:00
Simon Ding
05ae58030c ui: improve error 2024-11-05 12:54:52 +08:00
Simon Ding
f1c4e306f4 ui: improve error readablity 2024-11-05 12:43:17 +08:00
Simon Ding
949b6e5188 ui: remove main selectionArea 2024-11-05 11:51:08 +08:00
Simon Ding
0d4b453d0a feat: prowlarr enable to disable 2024-11-05 10:52:14 +08:00
Simon Ding
bce4d93ab1 feat: add prowlarr enable button 2024-11-04 23:48:52 +08:00
Simon Ding
36b72e6461 fix: text selectable 2024-11-04 18:37:44 +08:00
Simon Ding
62417727f9 ui: revert searchbar 2024-11-04 18:13:02 +08:00
Simon Ding
03f72b9d86 ui: change appbar layout 2024-11-04 18:02:52 +08:00
Simon Ding
c17cf750e5 feat: better prowlarr support 2024-11-04 15:10:56 +08:00
Simon Ding
b176253fc4 feat: add log and defer task loading 2024-11-04 12:04:28 +08:00
Simon Ding
1e2d8b8520 fix: add default behavior 2024-11-04 12:03:32 +08:00
Simon Ding
3739f2c960 fix: page order 2024-11-04 11:30:48 +08:00
Simon Ding
bb6da47efb fix: use StatefulShellRoute to fix ui rerendering 2024-11-04 11:24:27 +08:00
Simon Ding
c28373bde1 ui: update deps 2024-11-01 22:23:21 +08:00
Simon Ding
8ce7045466 fix: return null 2024-11-01 22:05:06 +08:00
Simon Ding
0b1bd8226d fix: add validator 2024-11-01 22:00:18 +08:00
Simon Ding
e67413cec2 feat: add refresh button & parse dialog 2024-11-01 21:53:38 +08:00
Simon Ding
2da02fa706 ui: add filter option 2024-11-01 18:14:32 +08:00
Simon Ding
bc50dd888a ui: change icon 2024-10-27 21:26:53 +08:00
Simon Ding
0305c0709d ui: add donate button 2024-10-27 21:19:02 +08:00
Simon Ding
5e9e85206e doc: update 2024-10-27 20:12:46 +08:00
Simon Ding
3babb9f5c7 doc: update prowlarr setting 2024-10-27 20:11:04 +08:00
Simon Ding
c9928f10ce revert: to html renderer 2024-10-21 09:24:35 +08:00
Simon Ding
a2da1e7479 feat: use canvas render 2024-10-21 08:59:51 +08:00
Simon Ding
038f643ce3 ui: upgrade dependences 2024-10-21 08:46:10 +08:00
Simon Ding
cf2fa90d5d ui: change prowlarr setting text 2024-10-20 22:28:12 +08:00
Simon Ding
677923ea8a fix: match priority 2024-10-20 16:36:34 +08:00
Simon Ding
1192d00fe0 feat: change icon 2024-10-20 16:24:28 +08:00
Simon Ding
b317636a8a feat: support prowlarr connection 2024-10-20 16:21:58 +08:00
Simon Ding
0e6465593b update 2024-10-20 13:37:33 +08:00
Simon
2cb8a5b6fb Update README.md 2024-10-20 13:20:13 +08:00
Simon Ding
8b7bd1f6c6 fix: default size limiter 2024-10-19 21:57:23 +08:00
Simon Ding
1a9ba8a599 feat: add defaukt min size, 80M for tv, 200M for movie 2024-10-19 21:20:19 +08:00
Simon Ding
709d9ea4eb feat: send msg when added to import list 2024-10-16 15:21:47 +08:00
Simon Ding
ed692b5aae update wechat 2024-10-14 16:05:12 +08:00
Simon Ding
f80ee71018 ui: update 2024-10-11 14:52:11 +08:00
Simon Ding
98fae05e16 feat: add qbit category 2024-10-11 13:20:03 +08:00
Simon Ding
f2faefa837 fix: qbit torrent name mismatch file name 2024-10-11 11:39:41 +08:00
Simon Ding
b281c6febb fix: set locale 2024-10-10 18:46:21 +08:00
Simon Ding
09862a2844 fix: name 2024-10-10 18:24:38 +08:00
Simon Ding
f77f565146 fix: add user 2024-10-10 18:16:34 +08:00
Simon Ding
befd5c6a8a feat: disable cgo in docker 2024-10-10 17:46:41 +08:00
Simon Ding
8376fef376 feat: remove umask 2024-10-10 17:42:25 +08:00
Simon Ding
9b641fb593 doc: add unraid install 2024-10-10 17:41:11 +08:00
Simon Ding
9b0fb42043 doc: update 2024-10-10 17:30:55 +08:00
Simon Ding
bf2aeaa2d0 fix: permission 2024-10-10 16:55:03 +08:00
Simon Ding
c52204619d feat: dokcer image support PUID PGID 2024-10-10 16:47:13 +08:00
Simon Ding
485a580661 feat: ascii name should match words 2024-10-10 13:16:44 +08:00
Simon Ding
a22100b2fc feat: reduce time consuming 2024-10-10 10:29:47 +08:00
Simon Ding
1728690860 refactor: change method to restore tasks for better maintains 2024-10-10 09:57:17 +08:00
Simon Ding
e0d0ab80b6 feat: clean cache upon indexer setting changes 2024-10-10 09:21:33 +08:00
Simon Ding
19f21ddd6e feat: self calculate required torrent hash 2024-10-10 09:01:51 +08:00
Simon Ding
37ad1391db fix: ci 2024-10-10 08:44:09 +08:00
Simon Ding
5daeca0bd9 feat: api to add torrent hash to blacklist 2024-10-10 00:49:32 +08:00
Simon Ding
7e4d907ef6 feat: save torrent link to history 2024-10-09 23:56:04 +08:00
Simon Ding
6527f843d8 update 2024-10-04 21:17:33 +08:00
Simon Ding
f5ca53f7d7 update: required 2024-10-04 11:39:58 +08:00
Simon Ding
7461918a6c fix: qbit progress 2024-10-04 11:36:12 +08:00
Simon Ding
3af5f96cb0 feat: support download client priority 2024-10-04 11:12:06 +08:00
Simon Ding
7dfa4eafc4 feat: support reload qbit tasks 2024-10-04 10:45:31 +08:00
Simon Ding
579b010d13 fix: go mod tidy 2024-10-04 10:32:19 +08:00
Simon Ding
c42cbb5e5d feat: complete qbittorrent support 2024-10-04 10:31:49 +08:00
Simon Ding
6a5c105f8c WIP: qbittorrent support 2024-10-04 01:22:27 +08:00
Simon Ding
e8067f96f1 feat: allow set any media qulity 2024-10-03 22:19:16 +08:00
Simon Ding
84a0197776 refactor: name testing 2024-09-29 18:43:29 +08:00
Simon Ding
f9556ec2d2 feat: check movie folder upon added 2024-09-29 18:35:20 +08:00
Simon Ding
98d14befa9 fix: remove episodes no media id 2024-09-29 16:16:05 +08:00
Simon Ding
6fcc569bf2 feat: clean dangling episodes 2024-09-29 15:45:31 +08:00
Simon Ding
672e7f914d feat: desc ordering 2024-09-29 15:33:56 +08:00
Simon Ding
20bdcdbcde fix: validate 2024-09-29 14:46:06 +08:00
Simon Ding
577a6cee1e fix: add flutter build 2024-09-29 14:37:58 +08:00
Simon Ding
4186d7d97f update go version 2024-09-29 14:33:21 +08:00
Simon Ding
5d726dbcf1 feat: add goreleaser 2024-09-29 14:27:01 +08:00
Simon Ding
ce25c090f5 feat: open url at startup 2024-09-29 13:55:16 +08:00
Simon Ding
2683c5dbf2 fix: tv name parse 2024-09-27 21:58:34 +08:00
Simon Ding
b717885270 feat: change status color 2024-09-27 15:19:45 +08:00
Simon Ding
4e457e99b9 fix: context 2024-09-27 15:03:00 +08:00
Simon Ding
ecfe31ea45 fix: tv date not exists and folder name suggestion 2024-09-26 09:45:36 +08:00
Simon Ding
89104785d7 fix: monitor lastest season 2024-09-23 23:12:06 +08:00
Simon Ding
f4ccc69b50 feat: trim white space 2024-09-23 22:44:15 +08:00
Simon Ding
40c6e2df5c fix: panic when torrent not exist 2024-09-21 21:47:26 +08:00
Simon Ding
37dfb0fe94 feat: add check 2024-09-21 21:23:47 +08:00
Simon Ding
9968f9f225 feat: add ability to change folder naming convention 2024-09-20 20:03:05 +08:00
Simon Ding
f5c977224b fix 2024-09-20 14:27:49 +08:00
Simon Ding
8af3ffccd3 fix: double downloading status problem 2024-09-20 11:40:22 +08:00
Simon Ding
c535dfd714 feat: do not use lowercase 2024-09-20 11:11:27 +08:00
Simon Ding
f696b78260 feat: default monitor lastest season all episodes 2024-09-20 11:03:01 +08:00
Simon Ding
4f3e3e399d feat: transmission use hash instead of id 2024-09-20 10:45:10 +08:00
Simon Ding
e4e3c9a851 fix: suggestted name when name_cn is in english 2024-09-07 13:45:27 +08:00
Simon Ding
bf608f933d feat: ui to manaul trigger cron jobs 2024-09-07 13:18:12 +08:00
Simon Ding
5923fc73e1 fix: new import list display 2024-09-04 16:51:49 +08:00
Simon Ding
c2d9ccfd4c chore: update ui details 2024-09-04 16:20:33 +08:00
Simon Ding
5d4429bf7c chore: update watchlist 2024-09-04 15:55:15 +08:00
Simon Ding
e4c111ac2a fix: cron jobs 2024-09-04 13:18:14 +08:00
Simon Ding
3e5e20e933 fix: naming 2024-09-03 10:04:56 +08:00
Simon Ding
ba1be8f279 feat: cron trigger api and fix import lists 2024-09-03 09:46:23 +08:00
Simon Ding
361556228b feat: add import list & calendar 2024-09-02 23:47:19 +08:00
Simon Ding
ca414a73ff fix: logout 2024-09-02 14:07:47 +08:00
Simon Ding
32b595e116 fix: change token name and same site lax rule 2024-09-02 13:59:36 +08:00
Simon Ding
b12bbd2ad9 fix: http auth 2024-09-02 13:45:49 +08:00
Simon Ding
60110f4ca6 feat: add db extra fields 2024-08-24 21:03:08 +08:00
Simon Ding
b7ca02429c chore: jav name suggest 2024-08-19 17:45:34 +08:00
Simon Ding
ff63084014 feat: better jav search support 2024-08-19 17:39:37 +08:00
Simon Ding
821d6859ff feat: option to enable adult content 2024-08-19 16:39:34 +08:00
Simon Ding
10e6e99990 update readme 2024-08-16 11:49:23 +08:00
Simon Ding
23a5997814 fix: episode status 2024-08-13 11:27:54 +08:00
Simon Ding
b487c81865 feat: cache errored request 2024-08-13 11:05:46 +08:00
Simon Ding
32914344d1 fix: remove seeding torrent status not right 2024-08-13 10:57:04 +08:00
Simon Ding
644c9ed228 feat: marshal indented 2024-08-13 10:41:40 +08:00
Simon Ding
d3ad80380f feat: nfo support frontend 2024-08-13 10:17:46 +08:00
Simon Ding
19c6308a81 feat: nfo support backend 2024-08-13 10:05:38 +08:00
Simon Ding
7017f32fe3 feat: nfo support backend 2024-08-13 10:02:34 +08:00
Simon Ding
02a23f13f9 fix: mkdir 2024-08-13 00:11:27 +08:00
Simon Ding
cc211a89a4 fix: dir not exist 2024-08-12 23:06:51 +08:00
Simon Ding
4800e6c79d chore: update 2024-08-12 22:57:21 +08:00
Simon Ding
b5f0b28c61 fix 2024-08-12 22:44:36 +08:00
Simon Ding
081338df24 feat: code refactor and support season pack write .plexmatch file 2024-08-12 22:19:57 +08:00
Simon Ding
9632ca45b3 fix: match logic 2024-08-12 20:59:31 +08:00
Simon Ding
b948bff497 chore: if imdbid match no need check name 2024-08-12 19:02:43 +08:00
Simon Ding
29383cf75c feat: should match imdbid if present 2024-08-12 18:47:38 +08:00
Simon Ding
57ec0b9eb9 fix: download series all 2024-08-12 18:13:34 +08:00
Simon Ding
0cce4ffee0 add button to appbar 2024-08-12 14:53:23 +08:00
Simon Ding
5c01c45068 feat: fliter audios 2024-08-12 14:23:20 +08:00
Simon Ding
712bf84c90 feat: add app icon 2024-08-12 14:23:09 +08:00
Simon Ding
fdb63a8459 fix 2024-08-12 10:28:28 +08:00
Simon Ding
990d9dab08 update image 2024-08-12 10:27:20 +08:00
Simon Ding
da863588e4 feat: show snakebar 2024-08-12 10:23:28 +08:00
Simon Ding
09ff67fef7 feat: download per media feature 2024-08-12 10:16:36 +08:00
Simon Ding
3c37948798 ui: change icon 2024-08-11 23:42:43 +08:00
Simon Ding
6fd39d818c feat: better seeding status 2024-08-11 23:09:34 +08:00
Simon Ding
a0e211c328 fix: activity 2024-08-11 22:44:52 +08:00
Simon Ding
27d8b1672a feat: show seed as active 2024-08-11 22:40:38 +08:00
Simon Ding
349e394e8e chore: updates 2024-08-11 22:06:54 +08:00
Simon Ding
620f085ca5 add log 2024-08-11 20:54:12 +08:00
Simon Ding
5b70badb50 feat: add seed ratio display 2024-08-11 20:41:26 +08:00
Simon Ding
5c6ac2c430 fix: movie target dir 2024-08-11 20:19:51 +08:00
Simon Ding
365cfddf8f change icon 2024-08-11 19:20:23 +08:00
Simon Ding
6c26812b92 feat: filter resources that is qiangban 2024-08-11 19:18:27 +08:00
Simon Ding
0057a75a95 feat: find season pack first 2024-08-11 18:06:50 +08:00
Simon Ding
f110f257d4 code refactor and add season pack size limit 2024-08-11 17:40:01 +08:00
Simon Ding
93e8e78591 ui: improve external link display 2024-08-10 17:55:56 +08:00
Simon Ding
9ff12cd86b fix: movie year match 2024-08-10 17:06:33 +08:00
Simon Ding
fd2f4b140f refactor: download api 2024-08-10 16:46:49 +08:00
Simon Ding
4607af6982 feat: search original name 2024-08-10 16:46:19 +08:00
Simon Ding
984bebcfe0 ui: fine tune 2024-08-10 15:23:08 +08:00
Simon Ding
d31abd59ad chore: ui improvement 2024-08-10 15:05:18 +08:00
Simon Ding
e0ad71291c fix width 2024-08-10 11:23:17 +08:00
Simon Ding
8ecc9393cf fix: width 126->120 2024-08-10 11:16:17 +08:00
Simon Ding
b62e0e9bfd feat: small screen 2024-08-10 11:06:29 +08:00
Simon Ding
1391f55f44 feat: small screen 2024-08-10 10:52:48 +08:00
Simon Ding
0c709ee517 feat: detail card fit small screen 2024-08-10 10:45:18 +08:00
Simon Ding
806d821388 feat: better support for small screen 2024-08-10 10:35:57 +08:00
Simon Ding
829043bf28 fix: naming suggestion 2024-08-09 20:40:38 +08:00
Simon Ding
66ab418054 feat: remove name extras characters 2024-08-09 19:47:58 +08:00
Simon Ding
5fe40cc64b feat: add size to activity 2024-08-09 19:00:40 +08:00
Simon Ding
8f6f26f00e refactor: activity list 2024-08-08 19:23:23 +08:00
Simon Ding
ee0bee2b06 fix: formatting 2024-08-08 14:20:20 +08:00
Simon Ding
1bb16a8a66 feat: imdbid support 2024-08-08 14:10:26 +08:00
Simon Ding
d746032114 fix: result ordering 2024-08-08 13:40:07 +08:00
Simon Ding
b34e39889c feat: ui improvement 2024-08-08 10:56:03 +08:00
Simon Ding
64e98647a8 update go.mod 2024-08-08 00:56:49 +08:00
Simon Ding
f91c91e0b1 chore: main page ui update 2024-08-07 23:36:41 +08:00
Simon Ding
f1aaa06d05 chore: update new flutter version 2024-08-07 23:13:36 +08:00
Simon Ding
e8a38aa6f8 chore: ui update 2024-08-07 22:55:24 +08:00
Simon Ding
7e88533ea2 chore: update storage display 2024-08-07 14:12:47 +08:00
Simon Ding
05698f4047 fix: size limiter 2024-08-07 13:37:39 +08:00
Simon Ding
1daad0c236 fix size limiter 2024-08-07 13:27:41 +08:00
Simon Ding
86c8163f9c feat: default select first storage 2024-08-07 13:22:55 +08:00
Simon Ding
78ab8cc8e6 feat: add size display 2024-08-07 13:06:37 +08:00
Simon Ding
1390277b43 feat: second confirmation on deletion 2024-08-07 12:48:15 +08:00
Simon Ding
1aa3dca2c6 update 2024-08-07 11:20:21 +08:00
Simon Ding
f48b3c657e feat: change cache implementation 2024-08-07 11:07:10 +08:00
Simon Ding
d8d570f1b2 feat: change db 2024-08-07 10:46:30 +08:00
Simon Ding
bd385d4f85 feat: add simple cache, due to jackett poor performance 2024-08-07 10:42:12 +08:00
Simon Ding
466596345d feat: edit media details 2024-08-06 23:00:56 +08:00
Simon Ding
8ab33f3d54 ui refactor 2024-08-04 10:54:47 +08:00
Simon Ding
4d3b26135c fix: ui alignment 2024-08-04 10:22:47 +08:00
Simon Ding
56d5cdb2bf refactor ui resource list 2024-08-03 23:05:17 +08:00
Simon Ding
6f80da779b fix: download client id 2024-08-03 17:12:20 +08:00
Simon Ding
5fef156052 fix: indexid 2024-08-03 17:10:49 +08:00
Simon Ding
eab3a6ca2b try fix seed ratio 2024-08-03 16:47:58 +08:00
Simon Ding
ffa5c37c4c fix: name matching 2024-08-03 15:03:47 +08:00
Simon Ding
241e30152b feat: file size limiter 2024-08-03 12:31:53 +08:00
Simon Ding
16216fcc4f feat: change single episode monitoring status 2024-08-03 10:46:52 +08:00
Simon Ding
578b6a9d78 feat: proxy only affects tmdb 2024-08-03 09:54:23 +08:00
Simon Ding
f4da80c845 add testcases & add parse condition 2024-08-02 21:04:34 +08:00
Simon Ding
5a9acd3e6e ui: improve tv display 2024-08-02 19:10:53 +08:00
Simon Ding
8bfa8f84b9 fix monitor 2024-08-02 14:56:14 +08:00
Simon Ding
5b0b2ce5b0 fix: status 2024-08-02 14:39:01 +08:00
Simon Ding
b24c1a1501 ui: add monitored field 2024-08-02 14:06:44 +08:00
Simon Ding
aa320c6dcb fix: monitored 2024-08-02 13:06:38 +08:00
Simon Ding
5132714247 feat: change method to monitor episodes 2024-08-02 12:52:54 +08:00
Simon Ding
3aeecac4fb updates 2024-08-02 12:19:53 +08:00
Simon Ding
7f8c613a65 fix number formats 2024-08-02 11:14:21 +08:00
Simon Ding
c787d71fbd code refactor 2024-08-02 10:08:26 +08:00
Simon Ding
c28e16805e fix: empty list 2024-08-01 20:34:23 +08:00
Simon Ding
fc3d3878bc feat: disable indexer 2024-08-01 20:12:42 +08:00
Simon Ding
e26e86a63f feat: implement seed ratio check logic 2024-08-01 19:52:40 +08:00
Simon Ding
408ff163ef feat: improve support for pt 2024-08-01 19:12:14 +08:00
Simon Ding
35d299b60c feat: improve indexer setting 2024-08-01 17:36:40 +08:00
Simon Ding
6e002b1198 fix: add defaults 2024-08-01 13:05:05 +08:00
Simon Ding
7508a264a6 chore: ci update 2024-08-01 09:42:37 +08:00
Simon Ding
0022c9dad5 fix: umask 2024-08-01 09:39:38 +08:00
Simon Ding
654d8b50b4 chore: add more screenshot 2024-08-01 09:23:13 +08:00
Simon Ding
97ede5d9c9 feat: add badges 2024-08-01 00:01:55 +08:00
Simon Ding
4803567818 fix: remove attestations 2024-07-31 23:43:07 +08:00
Simon Ding
4e0014cb3f fix: sha256 tags in repo 2024-07-31 23:41:58 +08:00
Simon Ding
c256d46d5c test ci 2024-07-31 23:11:55 +08:00
Simon Ding
b765f16ea6 chore: updates 2024-07-31 20:59:40 +08:00
Simon Ding
9350e376f4 fix 2024-07-31 17:50:37 +08:00
Simon Ding
06f935871a chore: improve ui & fix 2024-07-31 17:43:42 +08:00
Simon Ding
001b850d8f feat: add imdbid to .plexmatch file 2024-07-31 17:01:50 +08:00
Simon Ding
1340305f2d feat: change progress display 2024-07-31 16:55:01 +08:00
Simon Ding
b337e40fcc feat: change name suggestting 2024-07-31 16:23:22 +08:00
Simon Ding
e94386e455 chore: better text display 2024-07-31 15:45:49 +08:00
Simon Ding
2b4fb99c89 chore: improve ui 2024-07-31 15:40:24 +08:00
Simon Ding
faa603d5df code refactor & improve search page 2024-07-31 15:26:34 +08:00
Simon Ding
9ba59a7d5a refactor code 2024-07-31 14:41:57 +08:00
Simon Ding
0ea1c040a2 chore: optimize log 2024-07-30 22:56:17 +08:00
Simon Ding
eba646f5db chore: delete not exist tasks 2024-07-30 22:11:41 +08:00
Simon Ding
ebcc0c32da fix: panic 2024-07-30 22:10:18 +08:00
Simon Ding
769f217506 feat: add option to control whether to deleted task 2024-07-30 21:55:54 +08:00
Simon Ding
3525d1bb83 feat: try hard link first 2024-07-30 21:15:35 +08:00
Simon Ding
2c3fd89f2a fix: plexmatch 2024-07-30 20:56:44 +08:00
Simon Ding
19ab8c65de chore: fixes 2024-07-30 20:37:42 +08:00
Simon Ding
979218f615 feat: season plexmatch file 2024-07-30 20:01:41 +08:00
Simon Ding
d4dd2da335 set umask to 0011 2024-07-30 19:22:17 +08:00
Simon Ding
000717fcd9 fix plexmatch 2024-07-30 17:22:28 +08:00
Simon Ding
300f9a478b chore: update readme 2024-07-30 16:35:59 +08:00
Simon Ding
88a554b186 fix: local storage dir 2024-07-30 16:12:10 +08:00
Simon Ding
6ef4bedebe feat: support generate .plexmatch 2024-07-30 15:51:54 +08:00
Simon Ding
233970ef39 feat: display loading animation 2024-07-30 14:02:24 +08:00
Simon Ding
e2bba8ec71 fix: target dir 2024-07-30 11:49:42 +08:00
Simon Ding
b7aeb9c3c6 fix: create file permission 2024-07-30 11:27:06 +08:00
Simon Ding
4a93d51fdc fix: chinese naming 2024-07-30 11:16:51 +08:00
Simon Ding
f158b74be6 fix: movie suggested naming 2024-07-30 11:11:07 +08:00
Simon Ding
2c8c715540 feat: movie also requires suggested dir 2024-07-30 10:50:40 +08:00
Simon Ding
ba532d406a feat: default to html render 2024-07-30 10:08:21 +08:00
Simon Ding
cff093ca98 fix: use root user, for now 2024-07-29 22:12:05 +08:00
Simon Ding
8f677b29a7 chore: change cron 2024-07-29 19:48:05 +08:00
Simon Ding
e08c126af2 feat: add bark push notification 2024-07-29 18:06:32 +08:00
Simon Ding
eed72c5eb9 refactor: settings page 2024-07-29 16:34:32 +08:00
Simon Ding
fcff47041a feat: support push notification clients 2024-07-29 15:56:29 +08:00
Simon Ding
f9d4f851eb feat: no animation 2024-07-29 10:45:31 +08:00
Simon Ding
262baf769f feat: fade route transition and fixes 2024-07-29 09:21:11 +08:00
Simon Ding
6ef2e5b347 feat: offline support 2024-07-28 21:28:29 +08:00
Simon Ding
e0e11b70bb fix: add movie download 2024-07-28 19:30:06 +08:00
Simon Ding
3de2f89107 feat: use cookie to store jwt token, better performance 2024-07-28 18:07:24 +08:00
Simon Ding
b024b5f6dc feat: add default download client 2024-07-28 17:19:05 +08:00
Simon Ding
961d762f35 feat: add text to empty screen 2024-07-28 16:43:59 +08:00
Simon Ding
7f025a6246 fix: bugs 2024-07-28 15:54:51 +08:00
Simon Ding
fc86a441f4 feat: option to download all episodes 2024-07-28 13:22:12 +08:00
Simon Ding
34fa05e7dd fix: var 2024-07-28 12:31:22 +08:00
Simon Ding
9c3757a1bf feat: season package list 2024-07-28 11:50:58 +08:00
Simon Ding
e63a899df5 chore: remove unused code 2024-07-28 11:13:26 +08:00
Simon Ding
3a4e303d9d feat: log to console in dev 2024-07-28 11:08:17 +08:00
Simon Ding
ef9e4487c6 fix: class to dart3 record 2024-07-28 11:04:51 +08:00
Simon Ding
02f6cfb5b7 fix 2024-07-27 23:42:28 +08:00
Simon Ding
e73ae86801 add parse tv & movie api 2024-07-27 23:42:06 +08:00
Simon Ding
b19938f2df remove 2024-07-27 22:42:29 +08:00
Simon Ding
bb3c4551af fix: api call 2024-07-27 22:35:49 +08:00
Simon Ding
eae35ce862 feat: show episode resource 2024-07-27 22:22:06 +08:00
Simon Ding
feecc9f983 feat: app proxy 2024-07-27 17:18:38 +08:00
Simon Ding
5175e651ee fix: donot use git shallow copy 2024-07-27 16:04:01 +08:00
Simon Ding
f065abfbf9 fix: install git 2024-07-27 15:55:08 +08:00
Simon Ding
cd4d600f5e feat: add app version ui 2024-07-27 15:44:49 +08:00
Simon Ding
741a4024fd feat: add app version 2024-07-27 15:34:58 +08:00
Simon Ding
0433cc7b0a chore: update doc 2024-07-27 11:24:22 +08:00
Simon Ding
accc02c74c chore: update doc 2024-07-27 11:21:34 +08:00
Simon Ding
87b6c99f1f feat: better doc 2024-07-27 11:17:16 +08:00
Simon Ding
b2a092c64e feat: add get all torrents api 2024-07-27 09:26:51 +08:00
Simon Ding
51fc5c3c74 chore: fix typo 2024-07-27 00:08:46 +08:00
Simon Ding
5e6a17f86c change padding 2024-07-27 00:06:18 +08:00
Simon Ding
2fedfd6c76 fix: not display error 2024-07-26 23:56:29 +08:00
Simon Ding
61bc9b72bd feat: disable webgl2 on safari 2024-07-26 23:26:14 +08:00
Simon Ding
a997726a5f feat: size readable 2024-07-26 17:13:43 +08:00
Simon Ding
7a2c67af04 main page 2024-07-26 17:07:36 +08:00
Simon Ding
3698170d0b chore: update main page 2024-07-26 17:03:08 +08:00
Simon Ding
6c38db5248 chore: upper case log level 2024-07-26 17:00:43 +08:00
Simon Ding
b597edab8a feat: add system page 2024-07-26 16:59:33 +08:00
Simon Ding
2e3b67dfce fix: db init 2024-07-26 14:28:58 +08:00
Simon Ding
1dd61ccbca feat: add log level setting 2024-07-26 14:22:08 +08:00
Simon Ding
f5f8434832 feat: support log rotation 2024-07-26 13:59:10 +08:00
Simon Ding
2cb6a15c0b feat: movie ignore sound tracks 2024-07-26 13:45:25 +08:00
Simon Ding
317f5655b8 chore: add space vertical 2024-07-26 13:33:24 +08:00
Simon Ding
00506df5a1 change image width 2024-07-26 13:12:40 +08:00
Simon Ding
57de442eb9 feat: simple tv & movie status 2024-07-26 13:07:54 +08:00
Simon Ding
690ce272c2 chore: change ui 2024-07-26 12:54:37 +08:00
Simon Ding
6a9f63fff6 feat: add movie status to ui 2024-07-26 12:25:23 +08:00
Simon Ding
7b9b619de6 add log 2024-07-25 20:44:04 +08:00
Simon Ding
8bc9076d90 fix: debug level default 2024-07-25 20:34:43 +08:00
Simon Ding
891be34504 feat: log to file 2024-07-25 20:28:13 +08:00
Simon Ding
04df9adfdf feat: change task scheduler 2024-07-25 15:35:44 +08:00
Simon Ding
3c47eba618 feat: add default timezone 2024-07-25 14:52:34 +08:00
Simon Ding
e85bd231c9 feat: add source field 2024-07-25 14:43:45 +08:00
Simon Ding
58e65b21fb feat: check connect before add download client 2024-07-25 14:19:03 +08:00
Simon Ding
520933085d fix: remove url check 2024-07-25 14:09:58 +08:00
Simon Ding
5cc88986d2 feat: better form 2024-07-25 14:02:47 +08:00
Simon Ding
d63a923589 feat: not allow empty fields 2024-07-25 11:16:31 +08:00
Simon Ding
bca68befb1 fix: name not exist 2024-07-25 10:58:58 +08:00
Simon Ding
1be44bff9e fix: add storage 2024-07-25 10:38:37 +08:00
Simon Ding
3998270cbd feat: check new season every 12h 2024-07-25 09:44:02 +08:00
Simon Ding
73e76c2185 feat: change logic 2024-07-25 08:43:49 +08:00
Simon Ding
c72a460509 update 2024-07-25 01:09:44 +08:00
Simon Ding
912293d8e8 feat: match anime that only rely on episode number 2024-07-25 01:07:24 +08:00
Simon Ding
7f2e84ad52 feat: no need auto dispose 2024-07-25 00:36:55 +08:00
Simon Ding
e52ad612c1 fix: extra spaces 2024-07-25 00:11:15 +08:00
Simon Ding
45a212fec5 feat: add msg 2024-07-24 23:51:20 +08:00
Simon Ding
39bfda4cda feat: remove unicode hindden char 2024-07-24 23:11:45 +08:00
Simon Ding
24a4d3152d fix: condition mismatch 2024-07-24 22:47:25 +08:00
Simon Ding
6c6670a8c0 fix name match 2024-07-24 22:35:50 +08:00
Simon Ding
63fc4f277b feat: better episode matching 2024-07-24 22:26:25 +08:00
Simon Ding
45d2a4fb79 feat: better name parser 2024-07-24 22:15:59 +08:00
Simon Ding
5e337871c9 fix: finding season pack 2024-07-24 21:57:50 +08:00
Simon Ding
803dcfeacd fix: replace strings 2024-07-24 21:48:14 +08:00
Simon Ding
c26e61bbee fix: incase name not submitted 2024-07-24 21:35:59 +08:00
Simon Ding
e334acba32 feat: submit all torrent info to server 2024-07-24 21:24:36 +08:00
Simon Ding
1359df599b feat: follow jackett redirect to get real link 2024-07-24 19:30:24 +08:00
Simon Ding
16ca00d19c fix: name cannot parsed 2024-07-24 18:35:01 +08:00
Simon Ding
f4b8d03cfc add log 2024-07-24 18:18:48 +08:00
Simon Ding
8811b89889 fix local storage 2024-07-24 18:12:11 +08:00
Simon Ding
daff2cfcfc feat: telegram chat 2024-07-24 17:13:23 +08:00
Simon Ding
79ec63bfdb feat: test webdav 2024-07-24 16:43:20 +08:00
Simon Ding
bd0ada5897 chore: remove useless logs 2024-07-24 15:57:39 +08:00
Simon Ding
a7dfa2d0f0 feat: fetch torznab results cocurrently 2024-07-24 15:55:33 +08:00
Simon Ding
33f0a5b53f fix: revert main 2024-07-24 15:23:27 +08:00
Simon Ding
1878d6b679 feat: japan anime support 2024-07-24 15:21:48 +08:00
Simon Ding
627f838ab9 feat: null operation 2024-07-23 22:34:45 +08:00
Simon Ding
215511fab0 remove log 2024-07-23 22:25:46 +08:00
Simon Ding
730db5c94a feat: seperate active and archived activities 2024-07-23 22:22:53 +08:00
Simon Ding
55f5ce329c feat: do not return error when no resource 2024-07-23 21:27:06 +08:00
Simon Ding
5b2d86d301 fix: cn name 2024-07-23 21:17:54 +08:00
Simon Ding
95708a4c0c fix: chinese name 2024-07-23 21:15:54 +08:00
Simon Ding
c41b3026df fix: airdate is null 2024-07-23 20:56:04 +08:00
Simon Ding
fa84f881a4 feat: do not download episode aired more than 24h 2024-07-23 20:52:07 +08:00
Simon Ding
90ac4cddff fix: no overview 2024-07-23 20:35:46 +08:00
Simon Ding
2c5e4d0530 feat: better readable text when no resources 2024-07-23 20:24:14 +08:00
Simon Ding
fb638dff8b fix: download dir 2024-07-23 19:50:50 +08:00
Simon Ding
11f7b51eb5 add movie download history 2024-07-23 19:01:24 +08:00
Simon Ding
d2439480c8 update redame 2024-07-23 15:49:48 +08:00
312 changed files with 35609 additions and 4647 deletions

11
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

View File

@@ -17,14 +17,11 @@ jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to image repository
uses: docker/login-action@v2
@@ -32,6 +29,19 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3
- name: Build Web
run: |
cd ui
flutter pub get
flutter build web --no-web-resources-cdn --wasm --release
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
@@ -43,15 +53,11 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
file: ./docker/Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TMDB_API_KEY=${{ secrets.TMDB_API_KEY }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

51
.github/workflows/goreleaser.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
name: goreleaser
on:
workflow_dispatch:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3
- name: Build Web
run: |
cd ui
flutter pub get
flutter build web --no-web-resources-cdn
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '>=1.23.0'
check-latest: true
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: '~> v2'
args: release --clean --skip=validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TMDB_API_KEY: ${{ secrets.TMDB_API_KEY }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

View File

@@ -22,6 +22,8 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
@@ -35,28 +37,41 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3
- name: Build Web
run: |
cd ui
flutter pub get
flutter build web --no-web-resources-cdn --wasm --release
- name: Build and push
id: push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
file: ./docker/Dockerfile
push: true
platforms: |
linux/amd64
linux/arm64
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TMDB_API_KEY=${{ secrets.TMDB_API_KEY }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
push-to-registry: false

3
.gitignore vendored
View File

@@ -11,7 +11,6 @@ config.yml
.idea/
.DS_Store
*.db
data/
ui/node_modules/
ui/dist/
@@ -30,3 +29,5 @@ ui/dist/
# Go workspace file
go.work
go.work.sum
dist/

67
.goreleaser.yaml Normal file
View File

@@ -0,0 +1,67 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: 2
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
#- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
main: ./cmd/polaris
ldflags:
- -X polaris/db.Version={{ .Summary }} -X polaris/db.DefaultTmdbApiKey={{ .Env.TMDB_API_KEY }}
goarch:
- amd64
- arm64
- arm
goarm:
- 7
ignore:
- goos: darwin
goarch: arm
- goos: windows
goarch: arm
archives:
- formats: [tar.gz]
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
formats: [zip]
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
release:
footer: >-
---
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).

View File

@@ -1,37 +0,0 @@
FROM instrumentisto/flutter:3 AS flutter
WORKDIR /app
COPY ./ui/pubspec.yaml ./ui/pubspec.lock ./
RUN flutter pub get
COPY ./ui/ ./
RUN flutter build web
# 打包依赖阶段使用golang作为基础镜像
FROM golang:1.22 as builder
# 启用go module
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
COPY --from=flutter /app/build/web ./ui/build/web/
# 指定OS等并go build
RUN CGO_ENABLED=1 go build -o polaris ./cmd/
FROM debian:12
WORKDIR /app
RUN apt-get update && apt-get -y install ca-certificates
# 将上一个阶段publish文件夹下的所有文件复制进来
COPY --from=builder /app/polaris .
EXPOSE 8080
ENTRYPOINT ["./polaris"]

12
Makefile Normal file
View File

@@ -0,0 +1,12 @@
.PHONY: windows
VERSION=$(shell git describe --tags --long)
windows:
@echo "Building for Windows..."
go build -tags lib -ldflags="-X polaris/db.Version=$(git describe --tags --long)" -buildmode=c-shared -o ui/windows/libpolaris.dll ./cmd/binding
cd ui && flutter build windows
polaris-web:
@echo "Building..."
CGO_ENABLED=0 go build -o polaris -ldflags="-X polaris/db.Version=$(VERSION) -X polaris/db.DefaultTmdbApiKey=$(TMDB_API_KEY)" ./cmd/polaris

147
README.md
View File

@@ -1,97 +1,100 @@
# polaris
Polaris 是一个电视剧和电影的追踪软件。配置好了之后当剧集或者电影播出后会第一时间下载对应的资源。支持本地存储或者webdav。
![main_page](./doc/assets/main_page.png)
![main_page](assets/main_page.png)
![detail_page](assets/detail_page.png)
## 功能
<h1 align="center">Polaris</h1>
- [x] 电视剧自动追踪下载
- [x] 电影自动追踪下载
- [x] webdav 存储支持,配合 [alist](https://github.com/alist-org/alist) 或阿里云等实现更多功能
<div align="center">
## 对比 sonarr/radarr
* 更好的中文支持
* 支持 webdav 后端存储,可以配合 alist 或者阿里云来实现下载后实时传到云上的功能。这样外出就可以不依靠家里的宽带来看电影了,或者实现个轻 NAS 功能,下载功能放在本地,数据放在云盘
* golang 实现后端,相比于 .NET 更节省资源
* 一个程序同时实现了电影、电视剧功能,不需要装两个程序
* 当然 sonarr/radarr 也是非常优秀的开源项目,目前 Polaris 功能还没有 sonarr/radarr 丰富
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/simon-ding/polaris/go.yml)
![GitHub Release](https://img.shields.io/github/v/release/simon-ding/polaris)
![GitHub Repo stars](https://img.shields.io/github/stars/simon-ding/polaris)
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/simon-ding/polaris)
**Polaris 是一个电视剧和电影的追踪下载软件。对美剧动漫日剧都有良好的匹配支持多种存储方式webdav、alist、本地存储**
</div>
交流群: https://t.me/+8R2nzrlSs2JhMDgx
## 快速开始
最简单部署 Polaris 的方式是使用 docker compose
若要体验请确保本机有docker环境然后执行
```yaml
services:
polaris:
image: ghcr.io/simon-ding/polaris:latest
restart: always
volumes:
- ./config/polaris:/app/data #程序配置文件路径
- /downloads:/downloads #下载路径,需要和下载客户端配置一致
- /data:/data #媒体数据存储路径也可以启动自己配置webdav存储
ports:
- 8080:8080
jackett: #资源提供者,也可以不安装使用已有的
image: lscr.io/linuxserver/jackett:latest
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai
- AUTO_UPDATE=false
volumes:
- ./config/jackett:/config
ports:
- 9117:9117
restart: always
transmission: #下载客户端,也可以不安装使用已有的
image: lscr.io/linuxserver/transmission:latest
container_name: transmission
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai
volumes:
- ./config/transmission:/config
- /downloads:/downloads #此路径要与polaris下载路径保持一致
ports:
- 9091:9091
- 51413:51413
- 51413:51413/udp
```bash
docker run -p 8080:8080 ghcr.io/simon-ding/polaris:latest
```
随后访问 http://127.0.0.1:8080 即可快速体验Polaris的功能
拉起之后访问 http://< ip >:8080 的形式访问
正式部署请参考 [【快速开始】](./doc/quick_start.md)
## 配置
## Features
要正确使用此程序,需要配置好以下设置:
- [x] 电视剧自动追踪下载
- [x] 电影自动追踪下载
- [x] 本地、webdav、 [alist](https://github.com/alist-org/alist) 存储支持,使用 alist 存储支持秒传功能
- [x] 事件通知推送,目前支持 Pushover和 Bark还在扩充中
- [x] TMDB 代理支持
- [x] 用户认证
- [x] plex 刮削支持
- [x] NFO 刮削文件支持
- [x] BT/PT 支持
- [x] qbittorrent/transmission客户端支持
- [x] 支持导入plex watchlistplex里标记自动导入polaris
- [x] and more...
### TMDB设置
因为此程序需要使用到 TMDB 的数据,使用此程序首先要申请一个 TMDB 的 Api Key
## 支持的平台
### 索引器
- linux/amd64
- linux/arm64
- linux/arm/v7
- linux/386
- linux/s390x
- linux/ppc64le
索引器是资源提供者,目前支持 torznab 协议,意味着 polarr 或者 jackett 都可以支持。请自行部署相关程序。
## FAQ
推荐使用 linuxserver 的镜像https://docs.linuxserver.io/images/docker-jackett/
- [常见问题 FAQ](./doc/faq.md)
### 下载器
资源由谁下载,目前可支持 tansmission需要配置好对应下载器
### 存储设置
程序默认所有剧集和电影存储在 /data 路径下如果想修改路径或者webdav存储需要在存储配置下修改
## 开始使用
配置完了这些,开始享受使用此程序吧!可以搜索几部自己想看的电影或者电视机,加入想看列表。当剧集有更新或者电影有资源是就会自动下载对应资源了。
## Todos
- [ ] 更多通知客户端支持
- [ ] 更多第三方watchlist导入支持
- [ ] 手机客户端
## 截图
![main_page](./doc/assets/main_page.png)
![detail_page](./doc/assets/detail_page.png)
![anime](./doc/assets/anime_match.png)
## 运行原理
Polaris本身不提供任何资源要使其能正常工作需要同时安装一个下载客户端transmission和一个索引客户端jackett
Polaris通过索引客户端查询相关的BT/PT站点然后把查到的资源送到下载器等待下载器下载完成对应资源。下载完成后根据下载的对应资源整理到对应的文件夹里去
![](./doc/assets/yuanli.png)
<!-- ## 对比 sonarr/radarr
* 更好的中文支持
* 对于动漫、日剧的良好支持,配合国内站点基本能匹配上对应资源
* 支持 webdav 后端存储,可以配合 alist 或者阿里云来实现下载后实时传到云上的功能。这样外出就可以不依靠家里的宽带来看电影了,或者实现个轻 NAS 功能,下载功能放在本地,数据放在云盘
* golang 实现后端,相比于 .NET 更节省资源
* 一个程序同时实现了电影、电视剧功能,不需要装两个程序
* 当然 sonarr/radarr 也是非常优秀的开源项目,目前 Polaris 功能还没有 sonarr/radarr 丰富 -->
## Stargazers over time
[![Stargazers over time](https://starchart.cc/simon-ding/polaris.svg?variant=adaptive)](https://starchart.cc/simon-ding/polaris)
-------------
## 请我喝杯咖啡
<img src="assets/wechat.JPG" width=40% height=40%>
<img src="./doc/assets/wechat.JPG" width=40% height=40%>

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

46
cmd/binding/main.go Normal file
View File

@@ -0,0 +1,46 @@
package main
import "C"
import (
"polaris/db"
"polaris/log"
"polaris/server"
)
func main() {}
var srv *server.Server
var port int
//export Start
func Start() (C.int, *C.char) {
if srv != nil {
return C.int(port), nil
}
log.InitLogger(true)
log.Infof("------------------- Starting Polaris ---------------------")
dbClient, err := db.Open()
if err != nil {
log.Panicf("init db error: %v", err)
return C.int(0), C.CString(err.Error())
}
s := server.NewServer(dbClient)
if p, err := s.Start(""); err != nil {
return C.int(0), C.CString(err.Error())
} else {
port = p
srv = s
return C.int(p), C.CString("")
}
}
//export Stop
func Stop() {
if srv != nil {
srv.Stop()
}
srv = nil
}

1
cmd/doc.go Normal file
View File

@@ -0,0 +1 @@
package cmd

View File

@@ -1,19 +0,0 @@
package main
import (
"polaris/db"
"polaris/log"
"polaris/server"
)
func main() {
dbClient, err := db.Open()
if err != nil {
log.Panicf("init db error: %v", err)
}
s := server.NewServer(dbClient)
if err := s.Serve(); err != nil {
log.Errorf("server start error: %v", err)
}
}

35
cmd/polaris/polaris.go Normal file
View File

@@ -0,0 +1,35 @@
package main
import (
"flag"
"fmt"
"os"
"polaris/db"
"polaris/log"
"polaris/pkg/utils"
"polaris/server"
)
func main() {
port := flag.Int("port", 3322, "port to listen on")
flag.Parse()
if os.Getenv("GIN_MODE") == "release" {
log.InitLogger(true)
}
log.Infof("------------------- Starting Polaris ---------------------")
dbClient, err := db.Open()
if err != nil {
log.Panicf("init db error: %v", err)
}
if !utils.IsRunningInDocker() {
go utils.OpenURL(fmt.Sprintf("http://127.0.0.1:%d", *port))
}
s := server.NewServer(dbClient)
if _, err := s.Start(fmt.Sprintf(":%d", *port)); err != nil {
log.Errorf("server start error: %v", err)
}
select {} //wait indefinitely
}

View File

@@ -1,23 +1,51 @@
package db
import (
"polaris/ent/media"
"polaris/pkg/utils"
)
var (
Version = "undefined"
DefaultTmdbApiKey = ""
)
const (
SettingTmdbApiKey = "tmdb_api_key"
SettingLanguage = "language"
SettingJacketUrl = "jacket_url"
SettingJacketApiKey = "jacket_api_key"
SettingDownloadDir = "download_dir"
SettingTmdbApiKey = "tmdb_api_key"
SettingLanguage = "language"
SettingJacketUrl = "jacket_url"
SettingJacketApiKey = "jacket_api_key"
SettingDownloadDir = "download_dir"
SettingLogLevel = "log_level"
SettingProxy = "proxy"
SettingPlexMatchEnabled = "plexmatch_enabled"
SettingNfoSupportEnabled = "nfo_support_enabled"
SettingAllowQiangban = "filter_qiangban"
SettingEnableTmdbAdultContent = "tmdb_adult_content"
SettingTvNamingFormat = "tv_naming_format"
SettingMovieNamingFormat = "movie_naming_format"
SettingProwlarrInfo = "prowlarr_info"
SettingTvSizeLimiter = "tv_size_limiter"
SettingMovieSizeLimiter = "movie_size_limiter"
SettingAcceptedVideoFormats = "accepted_video_formats"
SettingAcceptedSubtitleFormats = "accepted_subtitle_formats"
)
const (
SettingAuthEnabled = "auth_enbled"
SettingUsername = "auth_username"
SettingPassword = "auth_password"
SettingUsername = "auth_username"
SettingPassword = "auth_password"
)
const (
IndexerTorznabImpl = "torznab"
DataPath = "./data"
ImgPath = DataPath + "/img"
)
var (
DataPath = utils.GetUserDataDir()
ImgPath = DataPath + "/img"
LogPath = DataPath + "/logs"
)
const (
@@ -25,18 +53,56 @@ const (
LanguageCN = "zh-CN"
)
type ResolutionType string
const DefaultNamingFormat = "{{.NameCN}} {{.NameEN}} {{if .Year}} ({{.Year}}) {{end}}"
const (
Any ResolutionType = "any"
R720p ResolutionType = "720p"
R1080p ResolutionType = "1080p"
R4k ResolutionType = "4k"
)
func (r ResolutionType) String() string {
return string(r)
// https://en.wikipedia.org/wiki/Video_file_format
var defaultAcceptedVideoFormats = []string{
".webm", ".mkv", ".flv", ".vob", ".ogv", ".ogg", ".drc", ".mng", ".avi", ".mts", ".m2ts", ".ts",
".mov", ".qt", ".wmv", ".yuv", ".rm", ".rmvb", ".viv", ".amv", ".mp4", ".m4p", ".m4v",
".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".m2v", ".m4v",
".svi", ".3gp", ".3g2", ".nsv",
}
var defaultAcceptedSubtitleFormats = []string{
".ass", ".srt", ".vtt", ".webvtt", ".sub", ".idx",
}
const JwtSerectKey = "jwt_secrect_key"
type NamingInfo struct {
NameCN string
NameEN string
Year string
TmdbID int
}
type ResolutionType string
const JwtSerectKey = "jwt_secrect_key"
type MediaSizeLimiter struct {
P720p SizeLimiter `json:"720p"`
P1080 SizeLimiter `json:"1080p"`
P2160 SizeLimiter `json:"2160p"`
}
func (m *MediaSizeLimiter) GetLimiter(r media.Resolution) SizeLimiter {
if r == media.Resolution1080p {
return m.P1080
} else if r == media.Resolution720p {
return m.P720p
} else if r == media.Resolution2160p {
return m.P2160
}
return SizeLimiter{}
}
type SizeLimiter struct {
MaxSIze int64 `json:"max_size"`
MinSize int64 `json:"min_size"`
PreferSIze int64 `json:"prefer_size"`
}
type ProwlarrSetting struct {
Disabled bool `json:"disabled"`
ApiKey string `json:"api_key"`
URL string `json:"url"`
}

624
db/db.go
View File

@@ -6,47 +6,80 @@ import (
"fmt"
"os"
"polaris/ent"
"polaris/ent/blacklist"
"polaris/ent/downloadclients"
"polaris/ent/episode"
"polaris/ent/history"
"polaris/ent/importlist"
"polaris/ent/indexers"
"polaris/ent/media"
"polaris/ent/schema"
"polaris/ent/settings"
"polaris/ent/storage"
"polaris/log"
"polaris/pkg/utils"
"slices"
"strings"
"time"
"database/sql"
"database/sql/driver"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
_ "github.com/mattn/go-sqlite3"
entsql "entgo.io/ent/dialect/sql"
"github.com/pkg/errors"
"modernc.org/sqlite"
)
type Client struct {
// https://github.com/ent/ent/discussions/1667#discussioncomment-1132296
type sqliteDriver struct {
*sqlite.Driver
}
func (d sqliteDriver) Open(name string) (driver.Conn, error) {
conn, err := d.Driver.Open(name)
if err != nil {
return conn, err
}
c := conn.(interface {
Exec(stmt string, args []driver.Value) (driver.Result, error)
})
if _, err := c.Exec("PRAGMA foreign_keys = on;", nil); err != nil {
conn.Close()
return nil, errors.Wrap(err, "failed to enable enable foreign keys")
}
return conn, nil
}
func init() {
sql.Register(dialect.SQLite, sqliteDriver{Driver: &sqlite.Driver{}})
}
type client struct {
ent *ent.Client
}
func Open() (*Client, error) {
func Open() (Database, error) {
os.Mkdir(DataPath, 0777)
client, err := ent.Open(dialect.SQLite, fmt.Sprintf("file:%v/polaris.db?cache=shared&_fk=1", DataPath))
cl, err := ent.Open(dialect.SQLite, fmt.Sprintf("file:%v/polaris.db?cache=shared&_fk=1", DataPath))
if err != nil {
return nil, errors.Wrap(err, "failed opening connection to sqlite")
}
//defer client.Close()
c := &client{
ent: cl,
}
// Run the auto migration tool.
if err := client.Schema.Create(context.Background()); err != nil {
return nil, errors.Wrap(err, "failed creating schema resources")
}
c := &Client{
ent: client,
if err := c.migrate(); err != nil {
return nil, errors.Wrap(err, "migrate")
}
c.init()
return c, nil
}
func (c *Client) init() {
func (c *client) init() {
c.generateJwtSerectIfNotExist()
if err := c.generateDefaultLocalStorage(); err != nil {
log.Errorf("generate default storage: %v", err)
@@ -55,11 +88,53 @@ func (c *Client) init() {
downloadDir := c.GetSetting(SettingDownloadDir)
if downloadDir == "" {
log.Infof("set default download dir")
c.SetSetting(downloadDir, "/downloads")
if utils.IsRunningInDocker() {
c.SetSetting(SettingDownloadDir, "/downloads")
} else {
downloadDir, err := utils.UserDownloadDir()
if err != nil {
log.Errorf("get user download dir error: %v", err)
downloadDir = "/downloads"
}
c.SetSetting(SettingDownloadDir, downloadDir)
}
}
logLevel := c.GetSetting(SettingLogLevel)
if logLevel == "" {
log.Infof("set default log level")
c.SetSetting(SettingLogLevel, "info")
}
c.initBuildinClient()
}
func (c *Client) generateJwtSerectIfNotExist() {
func (c *client) initBuildinClient() {
hasBuildin := false
tr := c.GetAllDonloadClients()
for _, d := range tr {
if d.Implementation == downloadclients.ImplementationBuildin {
hasBuildin = true
break
}
}
if !hasBuildin {
log.Warnf("no buildin download client, set default download client")
if err := c.SaveDownloader(&ent.DownloadClients{
Enable: true,
Name: "内建下载器",
Implementation: downloadclients.ImplementationBuildin,
URL: "buildin",
Priority1: 50,
RemoveCompletedDownloads: true,
RemoveFailedDownloads: true,
}); err != nil {
log.Warnf("add buildin client error: %v", err)
}
}
}
func (c *client) generateJwtSerectIfNotExist() {
v := c.GetSetting(JwtSerectKey)
if v == "" {
log.Infof("generate jwt serect")
@@ -68,7 +143,7 @@ func (c *Client) generateJwtSerectIfNotExist() {
}
}
func (c *Client) generateDefaultLocalStorage() error {
func (c *client) generateDefaultLocalStorage() error {
n, _ := c.ent.Storage.Query().Count(context.TODO())
if n != 0 {
return nil
@@ -77,24 +152,22 @@ func (c *Client) generateDefaultLocalStorage() error {
return c.AddStorage(&StorageInfo{
Name: "local",
Implementation: "local",
TvPath: "/data/tv/",
MoviePath: "/data/movies/",
Default: true,
Settings: map[string]string{
"tv_path": "/data/tv/",
"movie_path": "/data/movies/",
},
})
}
func (c *Client) GetSetting(key string) string {
func (c *client) GetSetting(key string) string {
v, err := c.ent.Settings.Query().Where(settings.Key(key)).Only(context.TODO())
if err != nil {
log.Errorf("get setting by key: %s error: %v", key, err)
log.Debugf("get setting by key: %s error: %v", key, err)
return ""
}
return v.Value
}
func (c *Client) SetSetting(key, value string) error {
func (c *client) SetSetting(key, value string) error {
v, err := c.ent.Settings.Query().Where(settings.Key(key)).Only(context.TODO())
if err != nil {
log.Infof("create new setting")
@@ -105,16 +178,16 @@ func (c *Client) SetSetting(key, value string) error {
return err
}
func (c *Client) GetLanguage() string {
func (c *client) GetLanguage() string {
lang := c.GetSetting(SettingLanguage)
log.Infof("get application language: %s", lang)
if lang == "" {
return "zh-CN"
return LanguageCN
}
return lang
}
func (c *Client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, error) {
func (c *client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, error) {
count := c.ent.Media.Query().Where(media.TmdbID(m.TmdbID)).CountX(context.Background())
if count > 0 {
return nil, fmt.Errorf("tv series %s already in watchlist", m.NameEn)
@@ -129,6 +202,7 @@ func (c *Client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, er
}
r, err := c.ent.Media.Create().
SetTmdbID(m.TmdbID).
SetImdbID(m.ImdbID).
SetStorageID(m.StorageID).
SetOverview(m.Overview).
SetNameCn(m.NameCn).
@@ -138,14 +212,18 @@ func (c *Client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, er
SetAirDate(m.AirDate).
SetResolution(m.Resolution).
SetTargetDir(m.TargetDir).
SetDownloadHistoryEpisodes(m.DownloadHistoryEpisodes).
SetLimiter(m.Limiter).
SetExtras(m.Extras).
SetAlternativeTitles(m.AlternativeTitles).
AddEpisodeIDs(episodes...).
Save(context.TODO())
return r, err
}
func (c *Client) GetMediaWatchlist(mediaType media.MediaType) []*ent.Media {
list, err := c.ent.Media.Query().Where(media.MediaTypeEQ(mediaType)).All(context.TODO())
func (c *client) GetMediaWatchlist(mediaType media.MediaType) []*ent.Media {
list, err := c.ent.Media.Query().Where(media.MediaTypeEQ(mediaType)).Order(ent.Desc(media.FieldID)).All(context.TODO())
if err != nil {
log.Infof("query wtach list error: %v", err)
return nil
@@ -153,25 +231,40 @@ func (c *Client) GetMediaWatchlist(mediaType media.MediaType) []*ent.Media {
return list
}
func (c *Client) GetEpisode(seriesId, seasonNum, episodeNum int) (*ent.Episode, error) {
func (c *client) GetAllEpisodes() (ent.Episodes, error) {
ep, err := c.ent.Episode.Query().All(context.TODO())
return ep, err
}
func (c *client) DeleteEpisode(ids ...int) error {
_, err := c.ent.Episode.Delete().Where(episode.IDIn(ids...)).Exec(context.TODO())
return err
}
func (c *client) GetEpisode(seriesId, seasonNum, episodeNum int) (*ent.Episode, error) {
return c.ent.Episode.Query().Where(episode.MediaID(seriesId), episode.SeasonNumber(seasonNum),
episode.EpisodeNumber(episodeNum)).First(context.TODO())
}
func (c *client) GetEpisodeByID(epID int) (*ent.Episode, error) {
return c.ent.Episode.Query().Where(episode.ID(epID)).First(context.TODO())
}
func (c *Client) UpdateEpiode(episodeId int, name, overview string) error {
func (c *client) UpdateEpiode(episodeId int, name, overview string) error {
return c.ent.Episode.Update().Where(episode.ID(episodeId)).SetTitle(name).SetOverview(overview).Exec(context.TODO())
}
func (c *client) UpdateEpiode2(episodeId int, name, overview, airdate string) error {
return c.ent.Episode.Update().Where(episode.ID(episodeId)).SetTitle(name).SetOverview(overview).SetAirDate(airdate).Exec(context.TODO())
}
type MediaDetails struct {
*ent.Media
Episodes []*ent.Episode `json:"episodes"`
}
func (c *Client) GetMediaDetails(id int) *MediaDetails {
func (c *client) GetMediaDetails(id int) (*MediaDetails, error) {
se, err := c.ent.Media.Query().Where(media.ID(id)).First(context.TODO())
if err != nil {
log.Errorf("get series %d: %v", id, err)
return nil
return nil, errors.Errorf("get series %d: %v", id, err)
}
var md = &MediaDetails{
Media: se,
@@ -179,29 +272,52 @@ func (c *Client) GetMediaDetails(id int) *MediaDetails {
ep, err := se.QueryEpisodes().All(context.Background())
if err != nil {
log.Errorf("get episodes %d: %v", id, err)
return nil
return nil, errors.Errorf("get episodes %d: %v", id, err)
}
md.Episodes = ep
return md
return md, nil
}
func (c *Client) DeleteMedia(id int) error {
func (c *client) GetMedia(id int) (*ent.Media, error) {
return c.ent.Media.Query().Where(media.ID(id)).First(context.TODO())
}
func (c *client) DeleteMedia(id int) error {
_, err := c.ent.Episode.Delete().Where(episode.MediaID(id)).Exec(context.TODO())
if err != nil {
return err
}
_, err = c.ent.Media.Delete().Where(media.ID(id)).Exec(context.TODO())
return err
if err != nil {
return err
}
return c.CleanAllDanglingEpisodes()
}
func (c *Client) SaveEposideDetail(d *ent.Episode) (int, error) {
func (c *client) SaveEposideDetail(d *ent.Episode) (int, error) {
ep, err := c.ent.Episode.Create().
SetAirDate(d.AirDate).
SetSeasonNumber(d.SeasonNumber).
SetEpisodeNumber(d.EpisodeNumber).
SetOverview(d.Overview).
SetMonitored(d.Monitored).
SetTitle(d.Title).Save(context.TODO())
if err != nil {
return 0, errors.Wrap(err, "save episode")
}
return ep.ID, nil
}
func (c *client) SaveEposideDetail2(d *ent.Episode) (int, error) {
ep, err := c.ent.Episode.Create().
SetAirDate(d.AirDate).
SetSeasonNumber(d.SeasonNumber).
SetEpisodeNumber(d.EpisodeNumber).
SetMediaID(d.MediaID).
SetStatus(d.Status).
SetOverview(d.Overview).
SetMonitored(d.Monitored).
SetTitle(d.Title).Save(context.TODO())
return ep.ID, err
@@ -212,19 +328,24 @@ type TorznabSetting struct {
ApiKey string `json:"api_key"`
}
func (c *Client) SaveTorznabInfo(name string, setting TorznabSetting) error {
data, err := json.Marshal(setting)
if err != nil {
return errors.Wrap(err, "marshal json")
}
count := c.ent.Indexers.Query().Where(indexers.Name(name)).CountX(context.TODO())
if count > 0 {
c.ent.Indexers.Update().Where(indexers.Name(name)).SetSettings(string(data)).Save(context.TODO())
return err
}
func (c *client) SaveIndexer(in *ent.Indexers) error {
_, err = c.ent.Indexers.Create().
SetName(name).SetImplementation(IndexerTorznabImpl).SetPriority(1).SetSettings(string(data)).Save(context.TODO())
count := c.ent.Indexers.Query().Where(indexers.Name(in.Name)).CountX(context.TODO())
if count > 0 {
//update setting
return c.ent.Indexers.Update().Where(indexers.Name(in.Name)).SetName(in.Name).SetImplementation(in.Implementation).
SetPriority(in.Priority).SetSeedRatio(in.SeedRatio).SetDisabled(in.Disabled).
SetTvSearch(in.TvSearch).SetMovieSearch(in.MovieSearch).SetSettings("").SetSynced(in.Synced).
SetAPIKey(in.APIKey).SetURL(in.URL).
Exec(context.Background())
}
//create new one
_, err := c.ent.Indexers.Create().
SetName(in.Name).SetImplementation(in.Implementation).SetPriority(in.Priority).SetSeedRatio(in.SeedRatio).
SetTvSearch(in.TvSearch).SetMovieSearch(in.MovieSearch).SetSettings("").SetSynced(in.Synced).
SetAPIKey(in.APIKey).SetURL(in.URL).SetDisabled(in.Disabled).Save(context.TODO())
if err != nil {
return errors.Wrap(err, "save db")
}
@@ -232,60 +353,38 @@ func (c *Client) SaveTorznabInfo(name string, setting TorznabSetting) error {
return nil
}
func (c *Client) DeleteTorznab(id int) {
func (c *client) DeleteIndexer(id int) {
c.ent.Indexers.Delete().Where(indexers.ID(id)).Exec(context.TODO())
}
type TorznabInfo struct {
ID int `json:"id"`
Name string `json:"name"`
TorznabSetting
}
func (c *Client) GetAllTorznabInfo() []*TorznabInfo {
res := c.ent.Indexers.Query().Where(indexers.Implementation(IndexerTorznabImpl)).AllX(context.TODO())
var l = make([]*TorznabInfo, 0, len(res))
for _, r := range res {
var ss TorznabSetting
err := json.Unmarshal([]byte(r.Settings), &ss)
if err != nil {
log.Errorf("unmarshal torznab %s error: %v", r.Name, err)
continue
}
l = append(l, &TorznabInfo{
ID: r.ID,
Name: r.Name,
TorznabSetting: ss,
})
func (c *client) GetIndexer(id int) (*ent.Indexers, error) {
res, err := c.ent.Indexers.Query().Where(indexers.ID(id)).First(context.TODO())
if err != nil {
return nil, err
}
return l
return res, nil
}
func (c *Client) SaveTransmission(name, url, user, password string) error {
count := c.ent.DownloadClients.Query().Where(downloadclients.Name(name)).CountX(context.TODO())
func (c *client) GetAllIndexers() []*ent.Indexers {
res := c.ent.Indexers.Query().Where(indexers.Implementation(IndexerTorznabImpl)).Order(ent.Asc(indexers.FieldID)).AllX(context.TODO())
return res
}
func (c *client) SaveDownloader(downloader *ent.DownloadClients) error {
count := c.ent.DownloadClients.Query().Where(downloadclients.Name(downloader.Name)).CountX(context.TODO())
if count != 0 {
err := c.ent.DownloadClients.Update().Where(downloadclients.Name(name)).
SetURL(url).SetUser(user).SetPassword(password).Exec(context.TODO())
err := c.ent.DownloadClients.Update().Where(downloadclients.Name(downloader.Name)).SetImplementation(downloader.Implementation).
SetURL(downloader.URL).SetUser(downloader.User).SetUseNatTraversal(downloader.UseNatTraversal).SetPassword(downloader.Password).SetPriority1(downloader.Priority1).Exec(context.TODO())
return err
}
_, err := c.ent.DownloadClients.Create().SetEnable(true).SetImplementation("transmission").
SetName(name).SetURL(url).SetUser(user).SetPassword(password).Save(context.TODO())
_, err := c.ent.DownloadClients.Create().SetEnable(true).SetImplementation(downloader.Implementation).SetUseNatTraversal(downloader.UseNatTraversal).
SetName(downloader.Name).SetURL(downloader.URL).SetUser(downloader.User).SetPriority1(downloader.Priority1).SetPassword(downloader.Password).Save(context.TODO())
return err
}
func (c *Client) GetTransmission() *ent.DownloadClients {
dc, err := c.ent.DownloadClients.Query().Where(downloadclients.Implementation("transmission")).First(context.TODO())
if err != nil {
log.Errorf("no transmission client found: %v", err)
return nil
}
return dc
}
func (c *Client) GetAllDonloadClients() []*ent.DownloadClients {
cc, err := c.ent.DownloadClients.Query().All(context.TODO())
func (c *client) GetAllDonloadClients() []*ent.DownloadClients {
cc, err := c.ent.DownloadClients.Query().Order(ent.Asc(downloadclients.FieldPriority1)).All(context.TODO())
if err != nil {
log.Errorf("no download client")
return nil
@@ -293,38 +392,59 @@ func (c *Client) GetAllDonloadClients() []*ent.DownloadClients {
return cc
}
func (c *Client) DeleteDownloadCLient(id int) {
c.ent.DownloadClients.Delete().Where(downloadclients.ID(id)).Exec(context.TODO())
func (c *client) DeleteDownloadCLient(id int) { //not delete buildin client
c.ent.DownloadClients.Delete().Where(downloadclients.ID(id), downloadclients.ImplementationNEQ(downloadclients.ImplementationBuildin)).Exec(context.TODO())
}
// Storage is the model entity for the Storage schema.
type StorageInfo struct {
Name string `json:"name"`
Implementation string `json:"implementation"`
Settings map[string]string `json:"settings"`
Name string `json:"name" binding:"required"`
Implementation string `json:"implementation" binding:"required"`
Settings map[string]string `json:"settings" binding:"required"`
TvPath string `json:"tv_path" binding:"required"`
MoviePath string `json:"movie_path" binding:"required"`
Default bool `json:"default"`
}
type LocalDirSetting struct {
TvPath string `json:"tv_path"`
MoviePath string `json:"movie_path"`
func (s *StorageInfo) ToWebDavSetting() WebdavSetting {
if s.Implementation != storage.ImplementationWebdav.String() {
panic("not webdav storage")
}
return WebdavSetting{
URL: s.Settings["url"],
User: s.Settings["user"],
Password: s.Settings["password"],
ChangeFileHash: s.Settings["change_file_hash"],
}
}
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"`
TvPath string `json:"tv_path"`
MoviePath string `json:"movie_path"`
User string `json:"user"`
Password string `json:"password"`
ChangeFileHash string `json:"change_file_hash"`
}
func (c *Client) AddStorage(st *StorageInfo) error {
if !strings.HasSuffix(st.Settings["tv_path"], "/") {
st.Settings["tv_path"] += "/"
func (c *client) AddStorage(st *StorageInfo) error {
if st.Implementation != storage.ImplementationLocal.String() { //add seperator if not local storage
if !strings.HasSuffix(st.TvPath, "/") {
st.TvPath += "/"
}
if !strings.HasSuffix(st.MoviePath, "/") {
st.MoviePath += "/"
}
}
if !strings.HasSuffix(st.Settings["movie_path"], "/") {
st.Settings["movie_path"] += "/"
if st.Settings == nil {
st.Settings = map[string]string{}
}
data, err := json.Marshal(st.Settings)
@@ -336,7 +456,7 @@ func (c *Client) AddStorage(st *StorageInfo) error {
if count > 0 {
//storage already exist, edit exist one
return c.ent.Storage.Update().Where(storage.Name(st.Name)).
SetImplementation(storage.Implementation(st.Implementation)).
SetImplementation(storage.Implementation(st.Implementation)).SetTvPath(st.TvPath).SetMoviePath(st.MoviePath).
SetSettings(string(data)).Exec(context.TODO())
}
countAll := c.ent.Storage.Query().Where(storage.Deleted(false)).CountX(context.TODO())
@@ -345,7 +465,7 @@ func (c *Client) AddStorage(st *StorageInfo) error {
st.Default = true
}
_, err = c.ent.Storage.Create().SetName(st.Name).
SetImplementation(storage.Implementation(st.Implementation)).
SetImplementation(storage.Implementation(st.Implementation)).SetTvPath(st.TvPath).SetMoviePath(st.MoviePath).
SetSettings(string(data)).SetDefault(st.Default).Save(context.TODO())
if err != nil {
return err
@@ -353,7 +473,7 @@ func (c *Client) AddStorage(st *StorageInfo) error {
return nil
}
func (c *Client) GetAllStorage() []*ent.Storage {
func (c *client) GetAllStorage() []*ent.Storage {
data, err := c.ent.Storage.Query().Where(storage.Deleted(false)).All(context.TODO())
if err != nil {
log.Errorf("get storage: %v", err)
@@ -366,17 +486,8 @@ type Storage struct {
ent.Storage
}
func (s *Storage) ToLocalSetting() LocalDirSetting {
if s.Implementation != storage.ImplementationLocal {
panic("not local storage")
}
var localSetting LocalDirSetting
json.Unmarshal([]byte(s.Settings), &localSetting)
return localSetting
}
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
@@ -384,13 +495,7 @@ func (s *Storage) ToWebDavSetting() WebdavSetting {
return webdavSetting
}
func (s *Storage) GetPath() (tvPath string, moviePath string) {
var m map[string]string
json.Unmarshal([]byte(s.Settings), &m)
return m["tv_path"], m["movie_path"]
}
func (c *Client) GetStorage(id int) *Storage {
func (c *client) GetStorage(id int) *Storage {
r, err := c.ent.Storage.Query().Where(storage.ID(id)).First(context.TODO())
if err != nil {
//use default storage
@@ -400,11 +505,11 @@ func (c *Client) GetStorage(id int) *Storage {
return &Storage{*r}
}
func (c *Client) DeleteStorage(id int) error {
func (c *client) DeleteStorage(id int) error {
return c.ent.Storage.Update().Where(storage.ID(id)).SetDeleted(true).Exec(context.TODO())
}
func (c *Client) SetDefaultStorage(id int) error {
func (c *client) SetDefaultStorage(id int) error {
err := c.ent.Storage.Update().Where(storage.ID(id)).SetDefault(true).Exec(context.TODO())
if err != nil {
return err
@@ -413,7 +518,7 @@ func (c *Client) SetDefaultStorage(id int) error {
return err
}
func (c *Client) SetDefaultStorageByName(name string) error {
func (c *client) SetDefaultStorageByName(name string) error {
err := c.ent.Storage.Update().Where(storage.Name(name)).SetDefault(true).Exec(context.TODO())
if err != nil {
return err
@@ -422,42 +527,44 @@ func (c *Client) SetDefaultStorageByName(name string) error {
return err
}
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).SetSaved(h.Saved).Save(context.TODO())
func (c *client) SaveHistoryRecord(h ent.History) (*ent.History, error) {
return c.ent.History.Create().SetMediaID(h.MediaID).SetDate(time.Now()).
SetStatus(h.Status).SetTargetDir(h.TargetDir).SetSourceTitle(h.SourceTitle).SetIndexerID(h.IndexerID).
SetDownloadClientID(h.DownloadClientID).SetSize(h.Size).SetSeasonNum(h.SeasonNum).
SetEpisodeNums(h.EpisodeNums).SetHash(h.Hash).SetLink(h.Link).Save(context.TODO())
}
func (c *Client) SetHistoryStatus(id int, status history.Status) error {
func (c *client) SetHistoryStatus(id int, status history.Status) error {
return c.ent.History.Update().Where(history.ID(id)).SetStatus(status).Exec(context.TODO())
}
func (c *Client) GetHistories() ent.Histories {
h, err := c.ent.History.Query().Order(history.ByID(sql.OrderDesc())).All(context.TODO())
func (c *client) GetHistories() ent.Histories {
h, err := c.ent.History.Query().Order(history.ByID(entsql.OrderDesc())).All(context.TODO())
if err != nil {
return nil
}
return h
}
func (c *Client) GetRunningHistories() ent.Histories {
func (c *client) GetRunningHistories() ent.Histories {
h, err := c.ent.History.Query().Where(history.Or(history.StatusEQ(history.StatusRunning),
history.StatusEQ(history.StatusUploading))).All(context.TODO())
history.StatusEQ(history.StatusUploading), history.StatusEQ(history.StatusSeeding))).All(context.TODO())
if err != nil {
return nil
}
return h
}
func (c *Client) GetHistory(id int) *ent.History {
func (c *client) GetHistory(id int) *ent.History {
return c.ent.History.Query().Where(history.ID(id)).FirstX(context.TODO())
}
func (c *Client) DeleteHistory(id int) error {
_, err := c.ent.History.Delete().Where(history.ID(id)).Exec(context.Background())
func (c *client) DeleteHistory(id int) error {
err := c.ent.History.Update().Where(history.ID(id)).SetStatus(history.StatusRemoved).Exec(context.Background())
return err
}
func (c *Client) GetDownloadDir() string {
func (c *client) GetDownloadDir() string {
r, err := c.ent.Settings.Query().Where(settings.Key(SettingDownloadDir)).First(context.TODO())
if err != nil {
return "/downloads"
@@ -465,23 +572,250 @@ func (c *Client) GetDownloadDir() string {
return r.Value
}
func (c *Client) UpdateEpisodeFile(mediaID int, seasonNum, episodeNum int, file string) error {
func (c *client) UpdateEpisodeStatus(mediaID int, seasonNum, episodeNum int) error {
ep, err := c.ent.Episode.Query().Where(episode.MediaID(mediaID)).Where(episode.EpisodeNumber(episodeNum)).
Where(episode.SeasonNumber(seasonNum)).First(context.TODO())
if err != nil {
return errors.Wrap(err, "finding episode")
}
return ep.Update().SetFileInStorage(file).SetStatus(episode.StatusDownloaded).Exec(context.TODO())
return ep.Update().SetStatus(episode.StatusDownloaded).Exec(context.TODO())
}
func (c *Client) SetEpisodeStatus(id int, status episode.Status) error {
func (c *client) SetEpisodeStatus(id int, status episode.Status) error {
return c.ent.Episode.Update().Where(episode.ID(id)).SetStatus(status).Exec(context.TODO())
}
func (c *Client) SetSeasonAllEpisodeStatus(mediaID, seasonNum int, status episode.Status) error {
func (c *client) IsEpisodeDownloadingOrDownloaded(id int) bool {
ep, _ := c.GetEpisodeByID(id)
his := c.ent.History.Query().Where(history.MediaID(ep.MediaID), history.SeasonNum(ep.SeasonNumber), history.StatusNEQ(history.StatusRemoved), history.StatusNEQ(history.StatusFail)).AllX(context.Background())
for _, h := range his {
if len(h.EpisodeNums) == 0 { //season pack download
return true
}
if slices.Contains(h.EpisodeNums, ep.EpisodeNumber) {
return true
}
}
return false
}
func (c *client) SetSeasonAllEpisodeStatus(mediaID, seasonNum int, status episode.Status) error {
return c.ent.Episode.Update().Where(episode.MediaID(mediaID), episode.SeasonNumber(seasonNum)).SetStatus(status).Exec(context.TODO())
}
func (c *Client) TmdbIdInWatchlist(tmdb_id int) bool {
func (c *client) TmdbIdInWatchlist(tmdb_id int) bool {
return c.ent.Media.Query().Where(media.TmdbID(tmdb_id)).CountX(context.TODO()) > 0
}
func (c *client) GetDownloadHistory(mediaID int) ([]*ent.History, error) {
return c.ent.History.Query().Where(history.MediaID(mediaID)).All(context.TODO())
}
func (c *client) GetMovieDummyEpisode(movieId int) (*ent.Episode, error) {
_, err := c.ent.Media.Query().Where(media.ID(movieId), media.MediaTypeEQ(media.MediaTypeMovie)).First(context.TODO())
if err != nil {
return nil, errors.Wrap(err, "get movie")
}
ep, err := c.ent.Episode.Query().Where(episode.MediaID(movieId)).First(context.TODO())
if err != nil {
return nil, errors.Wrap(err, "query episode")
}
return ep, nil
}
func (c *client) GetDownloadClient(id int) (*ent.DownloadClients, error) {
return c.ent.DownloadClients.Query().Where(downloadclients.ID(id)).First(context.Background())
}
func (c *client) SetEpisodeMonitoring(id int, b bool) error {
return c.ent.Episode.Update().Where(episode.ID(id)).SetMonitored(b).Exec(context.Background())
}
type EditMediaData struct {
ID int `json:"id"`
Resolution media.Resolution `json:"resolution"`
TargetDir string `json:"target_dir"`
Limiter schema.MediaLimiter `json:"limiter"`
}
func (c *client) EditMediaMetadata(in EditMediaData) error {
return c.ent.Media.Update().Where(media.ID(in.ID)).SetResolution(in.Resolution).SetTargetDir(in.TargetDir).SetLimiter(in.Limiter).
Exec(context.Background())
}
func (c *client) UpdateEpisodeTargetFile(id int, filename string) error {
return c.ent.Episode.Update().Where(episode.ID(id)).SetTargetFile(filename).Exec(context.Background())
}
func (c *client) GetSeasonEpisodes(mediaId, seasonNum int) ([]*ent.Episode, error) {
return c.ent.Episode.Query().Where(episode.MediaID(mediaId), episode.SeasonNumber(seasonNum)).All(context.Background())
}
func (c *client) GetAllImportLists() ([]*ent.ImportList, error) {
return c.ent.ImportList.Query().All(context.Background())
}
func (c *client) AddImportlist(il *ent.ImportList) error {
count, err := c.ent.ImportList.Query().Where(importlist.Name(il.Name)).Count(context.Background())
if err != nil {
return err
}
if count > 0 {
//edit exist record
return c.ent.ImportList.Update().Where(importlist.Name(il.Name)).
SetURL(il.URL).SetQulity(il.Qulity).SetType(il.Type).SetStorageID(il.StorageID).Exec(context.Background())
}
return c.ent.ImportList.Create().SetName(il.Name).SetURL(il.URL).SetQulity(il.Qulity).SetStorageID(il.StorageID).
SetType(il.Type).Exec(context.Background())
}
func (c *client) DeleteImportlist(id int) error {
return c.ent.ImportList.DeleteOneID(id).Exec(context.TODO())
}
func (c *client) GetSizeLimiter(mediaType string) (*MediaSizeLimiter, error) {
var v string
if mediaType == "tv" {
v = c.GetSetting(SettingTvSizeLimiter)
} else if mediaType == "movie" {
v = c.GetSetting(SettingMovieSizeLimiter)
} else {
return nil, errors.Errorf("media type not supported: %v", mediaType)
}
var limiter MediaSizeLimiter
if v == "" {
return &limiter, nil
}
err := json.Unmarshal([]byte(v), &limiter)
return &limiter, err
}
func (c *client) SetSizeLimiter(mediaType string, limiter *MediaSizeLimiter) error {
data, err := json.Marshal(limiter)
if err != nil {
return err
}
if mediaType == "tv" {
return c.SetSetting(SettingTvSizeLimiter, string(data))
} else if mediaType == "movie" {
return c.SetSetting(SettingMovieSizeLimiter, string(data))
} else {
return errors.Errorf("media type not supported: %v", mediaType)
}
}
func (c *client) GetTvNamingFormat() string {
s := c.GetSetting(SettingTvNamingFormat)
if s == "" {
return DefaultNamingFormat
}
return s
}
func (c *client) GetMovingNamingFormat() string {
s := c.GetSetting(SettingMovieNamingFormat)
if s == "" {
return DefaultNamingFormat
}
return s
}
func (c *client) CleanAllDanglingEpisodes() error {
_, err := c.ent.Episode.Delete().Where(episode.Not(episode.HasMedia())).Exec(context.Background())
return err
}
func (c *client) GetProwlarrSetting() (*ProwlarrSetting, error) {
s := c.GetSetting(SettingProwlarrInfo)
if s == "" {
return nil, errors.New("prowlarr setting not set")
}
var se ProwlarrSetting
if err := json.Unmarshal([]byte(s), &se); err != nil {
return nil, err
}
return &se, nil
}
func (c *client) SaveProwlarrSetting(se *ProwlarrSetting) error {
data, err := json.Marshal(se)
if err != nil {
return err
}
return c.SetSetting(SettingProwlarrInfo, string(data))
}
func (c *client) getAcceptedFormats(key string) ([]string, error) {
v := c.GetSetting(key)
if v == "" {
return nil, nil
}
var res []string
err := json.Unmarshal([]byte(v), &res)
return res, err
}
func (c *client) setAcceptedFormats(key string, v []string) error {
data, err := json.Marshal(v)
if err != nil {
return err
}
return c.SetSetting(key, string(data))
}
func (c *client) GetAcceptedVideoFormats() ([]string, error) {
res, err := c.getAcceptedFormats(SettingAcceptedVideoFormats)
if err != nil {
return nil, err
}
if res == nil {
return defaultAcceptedVideoFormats, nil
}
return res, nil
}
func (c *client) SetAcceptedVideoFormats(key string, v []string) error {
return c.setAcceptedFormats(SettingAcceptedVideoFormats, v)
}
func (c *client) GetAcceptedSubtitleFormats() ([]string, error) {
res, err := c.getAcceptedFormats(SettingAcceptedSubtitleFormats)
if err != nil {
return nil, err
}
if res == nil {
return defaultAcceptedSubtitleFormats, nil
}
return res, nil
}
func (c *client) SetAcceptedSubtitleFormats(key string, v []string) error {
return c.setAcceptedFormats(SettingAcceptedSubtitleFormats, v)
}
func (c *client) GetTmdbApiKey() string {
k := c.GetSetting(SettingTmdbApiKey)
if k == "" {
return DefaultTmdbApiKey
}
return k
}
func (c *client) AddTorrent2Blacklist(hash, name string, mediaId int) error {
count := c.ent.Blacklist.Query().Where(blacklist.TorrentHash(hash), blacklist.MediaID(mediaId)).CountX(context.TODO())
if count > 0 { //already exist
log.Infof("torrent %s already in blacklist", hash)
return nil
}
return c.ent.Blacklist.Create().SetType(blacklist.TypeTorrent).SetTorrentHash(hash).SetTorrentName(name).SetMediaID(mediaId).Exec(context.Background())
}
func (c *client) GetTorrentBlacklist() (ent.Blacklists, error) {
return c.ent.Blacklist.Query().Where(blacklist.TypeEQ(blacklist.TypeTorrent)).All(context.Background())
}
func (c *client) DeleteTorrentBlacklist(id int) error {
return c.ent.Blacklist.DeleteOneID(id).Exec(context.Background())
}

111
db/interface.go Normal file
View File

@@ -0,0 +1,111 @@
package db
import (
"polaris/ent"
"polaris/ent/episode"
"polaris/ent/history"
"polaris/ent/media"
)
type Database interface {
Settings
MediaApis
EpisodeApis
IndexerApis
HistoryApis
SaveDownloader(downloader *ent.DownloadClients) error
GetAllDonloadClients() []*ent.DownloadClients
DeleteDownloadCLient(id int)
GetDownloadClient(id int) (*ent.DownloadClients, error)
AddStorage(st *StorageInfo) error
GetAllStorage() []*ent.Storage
GetStorage(id int) *Storage
DeleteStorage(id int) error
SetDefaultStorage(id int) error
SetDefaultStorageByName(name string) error
GetAllImportLists() ([]*ent.ImportList, error)
AddImportlist(il *ent.ImportList) error
DeleteImportlist(id int) error
GetAllNotificationClients2() ([]*ent.NotificationClient, error)
GetAllNotificationClients() ([]*NotificationClient, error)
AddNotificationClient(name, service string, setting string, enabled bool) error
DeleteNotificationClient(id int) error
GetNotificationClient(id int) (*NotificationClient, error)
AddTorrent2Blacklist(hash, name string, mediaId int) error
GetTorrentBlacklist() (ent.Blacklists, error)
DeleteTorrentBlacklist(id int) error
}
type Settings interface {
GetSetting(key string) string
SetSetting(key, value string) error
GetLanguage() string
GetDownloadDir() string
GetTvNamingFormat() string
GetMovingNamingFormat() string
GetProwlarrSetting() (*ProwlarrSetting, error)
SaveProwlarrSetting(se *ProwlarrSetting) error
GetAcceptedVideoFormats() ([]string, error)
SetAcceptedVideoFormats(key string, v []string) error
GetAcceptedSubtitleFormats() ([]string, error)
SetAcceptedSubtitleFormats(key string, v []string) error
GetTmdbApiKey() string
}
type MediaApis interface {
AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, error)
GetMediaWatchlist(mediaType media.MediaType) []*ent.Media
GetMediaDetails(id int) (*MediaDetails, error)
GetMedia(id int) (*ent.Media, error)
DeleteMedia(id int) error
TmdbIdInWatchlist(tmdb_id int) bool
EditMediaMetadata(in EditMediaData) error
GetSizeLimiter(mediaType string) (*MediaSizeLimiter, error)
SetSizeLimiter(mediaType string, limiter *MediaSizeLimiter) error
}
type EpisodeApis interface {
GetAllEpisodes() (ent.Episodes, error)
DeleteEpisode(ids ...int) error
GetEpisode(seriesId, seasonNum, episodeNum int) (*ent.Episode, error)
GetEpisodeByID(epID int) (*ent.Episode, error)
UpdateEpiode(episodeId int, name, overview string) error
UpdateEpiode2(episodeId int, name, overview, airdate string) error
SaveEposideDetail(d *ent.Episode) (int, error)
SaveEposideDetail2(d *ent.Episode) (int, error)
UpdateEpisodeStatus(mediaID int, seasonNum, episodeNum int) error
SetEpisodeStatus(id int, status episode.Status) error
IsEpisodeDownloadingOrDownloaded(id int) bool
SetSeasonAllEpisodeStatus(mediaID, seasonNum int, status episode.Status) error
SetEpisodeMonitoring(id int, b bool) error
UpdateEpisodeTargetFile(id int, filename string) error
GetSeasonEpisodes(mediaId, seasonNum int) ([]*ent.Episode, error)
CleanAllDanglingEpisodes() error
}
type IndexerApis interface {
SaveIndexer(in *ent.Indexers) error
DeleteIndexer(id int)
GetIndexer(id int) (*ent.Indexers, error)
GetAllIndexers() []*ent.Indexers
}
type HistoryApis interface {
SaveHistoryRecord(h ent.History) (*ent.History, error)
SetHistoryStatus(id int, status history.Status) error
GetRunningHistories() ent.Histories
GetHistory(id int) *ent.History
GetHistories() ent.Histories
DeleteHistory(id int) error
GetDownloadHistory(mediaID int) ([]*ent.History, error)
GetMovieDummyEpisode(movieId int) (*ent.Episode, error)
}

46
db/migrate.go Normal file
View File

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

99
db/notification.go Normal file
View File

@@ -0,0 +1,99 @@
package db
import (
"context"
"encoding/json"
"polaris/ent"
"polaris/ent/notificationclient"
"polaris/pkg/notifier"
"strings"
"github.com/pkg/errors"
)
func (c *client) GetAllNotificationClients2() ([]*ent.NotificationClient, error) {
return c.ent.NotificationClient.Query().All(context.TODO())
}
func (c *client) GetAllNotificationClients() ([]*NotificationClient, error) {
all, err := c.ent.NotificationClient.Query().All(context.TODO())
if err != nil {
return nil, errors.Wrap(err, "query db")
}
var all1 []*NotificationClient
for _, item := range all {
cl, err := toNotificationClient(item)
if err != nil {
return nil, errors.Wrap(err, "convert")
}
all1 = append(all1, cl)
}
return all1, nil
}
func (c *client) AddNotificationClient(name, service string, setting string, enabled bool) error {
// data, err := json.Marshal(setting)
// if err != nil {
// return errors.Wrap(err, "json")
// }
service = strings.ToLower(service)
count, err := c.ent.NotificationClient.Query().Where(notificationclient.Name(name)).Count(context.Background())
if err == nil && count > 0 {
//update exist one
return c.ent.NotificationClient.Update().Where(notificationclient.Name(name)).SetService(service).
SetSettings(setting).SetEnabled(enabled).Exec(context.Background())
}
return c.ent.NotificationClient.Create().SetName(name).SetService(service).
SetSettings(setting).SetEnabled(enabled).Exec(context.Background())
}
func (c *client) DeleteNotificationClient(id int) error {
_, err := c.ent.NotificationClient.Delete().Where(notificationclient.ID(id)).Exec(context.Background())
return err
}
func (c *client) GetNotificationClient(id int) (*NotificationClient, error) {
noti, err := c.ent.NotificationClient.Query().Where(notificationclient.ID(id)).First(context.Background())
if err != nil {
return nil, errors.Wrap(err, "query")
}
return toNotificationClient(noti)
}
func toNotificationClient(cl *ent.NotificationClient) (*NotificationClient, error) {
var settings interface{}
switch cl.Service {
case "pushover":
settings = notifier.PushoverConfig{}
case "dingtalk":
settings = notifier.DingTalkConfig{}
case "telegram":
settings = notifier.TelegramConfig{}
case "bark":
settings = notifier.BarkConfig{}
case "serverchan":
settings = notifier.ServerChanConfig{}
}
err := json.Unmarshal([]byte(cl.Settings), &settings)
if err != nil {
return nil, errors.Wrap(err, "json")
}
return &NotificationClient{
ID: cl.ID,
Name: cl.Name,
Service: cl.Service,
Enabled: cl.Enabled,
Settings: settings,
}, nil
}
type NotificationClient struct {
ID int `json:"id"`
Name string `json:"name"`
Service string `json:"service"`
Enabled bool `json:"enabled"`
Settings interface{} `json:"settings"`
}

13
doc/alist.md Normal file
View File

@@ -0,0 +1,13 @@
# alist 对接
> 本程序可以把alist作为一个存储后台使用下载完成的电影电视剧上传到alist对应的文件夹。配合阿里云、夸克云盘等实现云盘NAS功能。目前支持两种对接方式webdav和直接对接
## webdav
使用webdav形式对接本程序支持程序所有功能但是不支持秒传上传会比较慢
## alist 直接对接
存储设置里选择 alist填入对应的信息即可。
优点支持秒传上传速度快。缺点部分功能无法使用plex和nfo文件刮削

BIN
doc/assets/add_indexer.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

BIN
doc/assets/add_series.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 KiB

BIN
doc/assets/anime_match.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 KiB

BIN
doc/assets/copy_feed.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
doc/assets/detail_page.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
doc/assets/downloader.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
doc/assets/main_page.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 843 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
doc/assets/search_add.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

BIN
doc/assets/unraid.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
doc/assets/wechat.JPG Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
doc/assets/yuanli.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

38
doc/configuration.md Normal file
View File

@@ -0,0 +1,38 @@
# 配置
要正确使用此程序,需要配置好以下设置:
### 1. TMDB设置
1. 因为此程序需要使用到 TMDB 的数据,使用此程序首先要申请一个 TMDB 的 Api Key. 申请教程请 google [tmdb api key申请](https://www.google.com/search?q=tmdb+api+key%E7%94%B3%E8%AF%B7)
2. 拿到 TMDB Api Key之后请填到 *设置 -> 常规设置 -> TMDB Api Key里*
**注意:** TMDB可能需要翻墙才能使用参考 [TMDB 访问问题](./tmdb.md)
### 2. 索引器
使用配置页面索引器配置或者prowlarr设置其中一个即可。
#### jackett配置参考 [jackett](./jackett.md)
#### prowlarr设置
1) 取得prowlarr的url和api key api key在 *Prowlarr 设置 -> 通用 -> API 密钥* 处取得
2) 对应参数填到 polaris程序*设置->prowlarr设置*当中
### 下载器
资源下载器,目前可支持 tansmission/qbittorrent请配置好对应配置
![transmission](./assets/downloader.png)
### 存储设置
默认配置了名为 local 的本地存储,如果你不知道怎么配置。请使用默认配置
![local_storage](./assets/local_storage.png)
类型里选择 webdav 可以使用 webdav 存储,配合 alist/clouddrive 等,可以实现存储到云盘里的功能。
![webdav](./assets/webdav_storage.png)

14
doc/faq.md Normal file
View File

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

21
doc/jackett.md Normal file
View File

@@ -0,0 +1,21 @@
## jackett 索引器配置
1. 打开 jackett 主页后,点击页面上面的 Add indexer会出现 BT/PT 站点列表,选择你需要的站点点击+号添加。如果是PT请自行配置好相关配置
![add indexer](./assets/add_indexer.png)
![search add](./assets/search_add.png)
2. 添加后主页即会显示相应的BT/PT站点点击 *Copy Torznab Feed* 即得到了我们需要的地址
![copy feed](./assets/copy_feed.png)
3. 回到我们的主程序 Polaris 当中,点击 *设置 -> 索引器设置* -> 点击+号增加新的索引器输入一个名称拷贝我们第2步得到的地址到地址栏
![polaris add indexer](./assets/polaris_add_indexer.png)
4. 选相框中我们可以看到,还需要一个 API Key我们回到 Jackett 中,在页面右上角,复制我们需要的 API Key
![api key](./assets/jackett_api_key.png)
5. 恭喜!你已经成功完成了索引器配置。如需要更多的站点,请重复相同的操作完成配置

139
doc/quick_start.md Normal file
View File

@@ -0,0 +1,139 @@
# 快速开始
## 1. 安装 Polaris
### 1.1 Docker Compose 方式安装
最简单使用本程序的方式是通过docker compose下面内容保存成 docker-compose.yml然后执行 docker compose up -d, 即可拉起程序。
```yaml
services:
polaris:
image: ghcr.io/simon-ding/polaris:latest
restart: always
environment:
- PUID=99 #程序运行的用户UID
- PGID=100 #程序运行的用户GID
- TZ=Asia/Shanghai #时区
volumes:
- <配置文件路径>:/app/data #程序配置文件路径
- <下载路径>:/downloads #下载路径,需要和下载客户端配置一致
- <媒体文件路径>:/data #媒体数据存储路径也可以启动自己配置webdav存储
ports:
- 8080:8080 #端口映射,冒号前的端口可自行改为需要的
```
> latest为发布版本如果你追求新功能且能接受bug可以使用main tag
### 1.2 Docker 方式安装
也可以通过原始 docker 命令的方式安装 Polaris
```bash
docker run -d \
-v <配置文件路径>:/app/data \
-v <下载路径>:/downloads \
-v <媒体文件路径>:/data \
-e PUID=99 \
-e PGID=100 \
-e TZ=Asia/Shanghai \
-p 8080:8080 \
--restart always \
ghcr.io/simon-ding/polaris:latest
```
### 1.3 Unraid 安装
参考下图进行配置
![](./assets/unraid.png)
### 1.4 访问
拉起之后访问 http://< ip >:8080 即可访问 Polaris 的主页:
![](./assets/main_page.png)
## 2. 安装下载客户端
Polaris 需要下载客户端的配合使用,目前支持 Transmission 和 Qbittorrent。推荐使用linuxserver镜像进行安装
* [linuxserver/transmission](https://docs.linuxserver.io/images/docker-transmission)
* [linuxserver/qbittorrent](https://docs.linuxserver.io/images/docker-qbittorrent/)
需要注意的是下载客户端内 /downloads 路径的映射地址要和 Polaris的/downloads路径映射保持一致。也就是说他俩都要映射到同一路径。
## 3. 安装 Jackett/Prowlarr
Polaris 如果要正常工作还需要一个索引客户端的支持目前支持jackett/prowlarr索引客户端。推荐使用prowlarr设置更简单
安装方式见:
* [linuxserver/jackett](https://docs.linuxserver.io/images/docker-jackett/)
* [linuxserver/prowlarr](https://docs.linuxserver.io/images/docker-prowlarr/)
## 4. 联合安装
如果觉得一个个安装麻烦也可以使用下面docker compose文件一键拉起所有组件
**注意:** transmission 的下载路径映射要和 polaris 保持一致,如果您不知道怎么做,请保持默认设置。
```yaml
services:
polaris:
image: ghcr.io/simon-ding/polaris:latest
restart: always
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai
volumes:
- ./config/polaris:/app/data #程序配置文件路径
- /downloads:/downloads #下载路径,需要和下载客户端配置一致
- /data:/data #媒体数据存储路径也可以启动自己配置webdav存储
ports:
- 8080:8080
transmission: #下载客户端,也可以不安装使用已有的
image: lscr.io/linuxserver/transmission:latest
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai
volumes:
- ./config/transmission:/config
- /downloads:/downloads #此路径要与polaris下载路径保持一致
ports:
- 9091:9091
- 51413:51413
- 51413:51413/udp
jackett: #索引客户端,也可以不安装使用已有的
image: lscr.io/linuxserver/jackett:latest
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai
volumes:
- ./config/jackett:/config
ports:
- 9117:9117
restart: unless-stopped
```
复制上面文件保存成 docker-compose.yml 文件,然后执行下面命令
```bash
docker compose up -d
```
## 5. 配置
详细配置请看 [配置篇](./configuration.md)
## 6. FAQ
- [常见问题 FAQ](./faq.md)

View File

@@ -0,0 +1,9 @@
# 利用STUN进行NAT内网穿透
可以在下载器选项里打开 *使用内置STUN NAT穿透* 功能即使处在NAT网络环境下BT/PT也可以满速上传。打开后Polaris自动更改下载客户端的监听端口并代理BT的上传流量。
要想正常使用此功能,需要具备以下几个条件:
1. 所在的NAT网络非对称NATSymmetric NAT可以使用 [NatTypeTester](https://github.com/HMBSbige/NatTypeTester/releases/) 检查自己的网络的NAT类型
2. 下载器设置选项中下载器地址为下载器docker的实际地址而非映射地址。达到这一目标可以使用host网络创建下载器也可以利用docker-compose自带的域名解析来实现

6
doc/tmdb.md Normal file
View File

@@ -0,0 +1,6 @@
# TMDB 访问问题
由于国内特殊的网络环境,访问 tmdb 可能需要翻墙代理,有两种解决方案
1. 设置路由器全局代理openwrt等第三方路由固件可以实现这个功能
2. 使用程序代理功能,*常规->代理地址* 中设置,格式如 http://192.168.0.10:1080

37
docker/Dockerfile Normal file
View File

@@ -0,0 +1,37 @@
FROM golang:1.24 as builder
# 启用go module
ENV GO111MODULE=on
#GOPROXY=https://goproxy.cn,direct
WORKDIR /app
ARG TMDB_API_KEY
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
# 指定OS等并go build
RUN make polaris-web
FROM debian:stable-slim
WORKDIR /app
RUN apt-get update && apt-get -y install ca-certificates tzdata gosu tini locales && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo "${TZ}" > /etc/timezone && apt-get clean && sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV TZ="Asia/Shanghai" GIN_MODE=release PUID=0 PGID=0 UMASK=0
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
# 将上一个阶段publish文件夹下的所有文件复制进来
COPY --from=builder /app/polaris .
COPY --from=builder /app/entrypoint.sh .
RUN chmod +x /app/entrypoint.sh
VOLUME /app/data
EXPOSE 8080
ENTRYPOINT ["tini","./entrypoint.sh"]

46
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,46 @@
services:
polaris:
image: ghcr.io/simon-ding/polaris:latest
restart: always
environment:
- PUID=1000
- PGID=1000
- TZ=${TIMEZONE}
volumes:
- ${CONFIGURATION_FILE_LOCATION}/polaris:/app/data
- ${DOWNLOAD_LOCATION}:/downloads
- ${MEDIA_LOCATION}:/data
env_file:
- .env
ports:
- 3322:8080
transmission:
image: lscr.io/linuxserver/transmission:latest
environment:
- PUID=1000
- PGID=1000
- TZ=${TIMEZONE}
volumes:
- ${CONFIGURATION_FILE_LOCATION}/transmission:/config
- ${DOWNLOAD_LOCATION}:/downloads
env_file:
- .env
restart: always
ports:
- 9091:9091
- 51413:51413
- 51413:51413/udp
prowlarr:
image: lscr.io/linuxserver/prowlarr:latest
container_name: prowlarr
environment:
- PUID=1000
- PGID=1000
- TZ=${TIMEZONE}
volumes:
- ${CONFIGURATION_FILE_LOCATION}/prowlar:/config
env_file:
- .env
ports:
- 9696:9696
restart: always

12
docker/example.env Normal file
View File

@@ -0,0 +1,12 @@
#下载路径
DOWNLOAD_LOCATION=/downloads
#媒体数据存储路径也可以启动自己配置webdav存储
MEDIA_LOCATION=/data
#程序配置文件存放路径
CONFIGURATION_FILE_LOCATION=./config
#时区
TIMEZONE=Asia/Shanghai

238
engine/client.go Normal file
View File

@@ -0,0 +1,238 @@
package engine
import (
"polaris/db"
"polaris/ent"
"polaris/ent/downloadclients"
"polaris/log"
"polaris/pkg"
"polaris/pkg/buildin"
"polaris/pkg/qbittorrent"
"polaris/pkg/tmdb"
"polaris/pkg/transmission"
"polaris/pkg/utils"
"github.com/pkg/errors"
"github.com/robfig/cron"
)
func NewEngine(db db.Database, language string) *Engine {
return &Engine{
db: db,
cron: cron.New(),
tasks: utils.Map[int, *Task]{},
schedulers: utils.Map[string, scheduler]{},
language: language,
}
}
type scheduler struct {
cron string
f func() error
}
type Engine struct {
db db.Database
cron *cron.Cron
tasks utils.Map[int, *Task]
language string
schedulers utils.Map[string, scheduler]
buildin *buildin.Downloader
}
func (c *Engine) registerCronJob(name string, cron string, f func() error) {
c.schedulers.Store(name, scheduler{
cron: cron,
f: f,
})
}
func (c *Engine) Init() {
go c.reloadTasks()
c.addSysCron()
go c.checkW500PosterOnStartup()
}
func (c *Engine) GetTask(id int) (*Task, bool) {
return c.tasks.Load(id)
}
func (c *Engine) reloadUsingBuildinDownloader(h *ent.History) error {
cl, err := c.buildInDownloader()
if err != nil {
log.Warnf("buildin downloader error: %v", err)
}
t, err := cl.Download(h.Link, h.Hash, c.db.GetDownloadDir())
if err != nil {
return errors.Wrap(err, "download torrent")
}
t.Start()
c.tasks.Store(h.ID, &Task{Torrent: t})
return nil
}
func (c *Engine) reloadTasks() {
allTasks := c.db.GetRunningHistories()
for _, t := range allTasks {
if t.DownloadClientID == 0 {
log.Warnf("assume buildin downloader: %v", t.SourceTitle)
err := c.reloadUsingBuildinDownloader(t)
if err != nil {
log.Warnf("buildin downloader error: %v", err)
} else {
log.Infof("success reloading buildin task: %v", t.SourceTitle)
}
continue
}
dl, err := c.db.GetDownloadClient(t.DownloadClientID)
if err != nil {
log.Warnf("no download client related: %v", t.SourceTitle)
continue
}
if dl.Implementation == downloadclients.ImplementationTransmission {
if t.Hash != "" { //优先使用hash
to, err := transmission.NewTorrentHash(transmission.Config{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Hash)
if err != nil {
log.Warnf("get task error: %v", err)
continue
}
c.tasks.Store(t.ID, &Task{Torrent: to})
} else if t.Link != "" {
to, err := transmission.NewTorrent(transmission.Config{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Link)
if err != nil {
log.Warnf("get task error: %v", err)
continue
}
c.tasks.Store(t.ID, &Task{Torrent: to})
}
} else if dl.Implementation == downloadclients.ImplementationQbittorrent {
if t.Hash != "" {
to, err := qbittorrent.NewTorrentHash(qbittorrent.Info{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Hash)
if err != nil {
log.Warnf("get task error: %v", err)
continue
}
c.tasks.Store(t.ID, &Task{Torrent: to})
} else if t.Link != "" {
to, err := qbittorrent.NewTorrent(qbittorrent.Info{
URL: dl.URL,
User: dl.User,
Password: dl.Password,
}, t.Link)
if err != nil {
log.Warnf("get task error: %v", err)
continue
}
c.tasks.Store(t.ID, &Task{Torrent: to})
}
} else if dl.Implementation == downloadclients.ImplementationBuildin {
err := c.reloadUsingBuildinDownloader(t)
if err != nil {
log.Warnf("buildin downloader error: %v", err)
} else {
log.Infof("success reloading buildin task: %v", t.SourceTitle)
}
}
}
log.Infof("------ task reloading done ------")
}
func (c *Engine) buildInDownloader() (pkg.Downloader, error) {
if c.buildin != nil {
return c.buildin, nil
}
dir := c.db.GetDownloadDir()
d, err := buildin.NewDownloader(dir)
if err != nil {
return nil, errors.Wrap(err, "buildin downloader")
}
c.buildin = d
return d, nil
}
func (c *Engine) GetDownloadClient() (pkg.Downloader, *ent.DownloadClients, error) {
downloaders := c.db.GetAllDonloadClients()
for _, d := range downloaders {
if !d.Enable {
continue
}
if d.Implementation == downloadclients.ImplementationTransmission {
trc, err := transmission.NewClient(transmission.Config{
URL: d.URL,
User: d.User,
Password: d.Password,
})
if err != nil {
log.Warnf("connect to download client error: %v", d.URL)
continue
}
return trc, d, nil
} else if d.Implementation == downloadclients.ImplementationQbittorrent {
qbt, err := qbittorrent.NewClient(d.URL, d.User, d.Password)
if err != nil {
log.Warnf("connect to download client error: %v", d.URL)
continue
}
return qbt, d, nil
} else if d.Implementation == downloadclients.ImplementationBuildin {
bin, err := c.buildInDownloader()
if err != nil {
log.Warnf("connect to download client error: %v", err)
continue
}
return bin, d, nil
}
}
return nil, nil, errors.Errorf("no available download client")
}
func (c *Engine) TMDB() (*tmdb.Client, error) {
api := c.db.GetTmdbApiKey()
if api == "" {
return nil, errors.New("TMDB apiKey not set")
}
proxy := c.db.GetSetting(db.SettingProxy)
adult := c.db.GetSetting(db.SettingEnableTmdbAdultContent)
return tmdb.NewClient(api, proxy, adult == "true")
}
func (c *Engine) MustTMDB() *tmdb.Client {
t, err := c.TMDB()
if err != nil {
log.Panicf("get tmdb: %v", err)
}
return t
}
func (c *Engine) RemoveTaskAndTorrent(id int) error {
torrent, ok := c.tasks.Load(id)
if ok {
if err := torrent.Remove(); err != nil {
return errors.Wrap(err, "remove torrent")
}
c.tasks.Delete(id)
}
return nil
}
func (c *Engine) GetTasks() *utils.Map[int, *Task] {
return &c.tasks
}

1
engine/fliters.go Normal file
View File

@@ -0,0 +1 @@
package engine

65
engine/housekeeping.go Normal file
View File

@@ -0,0 +1,65 @@
package engine
import (
"polaris/ent/media"
"polaris/log"
)
func (c *Engine) housekeeping() (err error) {
log.Infof("start housekeeping tasks...")
defer func() {
log.Infof("housekeeping tasks completed. err: %v", err)
}()
if err := c.checkDbScraps(); err != nil {
return err
}
if err := c.checkImageFilesInterity(); err != nil {
return err
}
return nil
}
func (c *Engine) checkDbScraps() error {
//TODO: remove episodes that are not associated with any series
tvs := c.db.GetMediaWatchlist(media.MediaTypeTv)
movies := c.db.GetMediaWatchlist(media.MediaTypeMovie)
validMediaIDs := make(map[int]bool, len(tvs)+len(movies))
for _, tv := range tvs {
validMediaIDs[tv.ID] = true
}
for _, movie := range movies {
validMediaIDs[movie.ID] = true
}
allEpisodes, err := c.db.GetAllEpisodes()
if err != nil {
log.Debugf("get all episodes error: %v", err)
return err
}
log.Infof("check db scraps, total episodes: %v, total media: %v", len(allEpisodes), len(validMediaIDs))
toDeleteIds := make([]int, 0)
for _, ep := range allEpisodes {
if _, ok := validMediaIDs[ep.MediaID]; !ok {
//log.Infof("remove scrap episode record: %v S%vE%v", ep.MediaID, ep.SeasonNumber, ep.EpisodeNumber)
toDeleteIds = append(toDeleteIds, ep.ID)
}
}
log.Infof("%v scrap episode records will be removed...", len(toDeleteIds))
if err := c.db.DeleteEpisode(toDeleteIds...); err != nil {
log.Errorf("delete scrap episode records error: %v", err)
}
return nil
}
func (c *Engine) checkImageFilesInterity() error {
//TODO: download missing image files, remove unused image files
return nil
}

608
engine/importlist.go Normal file
View File

@@ -0,0 +1,608 @@
package engine
import (
"bytes"
"fmt"
"html/template"
"io"
"net/http"
"os"
"path/filepath"
"polaris/db"
"polaris/ent"
"polaris/ent/episode"
"polaris/ent/importlist"
"polaris/ent/media"
"polaris/ent/schema"
"polaris/log"
"polaris/pkg/importlist/plexwatchlist"
"polaris/pkg/metadata"
"polaris/pkg/utils"
"regexp"
"strings"
tmdb "github.com/cyruzin/golang-tmdb"
"github.com/pkg/errors"
)
func (c *Engine) periodicallyUpdateImportlist() error {
log.Infof("begin check import list")
lists, err := c.db.GetAllImportLists()
if err != nil {
return errors.Wrap(err, "get from db")
}
for _, l := range lists {
log.Infof("check import list content for %v", l.Name)
if l.Type == importlist.TypePlex {
res, err := plexwatchlist.ParsePlexWatchlist(l.URL)
if err != nil {
log.Errorf("parse plex watchlist: %v", err)
continue
}
for _, item := range res.Items {
var tmdbRes *tmdb.FindByID
if item.ImdbID != "" {
tmdbRes1, err := c.MustTMDB().GetByImdbId(item.ImdbID, c.language)
if err != nil {
log.Errorf("get by imdb id error: %v", err)
continue
}
tmdbRes = tmdbRes1
} else if item.TvdbID != "" {
tmdbRes1, err := c.MustTMDB().GetByTvdbId(item.TvdbID, c.language)
if err != nil {
log.Errorf("get by imdb id error: %v", err)
continue
}
tmdbRes = tmdbRes1
}
if tmdbRes == nil {
log.Errorf("can not find media for : %+v", item)
continue
}
if len(tmdbRes.MovieResults) > 0 {
d := tmdbRes.MovieResults[0]
name, err := c.SuggestedMovieFolderName(int(d.ID))
if err != nil {
log.Errorf("suggesting name error: %v", err)
continue
}
_, err = c.AddMovie2Watchlist(AddWatchlistIn{
TmdbID: int(d.ID),
StorageID: l.StorageID,
Resolution: l.Qulity,
Folder: name,
})
if err != nil {
log.Errorf("[update_import_lists] add movie to watchlist error: %v", err)
} else {
c.sendMsg(fmt.Sprintf("成功监控电影:%v", d.Title))
log.Infof("[update_import_lists] add movie to watchlist success")
}
} else if len(tmdbRes.TvResults) > 0 {
d := tmdbRes.TvResults[0]
name, err := c.SuggestedSeriesFolderName(int(d.ID))
if err != nil {
log.Errorf("suggesting name error: %v", err)
continue
}
_, err = c.AddTv2Watchlist(AddWatchlistIn{
TmdbID: int(d.ID),
StorageID: l.StorageID,
Resolution: l.Qulity,
Folder: name,
})
if err != nil {
log.Errorf("[update_import_lists] add tv to watchlist error: %v", err)
} else {
c.sendMsg(fmt.Sprintf("成功监控电视剧:%v", d.Name))
log.Infof("[update_import_lists] add tv to watchlist success")
}
}
}
}
}
return nil
}
type AddWatchlistIn struct {
TmdbID int `json:"tmdb_id" binding:"required"`
StorageID int `json:"storage_id" `
Resolution string `json:"resolution" binding:"required"`
Folder string `json:"folder" binding:"required"`
DownloadHistoryEpisodes bool `json:"download_history_episodes"` //for tv
SizeMin int64 `json:"size_min"`
SizeMax int64 `json:"size_max"`
PreferSize int64 `json:"prefer_size"`
}
func (c *Engine) AddTv2Watchlist(in AddWatchlistIn) (interface{}, error) {
log.Debugf("add tv watchlist input %+v", in)
if in.Folder == "" {
return nil, errors.New("folder should be provided")
}
detailCn, err := c.MustTMDB().GetTvDetails(in.TmdbID, db.LanguageCN)
if err != nil {
return nil, errors.Wrap(err, "get tv detail")
}
var nameCn = detailCn.Name
detailEn, _ := c.MustTMDB().GetTvDetails(in.TmdbID, db.LanguageEN)
var nameEn = detailEn.Name
var detail *tmdb.TVDetails
if c.language == "" || c.language == db.LanguageCN {
detail = detailCn
} else {
detail = detailEn
}
log.Infof("find detail for tv id %d: %+v", in.TmdbID, detail)
lastSeason := 0
for _, season := range detail.Seasons {
if season.SeasonNumber > lastSeason && season.EpisodeCount > 0 { //如果最新一季已经有剧集信息,则以最新一季为准
lastSeason = season.SeasonNumber
}
}
log.Debugf("latest season is %v", lastSeason)
alterTitles, err := c.getAlterTitles(in.TmdbID, media.MediaTypeTv)
if err != nil {
return nil, errors.Wrap(err, "get alter titles")
}
var epIds []int
for _, season := range detail.Seasons {
seasonId := season.SeasonNumber
se, err := c.MustTMDB().GetSeasonDetails(int(detail.ID), seasonId, c.language)
if err != nil {
log.Errorf("get season detail (%s) error: %v", detail.Name, err)
continue
}
shouldMonitor := seasonId >= lastSeason //监控最新的一季
for _, ep := range se.Episodes {
// //如果设置下载往期剧集则监控所有剧集。如果没有则监控未上映的剧集考虑时差等问题留24h余量
// if in.DownloadHistoryEpisodes {
// shouldMonitor = true
// } else {
// t, err := time.Parse("2006-01-02", ep.AirDate)
// if err != nil {
// log.Error("air date not known, will monitor: %v", ep.AirDate)
// shouldMonitor = true
// } else {
// if time.Since(t) < 24*time.Hour { //monitor episode air 24h before now
// shouldMonitor = true
// }
// }
// }
ep := ent.Episode{
SeasonNumber: seasonId,
EpisodeNumber: ep.EpisodeNumber,
Title: ep.Name,
Overview: ep.Overview,
AirDate: ep.AirDate,
Monitored: shouldMonitor,
}
epid, err := c.db.SaveEposideDetail(&ep)
if err != nil {
log.Errorf("save episode info error: %v", err)
continue
}
log.Debugf("success save episode %+v", ep)
epIds = append(epIds, epid)
}
}
m := &ent.Media{
TmdbID: int(detail.ID),
ImdbID: detail.IMDbID,
MediaType: media.MediaTypeTv,
NameCn: nameCn,
NameEn: nameEn,
OriginalName: detail.OriginalName,
Overview: detail.Overview,
AirDate: detail.FirstAirDate,
Resolution: media.Resolution(in.Resolution),
StorageID: in.StorageID,
TargetDir: in.Folder,
DownloadHistoryEpisodes: in.DownloadHistoryEpisodes,
Limiter: schema.MediaLimiter{SizeMin: in.SizeMin, SizeMax: in.SizeMax},
Extras: schema.MediaExtras{
OriginalLanguage: detail.OriginalLanguage,
//Genres: detail.Genres,
},
AlternativeTitles: alterTitles,
}
for _, g := range detail.Genres {
m.Extras.Genres = append(m.Extras.Genres, schema.Genre{
ID: g.ID,
Name: g.Name,
})
}
r, err := c.db.AddMediaWatchlist(m, epIds)
if err != nil {
return nil, errors.Wrap(err, "add to list")
}
go func() {
if err := c.downloadPoster(detail.PosterPath, r.ID); err != nil {
log.Errorf("download poster error: %v", err)
}
if err := c.downloadW500Poster(detail.PosterPath, r.ID); err != nil {
log.Errorf("download w500 poster error: %v", err)
}
if err := c.downloadBackdrop(detail.BackdropPath, r.ID); err != nil {
log.Errorf("download poster error: %v", err)
}
if err := c.CheckDownloadedSeriesFiles(r); err != nil {
log.Errorf("check downloaded files error: %v", err)
}
}()
log.Infof("add tv %s to watchlist success", detail.Name)
return nil, nil
}
func (c *Engine) getAlterTitles(tmdbId int, mediaType media.MediaType) ([]schema.AlternativeTilte, error) {
var titles []schema.AlternativeTilte
if mediaType == media.MediaTypeTv {
alterTitles, err := c.MustTMDB().GetTVAlternativeTitles(tmdbId, c.language)
if err != nil {
return nil, errors.Wrap(err, "tmdb")
}
for _, t := range alterTitles.Results {
titles = append(titles, schema.AlternativeTilte{
Iso3166_1: t.Iso3166_1,
Title: t.Title,
Type: t.Type,
})
}
} else if mediaType == media.MediaTypeMovie {
alterTitles, err := c.MustTMDB().GetMovieAlternativeTitles(tmdbId, c.language)
if err != nil {
return nil, errors.Wrap(err, "tmdb")
}
for _, t := range alterTitles.Titles {
titles = append(titles, schema.AlternativeTilte{
Iso3166_1: t.Iso3166_1,
Title: t.Title,
Type: t.Type,
})
}
}
log.Debugf("get alternative titles: %+v", titles)
return titles, nil
}
func (c *Engine) AddMovie2Watchlist(in AddWatchlistIn) (interface{}, error) {
log.Infof("add movie watchlist input: %+v", in)
detailCn, err := c.MustTMDB().GetMovieDetails(in.TmdbID, db.LanguageCN)
if err != nil {
return nil, errors.Wrap(err, "get movie detail")
}
var nameCn = detailCn.Title
detailEn, _ := c.MustTMDB().GetMovieDetails(in.TmdbID, db.LanguageEN)
var nameEn = detailEn.Title
var detail *tmdb.MovieDetails
if c.language == "" || c.language == db.LanguageCN {
detail = detailCn
} else {
detail = detailEn
}
log.Infof("find detail for movie id %d: %v", in.TmdbID, detail)
alterTitles, err := c.getAlterTitles(in.TmdbID, media.MediaTypeMovie)
if err != nil {
return nil, errors.Wrap(err, "get alter titles")
}
epid, err := c.db.SaveEposideDetail(&ent.Episode{
SeasonNumber: 1,
EpisodeNumber: 1,
Title: "dummy episode for movies",
Overview: "dummy episode for movies",
AirDate: detail.ReleaseDate,
Monitored: true,
})
if err != nil {
return nil, errors.Wrap(err, "add dummy episode")
}
log.Infof("added dummy episode for movie: %v", nameEn)
movie := ent.Media{
TmdbID: int(detail.ID),
ImdbID: detail.IMDbID,
MediaType: media.MediaTypeMovie,
NameCn: nameCn,
NameEn: nameEn,
OriginalName: detail.OriginalTitle,
Overview: detail.Overview,
AirDate: detail.ReleaseDate,
Resolution: media.Resolution(in.Resolution),
StorageID: in.StorageID,
TargetDir: in.Folder,
Limiter: schema.MediaLimiter{SizeMin: in.SizeMin, SizeMax: in.SizeMax},
AlternativeTitles: alterTitles,
}
extras := schema.MediaExtras{
IsAdultMovie: detail.Adult,
OriginalLanguage: detail.OriginalLanguage,
//Genres: detail.Genres,
}
for _, g := range detail.Genres {
extras.Genres = append(extras.Genres, schema.Genre{
ID: g.ID,
Name: g.Name,
})
}
if IsJav(detail) {
javid := c.GetJavid(in.TmdbID)
extras.JavId = javid
}
movie.Extras = extras
r, err := c.db.AddMediaWatchlist(&movie, []int{epid})
if err != nil {
return nil, errors.Wrap(err, "add to list")
}
go func() {
if err := c.downloadPoster(detail.PosterPath, r.ID); err != nil {
log.Errorf("download poster error: %v", err)
}
if err := c.downloadW500Poster(detail.PosterPath, r.ID); err != nil {
log.Errorf("download w500 poster error: %v", err)
}
if err := c.downloadBackdrop(detail.BackdropPath, r.ID); err != nil {
log.Errorf("download backdrop error: %v", err)
}
if err := c.checkMovieFolder(r); err != nil {
log.Warnf("check movie folder error: %v", err)
}
}()
log.Infof("add movie %s to watchlist success", detail.Title)
return nil, nil
}
func (c *Engine) checkMovieFolder(m *ent.Media) error {
var storageImpl, err = c.GetStorage(m.StorageID, media.MediaTypeMovie)
if err != nil {
return err
}
files, err := storageImpl.ReadDir(m.TargetDir)
if err != nil {
return err
}
ep, err := c.db.GetMovieDummyEpisode(m.ID)
if err != nil {
return err
}
for _, f := range files {
if f.IsDir() || f.Size() < 100*1000*1000 /* 100M */ { //忽略路径和小于100M的文件
continue
}
meta := metadata.ParseMovie(f.Name())
if meta.IsAcceptable(m.NameCn) || meta.IsAcceptable(m.NameEn) {
log.Infof("found already downloaded movie: %v", f.Name())
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloaded)
}
}
return nil
}
func IsJav(detail *tmdb.MovieDetails) bool {
if detail.Adult && len(detail.ProductionCountries) > 0 && strings.ToUpper(detail.ProductionCountries[0].Iso3166_1) == "JP" {
return true
}
return false
}
func (c *Engine) GetJavid(id int) string {
alters, err := c.MustTMDB().GetMovieAlternativeTitles(id, c.language)
if err != nil {
return ""
}
for _, t := range alters.Titles {
if t.Iso3166_1 == "JP" && t.Type == "" {
return t.Title
}
}
return ""
}
func (c *Engine) downloadBackdrop(path string, mediaID int) error {
url := "https://image.tmdb.org/t/p/original" + path
return c.downloadImage(url, mediaID, "backdrop.jpg")
}
func (c *Engine) downloadPoster(path string, mediaID int) error {
var url = "https://image.tmdb.org/t/p/original" + path
return c.downloadImage(url, mediaID, "poster.jpg")
}
func (c *Engine) downloadW500Poster(path string, mediaID int) error {
url := "https://image.tmdb.org/t/p/w500" + path
return c.downloadImage(url, mediaID, "poster_w500.jpg")
}
func (c *Engine) downloadImage(url string, mediaID int, name string) error {
log.Infof("try to download image: %v", url)
var resp, err = http.Get(url)
if err != nil {
return errors.Wrap(err, "http get")
}
targetDir := fmt.Sprintf("%v/%d", db.ImgPath, mediaID)
os.MkdirAll(targetDir, 0777)
//ext := filepath.Ext(path)
targetFile := filepath.Join(targetDir, name)
f, err := os.Create(targetFile)
if err != nil {
return errors.Wrap(err, "new file")
}
defer f.Close()
_, err = io.Copy(f, resp.Body)
if err != nil {
return errors.Wrap(err, "copy http response")
}
log.Infof("image successfully downlaoded: %v", targetFile)
return nil
}
func (c *Engine) checkW500PosterOnStartup() {
log.Infof("check all w500 posters")
all := c.db.GetMediaWatchlist(media.MediaTypeTv)
movies := c.db.GetMediaWatchlist(media.MediaTypeMovie)
all = append(all, movies...)
for _, e := range all {
targetFile := filepath.Join(fmt.Sprintf("%v/%d", db.ImgPath, e.ID), "poster_w500.jpg")
if _, err := os.Stat(targetFile); err != nil {
log.Infof("poster_w500.jpg not exist for %s, will download it", e.NameEn)
if e.MediaType == media.MediaTypeTv {
detail, err := c.MustTMDB().GetTvDetails(e.TmdbID, db.LanguageCN)
if err != nil {
log.Warnf("get tmdb detail for %s error: %v", e.NameEn, err)
continue
}
if err := c.downloadW500Poster(detail.PosterPath, e.ID); err != nil {
log.Warnf("download w500 poster error: %v", err)
continue
}
} else {
detail, err := c.MustTMDB().GetMovieDetails(e.TmdbID, db.LanguageCN)
if err != nil {
log.Warnf("get tmdb detail for %s error: %v", e.NameEn, err)
continue
}
if err := c.downloadW500Poster(detail.PosterPath, e.ID); err != nil {
log.Warnf("download w500 poster error: %v", err)
continue
}
}
}
}
}
func (c *Engine) SuggestedMovieFolderName(tmdbId int) (string, error) {
d1, err := c.MustTMDB().GetMovieDetails(tmdbId, c.language)
if err != nil {
return "", errors.Wrap(err, "get movie details")
}
name := d1.Title
if IsJav(d1) {
javid := c.GetJavid(tmdbId)
if javid != "" {
return javid, nil
}
}
info := db.NamingInfo{TmdbID: tmdbId}
if utils.IsASCII(name) {
info.NameEN = stripExtraCharacters(name)
} else {
info.NameCN = stripExtraCharacters(name)
en, err := c.MustTMDB().GetMovieDetails(tmdbId, db.LanguageEN)
if err != nil {
log.Errorf("get en tv detail error: %v", err)
} else {
info.NameEN = stripExtraCharacters(en.Title)
}
}
year := strings.Split(d1.ReleaseDate, "-")[0]
info.Year = year
movieNamingFormat := c.db.GetMovingNamingFormat()
tmpl, err := template.New("test").Parse(movieNamingFormat)
if err != nil {
return "", errors.Wrap(err, "naming format")
}
buff := &bytes.Buffer{}
err = tmpl.Execute(buff, info)
if err != nil {
return "", errors.Wrap(err, "tmpl exec")
}
res := strings.TrimSpace(buff.String())
log.Infof("tv series of tmdb id %v suggestting name is %v", tmdbId, res)
return res, nil
}
func (c *Engine) SuggestedSeriesFolderName(tmdbId int) (string, error) {
d, err := c.MustTMDB().GetTvDetails(tmdbId, c.language)
if err != nil {
return "", errors.Wrap(err, "get tv details")
}
name := d.Name
info := db.NamingInfo{TmdbID: tmdbId}
if utils.IsASCII(name) {
info.NameEN = stripExtraCharacters(name)
} else {
info.NameCN = stripExtraCharacters(name)
en, err := c.MustTMDB().GetTvDetails(tmdbId, db.LanguageEN)
if err != nil {
log.Errorf("get en tv detail error: %v", err)
} else {
if en.Name != name { //sometimes en name is in chinese
info.NameEN = stripExtraCharacters(en.Name)
}
}
}
year := strings.Split(d.FirstAirDate, "-")[0]
info.Year = year
tvNamingFormat := c.db.GetTvNamingFormat()
tmpl, err := template.New("test").Parse(tvNamingFormat)
if err != nil {
return "", errors.Wrap(err, "naming format")
}
buff := &bytes.Buffer{}
err = tmpl.Execute(buff, info)
if err != nil {
return "", errors.Wrap(err, "tmpl exec")
}
res := strings.TrimSpace(buff.String())
log.Infof("tv series of tmdb id %v suggestting name is %v", tmdbId, res)
return res, nil
}
func stripExtraCharacters(s string) string {
re := regexp.MustCompile(`[^\p{L}\w\s]`)
s = re.ReplaceAllString(s, " ")
return strings.Join(strings.Fields(s), " ")
}

79
engine/indexer.go Normal file
View File

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

287
engine/integration.go Normal file
View File

@@ -0,0 +1,287 @@
package engine
import (
"bytes"
"encoding/xml"
"fmt"
"io/fs"
"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"
"slices"
"strconv"
"strings"
"github.com/pkg/errors"
)
func (c *Engine) writeNfoFile(historyId int) error {
if !c.nfoSupportEnabled() {
return nil
}
his := c.db.GetHistory(historyId)
md, err := c.db.GetMedia(his.MediaID)
if err != nil {
return err
}
if md.MediaType == media.MediaTypeTv { //tvshow.nfo
st, err := c.GetStorage(md.StorageID, media.MediaTypeTv)
if err != nil {
return errors.Wrap(err, "get storage")
}
nfoPath := filepath.Join(md.TargetDir, "tvshow.nfo")
_, err = st.ReadFile(nfoPath)
if err != nil {
log.Infof("tvshow.nfo file missing, create new one, tv series name: %s", md.NameEn)
show := Tvshow{
Title: md.NameCn,
Originaltitle: md.OriginalName,
Showtitle: md.NameCn,
Plot: md.Overview,
ID: strconv.Itoa(md.TmdbID),
Uniqueid: []UniqueId{
{
Text: strconv.Itoa(md.TmdbID),
Type: "tmdb",
Default: "true",
},
{
Text: md.ImdbID,
Type: "imdb",
},
},
}
data, err := xml.MarshalIndent(&show, " ", " ")
if err != nil {
return errors.Wrap(err, "xml marshal")
}
return st.WriteFile(nfoPath, []byte(xml.Header+string(data)))
}
} else if md.MediaType == media.MediaTypeMovie { //movie.nfo
st, err := c.GetStorage(md.StorageID, media.MediaTypeMovie)
if err != nil {
return errors.Wrap(err, "get storage")
}
nfoPath := filepath.Join(md.TargetDir, "movie.nfo")
_, err = st.ReadFile(nfoPath)
if err != nil {
log.Infof("movie.nfo file missing, create new one, tv series name: %s", md.NameEn)
nfoData := Movie{
Title: md.NameCn,
Originaltitle: md.OriginalName,
Sorttitle: md.NameCn,
Plot: md.Overview,
ID: strconv.Itoa(md.TmdbID),
Uniqueid: []UniqueId{
{
Text: strconv.Itoa(md.TmdbID),
Type: "tmdb",
Default: "true",
},
{
Text: md.ImdbID,
Type: "imdb",
},
},
}
data, err := xml.MarshalIndent(&nfoData, " ", " ")
if err != nil {
return errors.Wrap(err, "xml marshal")
}
return st.WriteFile(nfoPath, []byte(xml.Header+string(data)))
}
}
return nil
}
func (c *Engine) writePlexmatch(historyId int) error {
if !c.plexmatchEnabled() {
return nil
}
his := c.db.GetHistory(historyId)
series, err := c.db.GetMedia(his.MediaID)
if err != nil {
return err
}
if series.MediaType != media.MediaTypeTv { //.plexmatch only support tv series
return nil
}
st, err := c.GetStorage(series.StorageID, media.MediaTypeTv)
if err != nil {
return errors.Wrap(err, "get storage")
}
//series plexmatch file
_, err = st.ReadFile(filepath.Join(series.TargetDir, ".plexmatch"))
if err != nil {
//create new
buff := bytes.Buffer{}
if series.ImdbID != "" {
buff.WriteString(fmt.Sprintf("imdbid: %s\n", series.ImdbID))
}
buff.WriteString(fmt.Sprintf("tmdbid: %d\n", series.TmdbID))
log.Warnf(".plexmatch file not found, create new one: %s", series.NameEn)
if err := st.WriteFile(filepath.Join(series.TargetDir, ".plexmatch"), buff.Bytes()); err != nil {
return errors.Wrap(err, "series plexmatch")
}
}
buff := bytes.Buffer{}
seasonPlex := filepath.Join(his.TargetDir, ".plexmatch")
data, err := st.ReadFile(seasonPlex)
if err != nil {
log.Infof("read season plexmatch: %v", err)
} else {
buff.Write(data)
}
episodesIds := c.GetEpisodeIds(his)
for _, id := range episodesIds {
ep, err := c.db.GetEpisodeByID(id)
if err != nil {
log.Warnf("query episode: %v", err)
continue
}
if strings.Contains(buff.String(), ep.TargetFile) {
log.Debugf("already write plex episode line: %v", ep.TargetFile)
return nil
}
buff.WriteString(fmt.Sprintf("\nep: %d: %s\n", ep.EpisodeNumber, ep.TargetFile))
}
log.Infof("write season plexmatch file content: %s", buff.String())
return st.WriteFile(seasonPlex, buff.Bytes())
}
func (c *Engine) plexmatchEnabled() bool {
return c.db.GetSetting(db.SettingPlexMatchEnabled) == "true"
}
func (c *Engine) nfoSupportEnabled() bool {
return c.db.GetSetting(db.SettingNfoSupportEnabled) == "true"
}
func (c *Engine) GetStorage(storageId int, mediaType media.MediaType) (storage.Storage, error) {
st := c.db.GetStorage(storageId)
targetPath := st.TvPath
if mediaType == media.MediaTypeMovie {
targetPath = st.MoviePath
}
videoFormats, err := c.db.GetAcceptedVideoFormats()
if err != nil {
log.Warnf("get accepted video format error: %v", err)
}
subtitleFormats, err := c.db.GetAcceptedSubtitleFormats()
if err != nil {
log.Warnf("get accepted subtitle format error: %v", err)
}
switch st.Implementation {
case storage1.ImplementationLocal:
storageImpl1, err := storage.NewLocalStorage(targetPath, videoFormats, subtitleFormats)
if err != nil {
return nil, errors.Wrap(err, "new local")
}
return storageImpl1, nil
case storage1.ImplementationWebdav:
ws := st.ToWebDavSetting()
storageImpl1, err := storage.NewWebdavStorage(ws.URL, ws.User, ws.Password, targetPath, ws.ChangeFileHash == "true", videoFormats, subtitleFormats)
if err != nil {
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, videoFormats, subtitleFormats)
if err != nil {
return nil, errors.Wrap(err, "alist")
}
return storageImpl1, nil
}
return nil, errors.New("no storage found")
}
func (c *Engine) sendMsg(msg string) {
clients, err := c.db.GetAllNotificationClients2()
if err != nil {
log.Errorf("query notification clients: %v", err)
return
}
for _, cl := range clients {
if !cl.Enabled {
continue
}
handler, ok := notifier.Gethandler(cl.Service)
if !ok {
log.Errorf("no notification implementation of service %s", cl.Service)
continue
}
noCl, err := handler(cl.Settings)
if err != nil {
log.Errorf("handle setting for name %s error: %v", cl.Name, err)
continue
}
err = noCl.SendMsg(msg)
if err != nil {
log.Errorf("send message error: %v", err)
continue
}
log.Debugf("send message to %s success, msg is %s", cl.Name, msg)
}
}
func (c *Engine) findEpisodeFilesPreMoving(historyId int) error {
his := c.db.GetHistory(historyId)
episodeIds := c.GetEpisodeIds(his)
task, _ := c.tasks.Load(historyId)
ff, err := c.db.GetAcceptedVideoFormats()
if err != nil {
return err
}
for _, id := range episodeIds {
ep, err := c.db.GetEpisodeByID(id)
if err != nil {
log.Warnf("query episode error (%d): %v", id, err)
continue
}
task.WalkFunc()(func(path string, info fs.FileInfo) error {
if info.IsDir() {
return nil
}
ext := filepath.Ext(info.Name())
if slices.Contains(ff, ext) {
return nil
}
meta := metadata.ParseTv(info.Name())
if meta.StartEpisode == meta.EndEpisode && meta.StartEpisode == ep.EpisodeNumber {
if err := c.db.UpdateEpisodeTargetFile(id, info.Name()); err != nil {
log.Errorf("writing downloaded file name to db error: %v", err)
}
}
return nil
})
}
return nil
}

253
engine/nfo.go Normal file
View File

@@ -0,0 +1,253 @@
package engine
import "encoding/xml"
type Tvshow struct {
XMLName xml.Name `xml:"tvshow"`
Text string `xml:",chardata"`
Title string `xml:"title"`
Originaltitle string `xml:"originaltitle"`
Showtitle string `xml:"showtitle"`
Ratings struct {
Text string `xml:",chardata"`
Rating []struct {
Text string `xml:",chardata"`
Name string `xml:"name,attr"`
Max string `xml:"max,attr"`
Default string `xml:"default,attr"`
Value string `xml:"value"`
Votes string `xml:"votes"`
} `xml:"rating"`
} `xml:"ratings"`
Userrating string `xml:"userrating"`
Top250 string `xml:"top250"`
Season string `xml:"season"`
Episode string `xml:"episode"`
Displayseason string `xml:"displayseason"`
Displayepisode string `xml:"displayepisode"`
Outline string `xml:"outline"`
Plot string `xml:"plot"`
Tagline string `xml:"tagline"`
Runtime string `xml:"runtime"`
Thumb []struct {
Text string `xml:",chardata"`
Spoof string `xml:"spoof,attr"`
Cache string `xml:"cache,attr"`
Aspect string `xml:"aspect,attr"`
Preview string `xml:"preview,attr"`
Season string `xml:"season,attr"`
Type string `xml:"type,attr"`
} `xml:"thumb"`
Fanart struct {
Text string `xml:",chardata"`
Thumb []struct {
Text string `xml:",chardata"`
Colors string `xml:"colors,attr"`
Preview string `xml:"preview,attr"`
} `xml:"thumb"`
} `xml:"fanart"`
Mpaa string `xml:"mpaa"`
Playcount string `xml:"playcount"`
Lastplayed string `xml:"lastplayed"`
ID string `xml:"id"`
Uniqueid []UniqueId `xml:"uniqueid"`
Genre string `xml:"genre"`
Premiered string `xml:"premiered"`
Year string `xml:"year"`
Status string `xml:"status"`
Code string `xml:"code"`
Aired string `xml:"aired"`
Studio string `xml:"studio"`
Trailer string `xml:"trailer"`
Actor []struct {
Text string `xml:",chardata"`
Name string `xml:"name"`
Role string `xml:"role"`
Order string `xml:"order"`
Thumb string `xml:"thumb"`
} `xml:"actor"`
Namedseason []struct {
Text string `xml:",chardata"`
Number string `xml:"number,attr"`
} `xml:"namedseason"`
Resume struct {
Text string `xml:",chardata"`
Position string `xml:"position"`
Total string `xml:"total"`
} `xml:"resume"`
Dateadded string `xml:"dateadded"`
}
type UniqueId struct {
Text string `xml:",chardata"`
Type string `xml:"type,attr"`
Default string `xml:"default,attr"`
}
type Episodedetails struct {
XMLName xml.Name `xml:"episodedetails"`
Text string `xml:",chardata"`
Title string `xml:"title"`
Showtitle string `xml:"showtitle"`
Ratings struct {
Text string `xml:",chardata"`
Rating []struct {
Text string `xml:",chardata"`
Name string `xml:"name,attr"`
Max string `xml:"max,attr"`
Default string `xml:"default,attr"`
Value string `xml:"value"`
Votes string `xml:"votes"`
} `xml:"rating"`
} `xml:"ratings"`
Userrating string `xml:"userrating"`
Top250 string `xml:"top250"`
Season string `xml:"season"`
Episode string `xml:"episode"`
Displayseason string `xml:"displayseason"`
Displayepisode string `xml:"displayepisode"`
Outline string `xml:"outline"`
Plot string `xml:"plot"`
Tagline string `xml:"tagline"`
Runtime string `xml:"runtime"`
Thumb []struct {
Text string `xml:",chardata"`
Spoof string `xml:"spoof,attr"`
Cache string `xml:"cache,attr"`
Aspect string `xml:"aspect,attr"`
Preview string `xml:"preview,attr"`
} `xml:"thumb"`
Mpaa string `xml:"mpaa"`
Playcount string `xml:"playcount"`
Lastplayed string `xml:"lastplayed"`
ID string `xml:"id"`
Uniqueid []struct {
Text string `xml:",chardata"`
Type string `xml:"type,attr"`
Default string `xml:"default,attr"`
} `xml:"uniqueid"`
Genre string `xml:"genre"`
Credits []string `xml:"credits"`
Director string `xml:"director"`
Premiered string `xml:"premiered"`
Year string `xml:"year"`
Status string `xml:"status"`
Code string `xml:"code"`
Aired string `xml:"aired"`
Studio string `xml:"studio"`
Trailer string `xml:"trailer"`
Actor []struct {
Text string `xml:",chardata"`
Name string `xml:"name"`
Role string `xml:"role"`
Order string `xml:"order"`
Thumb string `xml:"thumb"`
} `xml:"actor"`
Resume struct {
Text string `xml:",chardata"`
Position string `xml:"position"`
Total string `xml:"total"`
} `xml:"resume"`
Dateadded string `xml:"dateadded"`
}
type Movie struct {
XMLName xml.Name `xml:"movie"`
Text string `xml:",chardata"`
Title string `xml:"title"`
Originaltitle string `xml:"originaltitle"`
Sorttitle string `xml:"sorttitle"`
Ratings struct {
Text string `xml:",chardata"`
Rating []struct {
Text string `xml:",chardata"`
Name string `xml:"name,attr"`
Max string `xml:"max,attr"`
Default string `xml:"default,attr"`
Value string `xml:"value"`
Votes string `xml:"votes"`
} `xml:"rating"`
} `xml:"ratings"`
Userrating string `xml:"userrating"`
Top250 string `xml:"top250"`
Outline string `xml:"outline"`
Plot string `xml:"plot"`
Tagline string `xml:"tagline"`
Runtime string `xml:"runtime"`
Thumb []struct {
Text string `xml:",chardata"`
Spoof string `xml:"spoof,attr"`
Cache string `xml:"cache,attr"`
Aspect string `xml:"aspect,attr"`
Preview string `xml:"preview,attr"`
} `xml:"thumb"`
Fanart struct {
Text string `xml:",chardata"`
Thumb struct {
Text string `xml:",chardata"`
Colors string `xml:"colors,attr"`
Preview string `xml:"preview,attr"`
} `xml:"thumb"`
} `xml:"fanart"`
Mpaa string `xml:"mpaa"`
Playcount string `xml:"playcount"`
Lastplayed string `xml:"lastplayed"`
ID string `xml:"id"`
Uniqueid []UniqueId `xml:"uniqueid"`
Genre string `xml:"genre"`
Country []string `xml:"country"`
Set struct {
Text string `xml:",chardata"`
Name string `xml:"name"`
Overview string `xml:"overview"`
} `xml:"set"`
Tag []string `xml:"tag"`
Videoassettitle string `xml:"videoassettitle"`
Videoassetid string `xml:"videoassetid"`
Videoassettype string `xml:"videoassettype"`
Hasvideoversions string `xml:"hasvideoversions"`
Hasvideoextras string `xml:"hasvideoextras"`
Isdefaultvideoversion string `xml:"isdefaultvideoversion"`
Credits []string `xml:"credits"`
Director string `xml:"director"`
Premiered string `xml:"premiered"`
Year string `xml:"year"`
Status string `xml:"status"`
Code string `xml:"code"`
Aired string `xml:"aired"`
Studio string `xml:"studio"`
Trailer string `xml:"trailer"`
Fileinfo struct {
Text string `xml:",chardata"`
Streamdetails struct {
Text string `xml:",chardata"`
Video struct {
Text string `xml:",chardata"`
Codec string `xml:"codec"`
Aspect string `xml:"aspect"`
Width string `xml:"width"`
Height string `xml:"height"`
Durationinseconds string `xml:"durationinseconds"`
Stereomode string `xml:"stereomode"`
Hdrtype string `xml:"hdrtype"`
} `xml:"video"`
Audio struct {
Text string `xml:",chardata"`
Codec string `xml:"codec"`
Language string `xml:"language"`
Channels string `xml:"channels"`
} `xml:"audio"`
Subtitle struct {
Text string `xml:",chardata"`
Language string `xml:"language"`
} `xml:"subtitle"`
} `xml:"streamdetails"`
} `xml:"fileinfo"`
Actor []struct {
Text string `xml:",chardata"`
Name string `xml:"name"`
Role string `xml:"role"`
Order string `xml:"order"`
Thumb string `xml:"thumb"`
} `xml:"actor"`
}

262
engine/resources.go Normal file
View File

@@ -0,0 +1,262 @@
package engine
import (
"bytes"
"fmt"
"polaris/ent"
"polaris/ent/episode"
"polaris/ent/history"
"polaris/ent/media"
"polaris/log"
"polaris/pkg/metadata"
"polaris/pkg/notifier/message"
"polaris/pkg/torznab"
"polaris/pkg/utils"
"github.com/pkg/errors"
)
func (c *Engine) DownloadEpisodeTorrent(r1 torznab.Result, op DownloadOptions) (*string, error) {
series, err := c.db.GetMedia(op.MediaId)
if err != nil {
return nil, fmt.Errorf("no tv series of id %v", op.MediaId)
}
return c.downloadTorrent(series, r1, op)
}
/*
tmdb 校验获取的资源名如果用资源名在tmdb搜索出来的结果能匹配上想要的资源则认为资源有效否则无效
解决名称过于简单的影视会匹配过多资源的问题, 例如:梦魇绝镇 FROM
*/
func (c *Engine) 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, err := c.db.GetMediaDetails(seriesId)
if err != nil {
log.Warnf("get media details error: %v", err)
return false
}
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 *Engine) SearchAndDownload(seriesId, seasonNum int, episodeNums ...int) ([]string, error) {
res, err := SearchTvSeries(c.db, &SearchParam{
MediaId: seriesId,
SeasonNum: seasonNum,
Episodes: episodeNums,
CheckFileSize: true,
CheckResolution: true,
})
if err != nil {
return nil, err
}
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, DownloadOptions{
SeasonNum: seasonNum,
MediaId: seriesId,
HashFilterFn: c.hashInBlacklist,
})
if err != nil {
log.Warnf("download season pack error, continue next item: %v", err)
continue lo
}
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, DownloadOptions{
SeasonNum: seasonNum,
MediaId: seriesId,
EpisodeNums: torrentEpisodes,
HashFilterFn: c.hashInBlacklist,
})
if err != nil {
log.Warnf("download episode error, continue next item: %v", err)
continue lo
}
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 *Engine) DownloadMovie(m *ent.Media, r1 torznab.Result) (*string, error) {
return c.downloadTorrent(m, r1, DownloadOptions{
SeasonNum: 0,
MediaId: m.ID,
})
}
func (c *Engine) hashInBlacklist(hash string) bool {
blacklist, err := c.db.GetTorrentBlacklist()
if err != nil {
log.Warnf("get torrent blacklist error: %v", err)
return false
}
for _, b := range blacklist {
if b.TorrentHash == hash {
return true
}
}
return false
}
func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, op DownloadOptions) (s *string, err1 error) {
trc, dlc, err := c.GetDownloadClient()
if err != nil {
return nil, errors.Wrap(err, "get download client")
}
downloadDir := c.db.GetDownloadDir()
//due to reported bug by user, this will be temporarily disabled
// size := utils.AvailableSpace(downloadDir)
// if size < uint64(r1.Size) {
// log.Errorf("space available %v, space needed %v", size, r1.Size)
// return nil, errors.New("not enough space")
// }
var name = r1.Name
var targetDir = m.TargetDir
if m.MediaType == media.MediaTypeTv { //tv download
targetDir = fmt.Sprintf("%s/Season %02d/", m.TargetDir, op.SeasonNum)
if len(op.EpisodeNums) > 0 {
for _, epNum := range op.EpisodeNums {
ep, err := c.db.GetEpisode(m.ID, op.SeasonNum, epNum)
if err != nil {
return nil, errors.Errorf("no episode of season %d episode %d", op.SeasonNum, epNum)
}
if ep.Status == episode.StatusMissing {
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
defer func(episodeId int) {
if err1 != nil {
c.db.SetEpisodeStatus(episodeId, episode.StatusMissing)
}
}(ep.ID)
}
}
buff := &bytes.Buffer{}
for i, ep := range op.EpisodeNums {
if i != 0 {
buff.WriteString(",")
}
buff.WriteString(fmt.Sprint(ep))
}
name = fmt.Sprintf("第%s集 (%s)", buff.String(), name)
} else { //season package download
name = fmt.Sprintf("全集 (%s)", name)
c.db.SetSeasonAllEpisodeStatus(m.ID, op.SeasonNum, episode.StatusDownloading)
defer func(mediaId int, seasonNum int) {
if err1 != nil {
c.db.SetSeasonAllEpisodeStatus(mediaId, seasonNum, episode.StatusMissing)
}
}(m.ID, op.SeasonNum)
}
} else { //movie download
ep, _ := c.db.GetMovieDummyEpisode(m.ID)
if ep.Status == episode.StatusMissing {
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
defer func(episodeId int) {
if err1 != nil {
c.db.SetEpisodeStatus(episodeId, episode.StatusMissing)
}
}(ep.ID)
}
}
link, hash, err := utils.GetRealLinkAndHash(r1.Link)
if err != nil {
return nil, errors.Wrap(err, "get hash")
}
if op.HashFilterFn != nil && op.HashFilterFn(hash) {
return nil, errors.Errorf("hash is filtered: %s", hash)
}
r1.Link = link
history, err := c.db.SaveHistoryRecord(ent.History{
MediaID: m.ID,
EpisodeNums: op.EpisodeNums,
SeasonNum: op.SeasonNum,
SourceTitle: r1.Name,
TargetDir: targetDir,
Status: history.StatusRunning,
Size: int(r1.Size),
//Saved: torrent.Save(),
Link: r1.Link,
Hash: hash,
DownloadClientID: dlc.ID,
IndexerID: r1.IndexerId,
})
if err != nil {
return nil, errors.Wrap(err, "save record")
}
torrent, err := trc.Download(r1.Link, hash, downloadDir)
if err != nil {
return nil, errors.Wrap(err, "downloading")
}
torrent.Start()
c.tasks.Store(history.ID, &Task{Torrent: torrent})
c.sendMsg(fmt.Sprintf(message.BeginDownload, name))
log.Infof("success add %s to download task", r1.Name)
return &r1.Name, nil
}

579
engine/scheduler.go Normal file
View File

@@ -0,0 +1,579 @@
package engine
import (
"fmt"
"os"
"path/filepath"
"polaris/db"
"polaris/ent"
"polaris/ent/episode"
"polaris/ent/history"
"polaris/ent/media"
"polaris/log"
"polaris/pkg"
"polaris/pkg/notifier/message"
"polaris/pkg/storage"
"polaris/pkg/utils"
"time"
"github.com/pkg/errors"
)
type DownloadOptions struct {
HashFilterFn func(hash string) bool
SeasonNum int
EpisodeNums []int
MediaId int
}
func (c *Engine) addSysCron() {
c.registerCronJob("check_running_tasks", "@every 1m", c.checkTasks)
c.registerCronJob("check_available_medias_to_download", "0 0 * * * *", func() error {
v := os.Getenv("POLARIS_NO_AUTO_DOWNLOAD")
if v == "true" {
return nil
}
if err := c.syncProwlarr(); err != nil {
log.Warnf("sync prowlarr error: %v", err)
}
c.downloadAllTvSeries()
c.downloadAllMovies()
return nil
})
c.registerCronJob("check_series_new_release", "0 0 */12 * * *", c.checkAllSeriesNewSeason)
c.registerCronJob("update_import_lists", "0 */20 * * * *", c.periodicallyUpdateImportlist)
c.registerCronJob("housekeeping", "0 0 2 * * *", c.housekeeping)
go c.housekeeping() //run once on startup
c.schedulers.Range(func(key string, value scheduler) bool {
log.Debugf("add cron job: %v", key)
c.mustAddCron(value.cron, func() {
if err := value.f(); err != nil {
log.Errorf("exexuting cron job %s error: %v", key, err)
}
})
return true
})
c.cron.Start()
log.Infof("--------- add cron jobs done --------")
}
func (c *Engine) mustAddCron(spec string, cmd func()) {
if err := c.cron.AddFunc(spec, cmd); err != nil {
log.Errorf("add func error: %v", err)
panic(err)
}
}
func (c *Engine) TriggerCronJob(name string) error {
job, ok := c.schedulers.Load(name)
if !ok {
return fmt.Errorf("job name not exists: %s", name)
}
return job.f()
}
func (c *Engine) checkTasks() error {
log.Debug("begin check tasks...")
c.tasks.Range(func(id int, t *Task) bool {
r := c.db.GetHistory(id)
if !t.Exists() {
log.Infof("task no longer exists: %v", id)
c.tasks.Delete(id)
return true
}
name, err := t.Name()
if err != nil {
log.Warnf("get task name error: %v", err)
return true
}
progress, err := t.Progress()
if err != nil {
log.Warnf("get task progress error: %v", err)
return true
}
log.Infof("task (%s) percentage done: %d%%", name, progress)
if progress == 100 {
if r.Status == history.StatusSeeding {
//task already success, check seed ratio
torrent, _ := c.tasks.Load(id)
ratio, ok := c.isSeedRatioLimitReached(r.IndexerID, torrent)
if ok {
log.Infof("torrent file seed ratio reached, remove: %v, current seed ratio: %v", name, ratio)
torrent.Remove()
c.tasks.Delete(id)
c.setHistoryStatus(id, history.StatusSuccess)
} else {
log.Infof("torrent file still sedding: %v, current seed ratio: %v", name, ratio)
}
return true
} else if r.Status == history.StatusRunning {
log.Infof("task is done: %v", name)
c.sendMsg(fmt.Sprintf(message.DownloadComplete, name))
go c.postTaskProcessing(id)
}
}
return true
})
return nil
}
/*
episode 状态有3种missing、downloading、downloaded
history状态有5种running, success, fail, uploading, seeding
没有下载的剧集状态都是missing已下载完成的都是downloaded正在下载的是downloading
对应的history状态下载任务创建成功正常跑着是running出了问题失败了就是fail下载完成的任务会先进入uploading状态进一步处理
uploading状态下会传输到对应的存储里面uploading成功如果需要做种会进入seeding状态如果不做种进入success状态失败了会进入fail状态
seeding状态中会定时检查做种状态达到指定分享率会置为success
任务创建成功episode状态会由missing置为downloading如果任务失败重新置为missing如果任务成功进入success或seedingepisode状态应置为downloaded
*/
func (c *Engine) setHistoryStatus(id int, status history.Status) {
r := c.db.GetHistory(id)
episodeIds := c.GetEpisodeIds(r)
switch status {
case history.StatusRunning:
c.db.SetHistoryStatus(id, history.StatusRunning)
c.setEpsideoStatus(episodeIds, episode.StatusDownloading)
case history.StatusSuccess:
c.db.SetHistoryStatus(id, history.StatusSuccess)
c.setEpsideoStatus(episodeIds, episode.StatusDownloaded)
case history.StatusUploading:
c.db.SetHistoryStatus(id, history.StatusUploading)
case history.StatusSeeding:
c.db.SetHistoryStatus(id, history.StatusSeeding)
c.setEpsideoStatus(episodeIds, episode.StatusDownloaded)
case history.StatusFail:
c.db.SetHistoryStatus(id, history.StatusFail)
c.setEpsideoStatus(episodeIds, episode.StatusMissing)
default:
panic(fmt.Sprintf("unkown status %v", status))
}
}
func (c *Engine) setEpsideoStatus(episodeIds []int, status episode.Status) error {
for _, id := range episodeIds {
ep, err := c.db.GetEpisodeByID(id)
if err != nil {
return err
}
if ep.Status == episode.StatusDownloaded {
//已经下载完成的任务,不再重新设置状态
continue
}
if err := c.db.SetEpisodeStatus(id, status); err != nil {
return err
}
}
return nil
}
func (c *Engine) postTaskProcessing(id int) {
if err := c.findEpisodeFilesPreMoving(id); err != nil {
log.Errorf("finding all episode file error: %v", err)
} else {
if err := c.writePlexmatch(id); err != nil {
log.Errorf("write plexmatch file error: %v", err)
}
if err := c.writeNfoFile(id); err != nil {
log.Errorf("write nfo file error: %v", err)
}
}
if err := c.moveCompletedTask(id); err != nil {
log.Infof("post tasks for id %v fail: %v", id, err)
}
}
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 *Engine) GetEpisodeIds(r *ent.History) []int {
series, err := c.db.GetMediaDetails(r.MediaID)
if err != nil {
log.Errorf("get media details error: %v", err)
return []int{}
}
if series.MediaType == media.MediaTypeMovie { //movie
ep, _ := c.db.GetMovieDummyEpisode(series.ID)
return []int{ep.ID}
} else { //tv
var episodeIds []int
seasonNum := getSeasonNum(r)
if len(r.EpisodeNums) > 0 {
for _, epNum := range r.EpisodeNums {
for _, ep := range series.Episodes {
if ep.SeasonNumber == seasonNum && ep.EpisodeNumber == epNum {
episodeIds = append(episodeIds, ep.ID)
}
}
}
} else {
for _, ep := range series.Episodes {
if ep.SeasonNumber == seasonNum {
episodeIds = append(episodeIds, ep.ID)
}
}
}
return episodeIds
}
}
func (c *Engine) moveCompletedTask(id int) (err1 error) {
torrent, _ := c.tasks.Load(id)
r := c.db.GetHistory(id)
// if r.Status == history.StatusUploading {
// log.Infof("task %d is already uploading, skip", id)
// return nil
// }
c.setHistoryStatus(r.ID, history.StatusUploading)
downloadclient, err := c.db.GetDownloadClient(r.DownloadClientID)
if err != nil {
log.Errorf("get task download client error: %v, use default one", err)
downloadclient = &ent.DownloadClients{RemoveCompletedDownloads: true, RemoveFailedDownloads: true}
}
torrentName, err := torrent.Name()
if err != nil {
return err
}
defer func() {
if err1 != nil {
c.setHistoryStatus(r.ID, history.StatusFail)
c.sendMsg(fmt.Sprintf(message.ProcessingFailed, err1))
if downloadclient.RemoveFailedDownloads {
log.Debugf("task failed, remove failed torrent and files related")
c.tasks.Delete(r.ID)
torrent.Remove()
}
}
}()
series, err := c.db.GetMediaDetails(r.MediaID)
if err != nil {
return err
}
st := c.db.GetStorage(series.StorageID)
log.Infof("move task files to target dir: %v", r.TargetDir)
stImpl, err := c.GetStorage(st.ID, series.MediaType)
if err != nil {
return err
}
//如果种子是路径,则会把路径展开,只移动文件,类似 move dir/* dir2/, 如果种子是文件,则会直接移动文件,类似 move file dir/
if err := stImpl.Copy(filepath.Join(c.db.GetDownloadDir(), torrentName), r.TargetDir, torrent.WalkFunc()); err != nil {
if errors.Is(err, &storage.NoVideoFileError{}) {
log.Warnf("no video file found in torrent, add torrent to blacklist: %v", torrentName)
c.db.AddTorrent2Blacklist(r.Hash, r.SourceTitle, r.MediaID)
}
return errors.Wrap(err, "move file")
}
torrent.UploadProgresser = stImpl.UploadProgress
c.sendMsg(fmt.Sprintf(message.ProcessingComplete, torrentName))
//判断是否需要删除本地文件, TODO prowlarr has no indexer id
r1, ok := c.isSeedRatioLimitReached(r.IndexerID, torrent)
if downloadclient.RemoveCompletedDownloads && ok {
log.Debugf("download complete,remove torrent and files related, torrent: %v, seed ratio: %v", torrentName, r1)
c.setHistoryStatus(r.ID, history.StatusSuccess)
c.tasks.Delete(r.ID)
torrent.Remove()
} else {
log.Infof("task complete but still needs seeding: %v", torrentName)
c.setHistoryStatus(r.ID, history.StatusSeeding)
}
log.Infof("move downloaded files to target dir success, file: %v, target dir: %v", torrentName, r.TargetDir)
return nil
}
func (c *Engine) CheckDownloadedSeriesFiles(m *ent.Media) error {
if m.MediaType != media.MediaTypeTv {
return nil
}
log.Infof("check files in directory: %s", m.TargetDir)
var storageImpl, err = c.GetStorage(m.StorageID, media.MediaTypeTv)
if err != nil {
return err
}
files, err := storageImpl.ReadDir(m.TargetDir)
if err != nil {
return errors.Wrapf(err, "read dir %s", m.TargetDir)
}
for _, in := range files {
if !in.IsDir() { //season dir, ignore file
continue
}
dir := filepath.Join(m.TargetDir, in.Name())
epFiles, err := storageImpl.ReadDir(dir)
if err != nil {
log.Errorf("read dir %s error: %v", dir, err)
continue
}
for _, ep := range epFiles {
log.Infof("found file: %v", ep.Name())
seNum, epNum, err := utils.FindSeasonEpisodeNum(ep.Name())
if err != nil {
log.Errorf("find season episode num error: %v", err)
continue
}
log.Infof("found match, season num %d, episode num %d", seNum, epNum)
ep, err := c.db.GetEpisode(m.ID, seNum, epNum)
if err != nil {
log.Error("update episode: %v", err)
continue
}
err = c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloaded)
if err != nil {
log.Error("update episode: %v", err)
continue
}
}
}
return nil
}
type Task struct {
//Processing bool
pkg.Torrent
UploadProgresser func() float64
}
func (c *Engine) DownloadSeriesAllEpisodes(id int) []string {
tvDetail, err := c.db.GetMediaDetails(id)
if err != nil {
log.Errorf("get media details error: %v", err)
return nil
}
m := make(map[int][]*ent.Episode)
for _, ep := range tvDetail.Episodes {
m[ep.SeasonNumber] = append(m[ep.SeasonNumber], ep)
}
var allNames []string
for seasonNum, epsides := range m {
if seasonNum == 0 {
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 {
names, err := c.SearchAndDownload(id, seasonNum)
if err == nil {
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 se, eps := range seasonEpisodesWanted {
names, err := c.SearchAndDownload(id, se, eps...)
if err != nil {
log.Warnf("finding resoruces of season %d episode %v error: %v", se, eps, err)
continue
} else {
allNames = append(allNames, names...)
log.Infof("begin download torrent resource: %v", names)
}
}
}
}
return allNames
}
func (c *Engine) downloadAllTvSeries() {
log.Infof("begin check all tv series resources")
allSeries := c.db.GetMediaWatchlist(media.MediaTypeTv)
for _, series := range allSeries {
c.DownloadSeriesAllEpisodes(series.ID)
}
}
func (c *Engine) downloadAllMovies() {
log.Infof("begin check all movie resources")
allSeries := c.db.GetMediaWatchlist(media.MediaTypeMovie)
for _, series := range allSeries {
if _, err := c.DownloadMovieByID(series.ID); err != nil {
log.Errorf("download movie error: %v", err)
}
}
}
func (c *Engine) DownloadMovieByID(id int) (string, error) {
detail, err := c.db.GetMediaDetails(id)
if err != nil {
return "", errors.Wrap(err, "get media details")
}
if len(detail.Episodes) == 0 {
return "", fmt.Errorf("no related dummy episode: %v", detail.NameEn)
}
ep := detail.Episodes[0]
if ep.Status != episode.StatusMissing {
return "", nil
}
if name, err := c.downloadMovieSingleEpisode(detail.Media, ep); err != nil {
return "", errors.Wrap(err, "download movie")
} else {
return name, nil
}
}
func (c *Engine) downloadMovieSingleEpisode(m *ent.Media, ep *ent.Episode) (string, error) {
qiangban := c.db.GetSetting(db.SettingAllowQiangban)
allowQiangban := false
if qiangban == "true" {
allowQiangban = false
}
res, err := SearchMovie(c.db, &SearchParam{
MediaId: ep.MediaID,
CheckFileSize: true,
CheckResolution: true,
FilterQiangban: !allowQiangban,
})
if err != nil {
return "", errors.Wrap(err, "search movie")
}
r1 := res[0]
log.Infof("begin download torrent resource: %v", r1.Name)
s, err := c.downloadTorrent(m, r1, DownloadOptions{MediaId: m.ID, SeasonNum: 0, HashFilterFn: c.hashInBlacklist})
if err != nil {
return "", err
}
return *s, nil
}
func (c *Engine) checkAllSeriesNewSeason() error {
log.Infof("begin checking series all new season")
allSeries := c.db.GetMediaWatchlist(media.MediaTypeTv)
for _, series := range allSeries {
err := c.checkSeiesNewSeason(series)
if err != nil {
log.Errorf("check series new season error: series name %v, error: %v", series.NameEn, err)
}
}
return nil
}
func (c *Engine) checkSeiesNewSeason(media *ent.Media) error {
d, err := c.MustTMDB().GetTvDetails(media.TmdbID, c.language)
if err != nil {
return errors.Wrap(err, "tmdb")
}
lastsSason := d.NumberOfSeasons
seasonDetail, err := c.MustTMDB().GetSeasonDetails(media.TmdbID, lastsSason, c.language)
if err != nil {
return errors.Wrap(err, "tmdb season")
}
for _, ep := range seasonDetail.Episodes {
epDb, err := c.db.GetEpisode(media.ID, ep.SeasonNumber, ep.EpisodeNumber)
if err != nil {
if ent.IsNotFound(err) {
log.Infof("add new episode: %+v", ep)
episode := &ent.Episode{
MediaID: media.ID,
SeasonNumber: ep.SeasonNumber,
EpisodeNumber: ep.EpisodeNumber,
Title: ep.Name,
Overview: ep.Overview,
AirDate: ep.AirDate,
Status: episode.StatusMissing,
Monitored: true,
}
c.db.SaveEposideDetail2(episode)
}
} else { //update episode
if ep.Name != epDb.Title || ep.Overview != epDb.Overview || ep.AirDate != epDb.AirDate {
log.Infof("update new episode: %+v", ep)
c.db.UpdateEpiode2(epDb.ID, ep.Name, ep.Overview, ep.AirDate)
}
}
}
return nil
}
func (c *Engine) isSeedRatioLimitReached(indexId int, t pkg.Torrent) (float64, bool) {
indexer, err := c.db.GetIndexer(indexId)
if err != nil {
return 0, true
}
currentRatio, err := t.SeedRatio()
if err != nil {
log.Warnf("get current seed ratio error: %v", err)
return currentRatio, indexer.SeedRatio == 0
}
return currentRatio, currentRatio >= float64(indexer.SeedRatio)
}

56
engine/stun.go Normal file
View File

@@ -0,0 +1,56 @@
package engine
import (
"fmt"
"net/url"
"polaris/ent/downloadclients"
"polaris/log"
"polaris/pkg/nat"
"polaris/pkg/qbittorrent"
"github.com/pion/stun/v3"
)
func (s *Engine) stunProxyDownloadClient() error {
return s.StartStunProxy("")
}
func (s *Engine) StartStunProxy(name string) error {
downloaders := s.db.GetAllDonloadClients()
for _, d := range downloaders {
if !d.Enable {
continue
}
if !d.UseNatTraversal {
continue
}
if name != "" && d.Name != name {
continue
}
if d.Implementation != downloadclients.ImplementationQbittorrent { //TODO only support qbittorrent for now
continue
}
qbt, err := qbittorrent.NewClient(d.URL, d.User, d.Password)
if err != nil {
return fmt.Errorf("connect to download client error: %v", d.URL)
}
u, err := url.Parse(d.URL)
if err != nil {
return err
}
log.Infof("start stun proxy for %s", d.Name)
n, err := nat.NewNatTraversal(func(xa stun.XORMappedAddress) error {
return qbt.SetListenPort(xa.Port)
}, u.Hostname())
if err != nil {
return err
}
n.StartProxy()
}
return nil
}

460
engine/torrent.go Normal file
View File

@@ -0,0 +1,460 @@
package engine
import (
"fmt"
"polaris/db"
"polaris/ent"
"polaris/ent/media"
"polaris/log"
"polaris/pkg/metadata"
"polaris/pkg/torznab"
"slices"
"sort"
"strconv"
"strings"
"sync"
"time"
"github.com/pkg/errors"
)
type SearchParam struct {
MediaId int
SeasonNum int //for tv
Episodes []int //for tv
CheckResolution bool
CheckFileSize bool
FilterQiangban bool //for movie, 是否过滤枪版电影
}
func names2Query(media *ent.Media) []string {
var names = []string{media.NameEn}
if media.NameCn != "" {
hasName := false
for _, n := range names {
if media.NameCn == n {
hasName = true
}
}
if !hasName {
names = append(names, media.NameCn)
}
}
if media.OriginalName != "" {
hasName := false
for _, n := range names {
if media.OriginalName == n {
hasName = true
}
}
if !hasName {
names = append(names, media.OriginalName)
}
}
for _, t := range media.AlternativeTitles {
if (t.Iso3166_1 == "CN" || t.Iso3166_1 == "US") && t.Type == "" {
hasName := false
for _, n := range names {
if t.Title == n {
hasName = true
}
}
if !hasName {
names = append(names, t.Title)
}
}
}
log.Debugf("name to query %+v", names)
return names
}
func getSeasonReleaseYear(series *db.MediaDetails, seasonNum int) int {
if seasonNum == 0 {
return 0
}
releaseYear := 0
for _, s := range series.Episodes {
if s.SeasonNumber == seasonNum && s.AirDate != "" {
ss := strings.Split(s.AirDate, "-")[0]
y, err := strconv.Atoi(ss)
if err != nil {
continue
}
releaseYear = y
break
}
}
return releaseYear
}
func SearchTvSeries(db1 db.Database, param *SearchParam) ([]torznab.Result, error) {
series, err := db1.GetMediaDetails(param.MediaId)
if err != nil {
return nil, fmt.Errorf("no tv series of id %v: %v", param.MediaId, err)
}
limiter, err := db1.GetSizeLimiter("tv")
if err != nil {
log.Warnf("get tv size limiter: %v", err)
limiter = &db.MediaSizeLimiter{}
}
log.Debugf("check tv series %s, season %d, episode %v", series.NameEn, param.SeasonNum, param.Episodes)
names := names2Query(series.Media)
res := searchWithTorznab(db1, SearchTypeTv, names...)
ss := strings.Split(series.AirDate, "-")[0]
releaseYear, _ := strconv.Atoi(ss)
seasonYear := getSeasonReleaseYear(series, param.SeasonNum)
var filtered []torznab.Result
lo:
for _, r := range res {
//log.Infof("torrent resource: %+v", r)
meta := metadata.ParseTv(r.Name)
meta.ParseExtraDescription(r.Description)
if isImdbidNotMatch(series.ImdbID, r.ImdbId) { //has imdb id and not match
continue
}
if !imdbIDMatchExact(series.ImdbID, r.ImdbId) { //imdb id not exact match, check file name
if !torrentNameOk(series, meta) {
continue
}
if meta.Year > 0 && releaseYear > 0 {
if meta.Year != releaseYear && meta.Year != releaseYear-1 && meta.Year != releaseYear+1 { //year not match
if seasonYear > 0 { // if tv release year is not match, check season release year
if meta.Year != seasonYear && meta.Year != seasonYear-1 && meta.Year != seasonYear+1 { //season year not match
continue lo
}
} else {
continue lo
}
}
}
}
if !isNoSeasonSeries(series) && meta.Season != param.SeasonNum { //do not check season on series that only rely on episode number
continue
}
if isNoSeasonSeries(series) && len(param.Episodes) == 0 {
//should not want season
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
}
if param.CheckResolution &&
series.Resolution != media.ResolutionAny &&
meta.Resolution != series.Resolution.String() {
continue
}
if !torrentSizeOk(series, limiter, r.Size, meta.EndEpisode+1-meta.StartEpisode, param) {
continue
}
filtered = append(filtered, r)
}
if len(filtered) == 0 {
return nil, errors.New("no resource found")
}
filtered = dedup(filtered)
return filtered, nil
}
// imdbid not exist consider match
func isImdbidNotMatch(id1, id2 string) bool {
if id1 == "" || id2 == "" {
return false
}
id1 = strings.TrimPrefix(id1, "tt")
id2 = strings.TrimPrefix(id2, "tt")
return id1 != id2
}
// imdbid not exist consider not match
func imdbIDMatchExact(id1, id2 string) bool {
if id1 == "" || id2 == "" {
return false
}
id1 = strings.TrimPrefix(id1, "tt")
id2 = strings.TrimPrefix(id2, "tt")
return id1 == id2
}
func torrentSizeOk(detail *db.MediaDetails, globalLimiter *db.MediaSizeLimiter, torrentSize int64,
torrentEpisodeNum int, param *SearchParam) bool {
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
if detail.Limiter.SizeMin > 0 { //min size
sizeMin := detail.Limiter.SizeMin * int64(multiplier)
if torrentSize < sizeMin { //比最小要求的大小还要小, min size not qualify
return false
}
} else if globalLimiter != nil {
resLimiter := globalLimiter.GetLimiter(detail.Resolution)
sizeMin := resLimiter.MinSize * int64(multiplier)
if torrentSize < sizeMin { //比最小要求的大小还要小, min size not qualify
return false
}
}
if detail.Limiter.SizeMax > 0 { //max size
sizeMax := detail.Limiter.SizeMax * int64(multiplier)
if torrentSize > sizeMax { //larger than max size wanted, max size not qualify
return false
}
} else if globalLimiter != nil {
resLimiter := globalLimiter.GetLimiter(detail.Resolution)
sizeMax := resLimiter.MaxSIze * int64(multiplier)
if torrentSize > sizeMax { //larger than max size wanted, max size not qualify
return false
}
}
}
return true
}
func seasonEpisodeCount(detail *db.MediaDetails, seasonNum int) int {
count := 0
for _, ep := range detail.Episodes {
if ep.SeasonNumber == seasonNum {
count++
}
}
return count
}
func isNoSeasonSeries(detail *db.MediaDetails) bool {
hasSeason2 := false
season2HasEpisode1 := false
for _, ep := range detail.Episodes {
if ep.SeasonNumber == 2 {
hasSeason2 = true
if ep.EpisodeNumber == 1 {
season2HasEpisode1 = true
}
}
}
return hasSeason2 && !season2HasEpisode1 //only one 1st episode
}
func SearchMovie(db1 db.Database, param *SearchParam) ([]torznab.Result, error) {
movieDetail, err := db1.GetMediaDetails(param.MediaId)
if err != nil {
return nil, err
}
limiter, err := db1.GetSizeLimiter("movie")
if err != nil {
log.Warnf("get tv size limiter: %v", err)
limiter = &db.MediaSizeLimiter{}
}
names := names2Query(movieDetail.Media)
res := searchWithTorznab(db1, SearchTypeMovie, names...)
if movieDetail.Extras.IsJav() {
res1 := searchWithTorznab(db1, SearchTypeMovie, movieDetail.Extras.JavId)
res = append(res, res1...)
}
if len(res) == 0 {
return nil, fmt.Errorf("no resource found")
}
var filtered []torznab.Result
for _, r := range res {
meta := metadata.ParseMovie(r.Name)
if isImdbidNotMatch(movieDetail.ImdbID, r.ImdbId) { //imdb id not match
continue
}
if !imdbIDMatchExact(movieDetail.ImdbID, r.ImdbId) {
if !torrentNameOk(movieDetail, meta) {
continue
}
if !movieDetail.Extras.IsJav() {
ss := strings.Split(movieDetail.AirDate, "-")[0]
year, _ := strconv.Atoi(ss)
if meta.Year != year && meta.Year != year-1 && meta.Year != year+1 { //year not match
continue
}
}
}
if param.CheckResolution &&
movieDetail.Resolution != media.ResolutionAny &&
meta.Resolution != movieDetail.Resolution.String() {
continue
}
if param.FilterQiangban && meta.IsQingban { //过滤枪版电影
continue
}
if !torrentSizeOk(movieDetail, limiter, r.Size, 1, param) {
continue
}
filtered = append(filtered, r)
}
if len(filtered) == 0 {
return nil, errors.New("no resource found")
}
filtered = dedup(filtered)
return filtered, nil
}
type SearchType int
const (
SearchTypeTv SearchType = 1
SearchTypeMovie SearchType = 2
)
func searchWithTorznab(db db.Database, t SearchType, queries ...string) []torznab.Result {
t1 := time.Now()
defer func() {
log.Infof("search with torznab took %v", time.Since(t1))
}()
var res []torznab.Result
allTorznab := db.GetAllIndexers()
resChan := make(chan []torznab.Result)
var wg sync.WaitGroup
for _, tor := range allTorznab {
if tor.Disabled {
continue
}
if t == SearchTypeTv && !tor.TvSearch {
continue
}
if t == SearchTypeMovie && !tor.MovieSearch {
continue
}
for _, q := range queries {
wg.Add(1)
go func() {
log.Debugf("search torznab %v with %v", tor.Name, queries)
defer wg.Done()
resp, err := torznab.Search(tor, q)
if err != nil {
log.Warnf("search %s with query %s error: %v", tor.Name, q, err)
return
}
resChan <- resp
}()
}
}
go func() {
wg.Wait()
close(resChan) // 在所有的worker完成后关闭Channel
}()
for result := range resChan {
res = append(res, result...)
}
res = dedup(res)
sort.SliceStable(res, func(i, j int) bool { //先按做种人数排序
var s1 = res[i]
var s2 = res[j]
return s1.Seeders > s2.Seeders
})
sort.SliceStable(res, func(i, j int) bool { //再按优先级排序,优先级高的种子排前面
var s1 = res[i]
var s2 = res[j]
return s1.Priority < s2.Priority
})
//pt资源中同一indexer内部优先下载free的资源
sort.SliceStable(res, func(i, j int) bool {
var s1 = res[i]
var s2 = res[j]
if s1.IndexerId == s2.IndexerId && s1.IsPrivate {
return s1.DownloadVolumeFactor < s2.DownloadVolumeFactor
}
return false
})
//同一indexer内部如果下载消耗一样则优先下载上传奖励较多的
sort.SliceStable(res, func(i, j int) bool {
var s1 = res[i]
var s2 = res[j]
if s1.IndexerId == s2.IndexerId && s1.IsPrivate && s1.DownloadVolumeFactor == s2.DownloadVolumeFactor {
return s1.UploadVolumeFactor > s2.UploadVolumeFactor
}
return false
})
return res
}
func dedup(list []torznab.Result) []torznab.Result {
var res = make([]torznab.Result, 0, len(list))
seen := make(map[string]bool, 0)
for _, r := range list {
key := fmt.Sprintf("%s%s%d%d", r.Name, r.Source, r.Seeders, r.Peers)
if seen[key] {
continue
}
seen[key] = true
res = append(res, r)
}
return res
}
type NameTester interface {
IsAcceptable(names ...string) bool
}
func torrentNameOk(detail *db.MediaDetails, tester NameTester) bool {
if detail.Extras.IsJav() && tester.IsAcceptable(detail.Extras.JavId) {
return true
}
names := names2Query(detail.Media)
return tester.IsAcceptable(names...)
}

161
ent/blacklist.go Normal file
View File

@@ -0,0 +1,161 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"polaris/ent/blacklist"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Blacklist is the model entity for the Blacklist schema.
type Blacklist struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Type holds the value of the "type" field.
Type blacklist.Type `json:"type,omitempty"`
// TorrentHash holds the value of the "torrent_hash" field.
TorrentHash string `json:"torrent_hash,omitempty"`
// TorrentName holds the value of the "torrent_name" field.
TorrentName string `json:"torrent_name,omitempty"`
// MediaID holds the value of the "media_id" field.
MediaID int `json:"media_id,omitempty"`
// CreateTime holds the value of the "create_time" field.
CreateTime time.Time `json:"create_time,omitempty"`
// Notes holds the value of the "notes" field.
Notes string `json:"notes,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Blacklist) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case blacklist.FieldID, blacklist.FieldMediaID:
values[i] = new(sql.NullInt64)
case blacklist.FieldType, blacklist.FieldTorrentHash, blacklist.FieldTorrentName, blacklist.FieldNotes:
values[i] = new(sql.NullString)
case blacklist.FieldCreateTime:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Blacklist fields.
func (b *Blacklist) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case blacklist.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
b.ID = int(value.Int64)
case blacklist.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
b.Type = blacklist.Type(value.String)
}
case blacklist.FieldTorrentHash:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field torrent_hash", values[i])
} else if value.Valid {
b.TorrentHash = value.String
}
case blacklist.FieldTorrentName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field torrent_name", values[i])
} else if value.Valid {
b.TorrentName = value.String
}
case blacklist.FieldMediaID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field media_id", values[i])
} else if value.Valid {
b.MediaID = int(value.Int64)
}
case blacklist.FieldCreateTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field create_time", values[i])
} else if value.Valid {
b.CreateTime = value.Time
}
case blacklist.FieldNotes:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field notes", values[i])
} else if value.Valid {
b.Notes = value.String
}
default:
b.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Blacklist.
// This includes values selected through modifiers, order, etc.
func (b *Blacklist) Value(name string) (ent.Value, error) {
return b.selectValues.Get(name)
}
// Update returns a builder for updating this Blacklist.
// Note that you need to call Blacklist.Unwrap() before calling this method if this Blacklist
// was returned from a transaction, and the transaction was committed or rolled back.
func (b *Blacklist) Update() *BlacklistUpdateOne {
return NewBlacklistClient(b.config).UpdateOne(b)
}
// Unwrap unwraps the Blacklist entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (b *Blacklist) Unwrap() *Blacklist {
_tx, ok := b.config.driver.(*txDriver)
if !ok {
panic("ent: Blacklist is not a transactional entity")
}
b.config.driver = _tx.drv
return b
}
// String implements the fmt.Stringer.
func (b *Blacklist) String() string {
var builder strings.Builder
builder.WriteString("Blacklist(")
builder.WriteString(fmt.Sprintf("id=%v, ", b.ID))
builder.WriteString("type=")
builder.WriteString(fmt.Sprintf("%v", b.Type))
builder.WriteString(", ")
builder.WriteString("torrent_hash=")
builder.WriteString(b.TorrentHash)
builder.WriteString(", ")
builder.WriteString("torrent_name=")
builder.WriteString(b.TorrentName)
builder.WriteString(", ")
builder.WriteString("media_id=")
builder.WriteString(fmt.Sprintf("%v", b.MediaID))
builder.WriteString(", ")
builder.WriteString("create_time=")
builder.WriteString(b.CreateTime.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("notes=")
builder.WriteString(b.Notes)
builder.WriteByte(')')
return builder.String()
}
// Blacklists is a parsable slice of Blacklist.
type Blacklists []*Blacklist

121
ent/blacklist/blacklist.go Normal file
View File

@@ -0,0 +1,121 @@
// Code generated by ent, DO NOT EDIT.
package blacklist
import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the blacklist type in the database.
Label = "blacklist"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldTorrentHash holds the string denoting the torrent_hash field in the database.
FieldTorrentHash = "torrent_hash"
// FieldTorrentName holds the string denoting the torrent_name field in the database.
FieldTorrentName = "torrent_name"
// FieldMediaID holds the string denoting the media_id field in the database.
FieldMediaID = "media_id"
// FieldCreateTime holds the string denoting the create_time field in the database.
FieldCreateTime = "create_time"
// FieldNotes holds the string denoting the notes field in the database.
FieldNotes = "notes"
// Table holds the table name of the blacklist in the database.
Table = "blacklists"
)
// Columns holds all SQL columns for blacklist fields.
var Columns = []string{
FieldID,
FieldType,
FieldTorrentHash,
FieldTorrentName,
FieldMediaID,
FieldCreateTime,
FieldNotes,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreateTime holds the default value on creation for the "create_time" field.
DefaultCreateTime func() time.Time
)
// Type defines the type for the "type" enum field.
type Type string
// TypeTorrent is the default value of the Type enum.
const DefaultType = TypeTorrent
// Type values.
const (
TypeMedia Type = "media"
TypeTorrent Type = "torrent"
)
func (_type Type) String() string {
return string(_type)
}
// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
func TypeValidator(_type Type) error {
switch _type {
case TypeMedia, TypeTorrent:
return nil
default:
return fmt.Errorf("blacklist: invalid enum value for type field: %q", _type)
}
}
// OrderOption defines the ordering options for the Blacklist queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldType, opts...).ToFunc()
}
// ByTorrentHash orders the results by the torrent_hash field.
func ByTorrentHash(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTorrentHash, opts...).ToFunc()
}
// ByTorrentName orders the results by the torrent_name field.
func ByTorrentName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTorrentName, opts...).ToFunc()
}
// ByMediaID orders the results by the media_id field.
func ByMediaID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMediaID, opts...).ToFunc()
}
// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}
// ByNotes orders the results by the notes field.
func ByNotes(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNotes, opts...).ToFunc()
}

440
ent/blacklist/where.go Normal file
View File

@@ -0,0 +1,440 @@
// Code generated by ent, DO NOT EDIT.
package blacklist
import (
"polaris/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldID, id))
}
// TorrentHash applies equality check predicate on the "torrent_hash" field. It's identical to TorrentHashEQ.
func TorrentHash(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldTorrentHash, v))
}
// TorrentName applies equality check predicate on the "torrent_name" field. It's identical to TorrentNameEQ.
func TorrentName(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldTorrentName, v))
}
// MediaID applies equality check predicate on the "media_id" field. It's identical to MediaIDEQ.
func MediaID(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldMediaID, v))
}
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
func CreateTime(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldCreateTime, v))
}
// Notes applies equality check predicate on the "notes" field. It's identical to NotesEQ.
func Notes(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldNotes, v))
}
// TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v Type) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldType, v))
}
// TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v Type) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldType, v))
}
// TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...Type) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldType, vs...))
}
// TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...Type) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldType, vs...))
}
// TorrentHashEQ applies the EQ predicate on the "torrent_hash" field.
func TorrentHashEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldTorrentHash, v))
}
// TorrentHashNEQ applies the NEQ predicate on the "torrent_hash" field.
func TorrentHashNEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldTorrentHash, v))
}
// TorrentHashIn applies the In predicate on the "torrent_hash" field.
func TorrentHashIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldTorrentHash, vs...))
}
// TorrentHashNotIn applies the NotIn predicate on the "torrent_hash" field.
func TorrentHashNotIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldTorrentHash, vs...))
}
// TorrentHashGT applies the GT predicate on the "torrent_hash" field.
func TorrentHashGT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldTorrentHash, v))
}
// TorrentHashGTE applies the GTE predicate on the "torrent_hash" field.
func TorrentHashGTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldTorrentHash, v))
}
// TorrentHashLT applies the LT predicate on the "torrent_hash" field.
func TorrentHashLT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldTorrentHash, v))
}
// TorrentHashLTE applies the LTE predicate on the "torrent_hash" field.
func TorrentHashLTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldTorrentHash, v))
}
// TorrentHashContains applies the Contains predicate on the "torrent_hash" field.
func TorrentHashContains(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContains(FieldTorrentHash, v))
}
// TorrentHashHasPrefix applies the HasPrefix predicate on the "torrent_hash" field.
func TorrentHashHasPrefix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasPrefix(FieldTorrentHash, v))
}
// TorrentHashHasSuffix applies the HasSuffix predicate on the "torrent_hash" field.
func TorrentHashHasSuffix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasSuffix(FieldTorrentHash, v))
}
// TorrentHashIsNil applies the IsNil predicate on the "torrent_hash" field.
func TorrentHashIsNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldIsNull(FieldTorrentHash))
}
// TorrentHashNotNil applies the NotNil predicate on the "torrent_hash" field.
func TorrentHashNotNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotNull(FieldTorrentHash))
}
// TorrentHashEqualFold applies the EqualFold predicate on the "torrent_hash" field.
func TorrentHashEqualFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEqualFold(FieldTorrentHash, v))
}
// TorrentHashContainsFold applies the ContainsFold predicate on the "torrent_hash" field.
func TorrentHashContainsFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContainsFold(FieldTorrentHash, v))
}
// TorrentNameEQ applies the EQ predicate on the "torrent_name" field.
func TorrentNameEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldTorrentName, v))
}
// TorrentNameNEQ applies the NEQ predicate on the "torrent_name" field.
func TorrentNameNEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldTorrentName, v))
}
// TorrentNameIn applies the In predicate on the "torrent_name" field.
func TorrentNameIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldTorrentName, vs...))
}
// TorrentNameNotIn applies the NotIn predicate on the "torrent_name" field.
func TorrentNameNotIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldTorrentName, vs...))
}
// TorrentNameGT applies the GT predicate on the "torrent_name" field.
func TorrentNameGT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldTorrentName, v))
}
// TorrentNameGTE applies the GTE predicate on the "torrent_name" field.
func TorrentNameGTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldTorrentName, v))
}
// TorrentNameLT applies the LT predicate on the "torrent_name" field.
func TorrentNameLT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldTorrentName, v))
}
// TorrentNameLTE applies the LTE predicate on the "torrent_name" field.
func TorrentNameLTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldTorrentName, v))
}
// TorrentNameContains applies the Contains predicate on the "torrent_name" field.
func TorrentNameContains(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContains(FieldTorrentName, v))
}
// TorrentNameHasPrefix applies the HasPrefix predicate on the "torrent_name" field.
func TorrentNameHasPrefix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasPrefix(FieldTorrentName, v))
}
// TorrentNameHasSuffix applies the HasSuffix predicate on the "torrent_name" field.
func TorrentNameHasSuffix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasSuffix(FieldTorrentName, v))
}
// TorrentNameIsNil applies the IsNil predicate on the "torrent_name" field.
func TorrentNameIsNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldIsNull(FieldTorrentName))
}
// TorrentNameNotNil applies the NotNil predicate on the "torrent_name" field.
func TorrentNameNotNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotNull(FieldTorrentName))
}
// TorrentNameEqualFold applies the EqualFold predicate on the "torrent_name" field.
func TorrentNameEqualFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEqualFold(FieldTorrentName, v))
}
// TorrentNameContainsFold applies the ContainsFold predicate on the "torrent_name" field.
func TorrentNameContainsFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContainsFold(FieldTorrentName, v))
}
// MediaIDEQ applies the EQ predicate on the "media_id" field.
func MediaIDEQ(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldMediaID, v))
}
// MediaIDNEQ applies the NEQ predicate on the "media_id" field.
func MediaIDNEQ(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldMediaID, v))
}
// MediaIDIn applies the In predicate on the "media_id" field.
func MediaIDIn(vs ...int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldMediaID, vs...))
}
// MediaIDNotIn applies the NotIn predicate on the "media_id" field.
func MediaIDNotIn(vs ...int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldMediaID, vs...))
}
// MediaIDGT applies the GT predicate on the "media_id" field.
func MediaIDGT(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldMediaID, v))
}
// MediaIDGTE applies the GTE predicate on the "media_id" field.
func MediaIDGTE(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldMediaID, v))
}
// MediaIDLT applies the LT predicate on the "media_id" field.
func MediaIDLT(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldMediaID, v))
}
// MediaIDLTE applies the LTE predicate on the "media_id" field.
func MediaIDLTE(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldMediaID, v))
}
// MediaIDIsNil applies the IsNil predicate on the "media_id" field.
func MediaIDIsNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldIsNull(FieldMediaID))
}
// MediaIDNotNil applies the NotNil predicate on the "media_id" field.
func MediaIDNotNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotNull(FieldMediaID))
}
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
func CreateTimeEQ(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldCreateTime, v))
}
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
func CreateTimeNEQ(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldCreateTime, v))
}
// CreateTimeIn applies the In predicate on the "create_time" field.
func CreateTimeIn(vs ...time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldCreateTime, vs...))
}
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
func CreateTimeNotIn(vs ...time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldCreateTime, vs...))
}
// CreateTimeGT applies the GT predicate on the "create_time" field.
func CreateTimeGT(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldCreateTime, v))
}
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
func CreateTimeGTE(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldCreateTime, v))
}
// CreateTimeLT applies the LT predicate on the "create_time" field.
func CreateTimeLT(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldCreateTime, v))
}
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
func CreateTimeLTE(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldCreateTime, v))
}
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
func CreateTimeIsNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldIsNull(FieldCreateTime))
}
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
func CreateTimeNotNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotNull(FieldCreateTime))
}
// NotesEQ applies the EQ predicate on the "notes" field.
func NotesEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldNotes, v))
}
// NotesNEQ applies the NEQ predicate on the "notes" field.
func NotesNEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldNotes, v))
}
// NotesIn applies the In predicate on the "notes" field.
func NotesIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldNotes, vs...))
}
// NotesNotIn applies the NotIn predicate on the "notes" field.
func NotesNotIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldNotes, vs...))
}
// NotesGT applies the GT predicate on the "notes" field.
func NotesGT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldNotes, v))
}
// NotesGTE applies the GTE predicate on the "notes" field.
func NotesGTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldNotes, v))
}
// NotesLT applies the LT predicate on the "notes" field.
func NotesLT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldNotes, v))
}
// NotesLTE applies the LTE predicate on the "notes" field.
func NotesLTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldNotes, v))
}
// NotesContains applies the Contains predicate on the "notes" field.
func NotesContains(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContains(FieldNotes, v))
}
// NotesHasPrefix applies the HasPrefix predicate on the "notes" field.
func NotesHasPrefix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasPrefix(FieldNotes, v))
}
// NotesHasSuffix applies the HasSuffix predicate on the "notes" field.
func NotesHasSuffix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasSuffix(FieldNotes, v))
}
// NotesIsNil applies the IsNil predicate on the "notes" field.
func NotesIsNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldIsNull(FieldNotes))
}
// NotesNotNil applies the NotNil predicate on the "notes" field.
func NotesNotNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotNull(FieldNotes))
}
// NotesEqualFold applies the EqualFold predicate on the "notes" field.
func NotesEqualFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEqualFold(FieldNotes, v))
}
// NotesContainsFold applies the ContainsFold predicate on the "notes" field.
func NotesContainsFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContainsFold(FieldNotes, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Blacklist) predicate.Blacklist {
return predicate.Blacklist(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Blacklist) predicate.Blacklist {
return predicate.Blacklist(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.Blacklist) predicate.Blacklist {
return predicate.Blacklist(sql.NotPredicates(p))
}

301
ent/blacklist_create.go Normal file
View File

@@ -0,0 +1,301 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"polaris/ent/blacklist"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// BlacklistCreate is the builder for creating a Blacklist entity.
type BlacklistCreate struct {
config
mutation *BlacklistMutation
hooks []Hook
}
// SetType sets the "type" field.
func (bc *BlacklistCreate) SetType(b blacklist.Type) *BlacklistCreate {
bc.mutation.SetType(b)
return bc
}
// SetNillableType sets the "type" field if the given value is not nil.
func (bc *BlacklistCreate) SetNillableType(b *blacklist.Type) *BlacklistCreate {
if b != nil {
bc.SetType(*b)
}
return bc
}
// SetTorrentHash sets the "torrent_hash" field.
func (bc *BlacklistCreate) SetTorrentHash(s string) *BlacklistCreate {
bc.mutation.SetTorrentHash(s)
return bc
}
// SetNillableTorrentHash sets the "torrent_hash" field if the given value is not nil.
func (bc *BlacklistCreate) SetNillableTorrentHash(s *string) *BlacklistCreate {
if s != nil {
bc.SetTorrentHash(*s)
}
return bc
}
// SetTorrentName sets the "torrent_name" field.
func (bc *BlacklistCreate) SetTorrentName(s string) *BlacklistCreate {
bc.mutation.SetTorrentName(s)
return bc
}
// SetNillableTorrentName sets the "torrent_name" field if the given value is not nil.
func (bc *BlacklistCreate) SetNillableTorrentName(s *string) *BlacklistCreate {
if s != nil {
bc.SetTorrentName(*s)
}
return bc
}
// SetMediaID sets the "media_id" field.
func (bc *BlacklistCreate) SetMediaID(i int) *BlacklistCreate {
bc.mutation.SetMediaID(i)
return bc
}
// SetNillableMediaID sets the "media_id" field if the given value is not nil.
func (bc *BlacklistCreate) SetNillableMediaID(i *int) *BlacklistCreate {
if i != nil {
bc.SetMediaID(*i)
}
return bc
}
// SetCreateTime sets the "create_time" field.
func (bc *BlacklistCreate) SetCreateTime(t time.Time) *BlacklistCreate {
bc.mutation.SetCreateTime(t)
return bc
}
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
func (bc *BlacklistCreate) SetNillableCreateTime(t *time.Time) *BlacklistCreate {
if t != nil {
bc.SetCreateTime(*t)
}
return bc
}
// SetNotes sets the "notes" field.
func (bc *BlacklistCreate) SetNotes(s string) *BlacklistCreate {
bc.mutation.SetNotes(s)
return bc
}
// SetNillableNotes sets the "notes" field if the given value is not nil.
func (bc *BlacklistCreate) SetNillableNotes(s *string) *BlacklistCreate {
if s != nil {
bc.SetNotes(*s)
}
return bc
}
// Mutation returns the BlacklistMutation object of the builder.
func (bc *BlacklistCreate) Mutation() *BlacklistMutation {
return bc.mutation
}
// Save creates the Blacklist in the database.
func (bc *BlacklistCreate) Save(ctx context.Context) (*Blacklist, error) {
bc.defaults()
return withHooks(ctx, bc.sqlSave, bc.mutation, bc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (bc *BlacklistCreate) SaveX(ctx context.Context) *Blacklist {
v, err := bc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (bc *BlacklistCreate) Exec(ctx context.Context) error {
_, err := bc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (bc *BlacklistCreate) ExecX(ctx context.Context) {
if err := bc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (bc *BlacklistCreate) defaults() {
if _, ok := bc.mutation.GetType(); !ok {
v := blacklist.DefaultType
bc.mutation.SetType(v)
}
if _, ok := bc.mutation.CreateTime(); !ok {
v := blacklist.DefaultCreateTime()
bc.mutation.SetCreateTime(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (bc *BlacklistCreate) check() error {
if _, ok := bc.mutation.GetType(); !ok {
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Blacklist.type"`)}
}
if v, ok := bc.mutation.GetType(); ok {
if err := blacklist.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Blacklist.type": %w`, err)}
}
}
return nil
}
func (bc *BlacklistCreate) sqlSave(ctx context.Context) (*Blacklist, error) {
if err := bc.check(); err != nil {
return nil, err
}
_node, _spec := bc.createSpec()
if err := sqlgraph.CreateNode(ctx, bc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
bc.mutation.id = &_node.ID
bc.mutation.done = true
return _node, nil
}
func (bc *BlacklistCreate) createSpec() (*Blacklist, *sqlgraph.CreateSpec) {
var (
_node = &Blacklist{config: bc.config}
_spec = sqlgraph.NewCreateSpec(blacklist.Table, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
)
if value, ok := bc.mutation.GetType(); ok {
_spec.SetField(blacklist.FieldType, field.TypeEnum, value)
_node.Type = value
}
if value, ok := bc.mutation.TorrentHash(); ok {
_spec.SetField(blacklist.FieldTorrentHash, field.TypeString, value)
_node.TorrentHash = value
}
if value, ok := bc.mutation.TorrentName(); ok {
_spec.SetField(blacklist.FieldTorrentName, field.TypeString, value)
_node.TorrentName = value
}
if value, ok := bc.mutation.MediaID(); ok {
_spec.SetField(blacklist.FieldMediaID, field.TypeInt, value)
_node.MediaID = value
}
if value, ok := bc.mutation.CreateTime(); ok {
_spec.SetField(blacklist.FieldCreateTime, field.TypeTime, value)
_node.CreateTime = value
}
if value, ok := bc.mutation.Notes(); ok {
_spec.SetField(blacklist.FieldNotes, field.TypeString, value)
_node.Notes = value
}
return _node, _spec
}
// BlacklistCreateBulk is the builder for creating many Blacklist entities in bulk.
type BlacklistCreateBulk struct {
config
err error
builders []*BlacklistCreate
}
// Save creates the Blacklist entities in the database.
func (bcb *BlacklistCreateBulk) Save(ctx context.Context) ([]*Blacklist, error) {
if bcb.err != nil {
return nil, bcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(bcb.builders))
nodes := make([]*Blacklist, len(bcb.builders))
mutators := make([]Mutator, len(bcb.builders))
for i := range bcb.builders {
func(i int, root context.Context) {
builder := bcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*BlacklistMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, bcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, bcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, bcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (bcb *BlacklistCreateBulk) SaveX(ctx context.Context) []*Blacklist {
v, err := bcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (bcb *BlacklistCreateBulk) Exec(ctx context.Context) error {
_, err := bcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (bcb *BlacklistCreateBulk) ExecX(ctx context.Context) {
if err := bcb.Exec(ctx); err != nil {
panic(err)
}
}

88
ent/blacklist_delete.go Normal file
View File

@@ -0,0 +1,88 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"polaris/ent/blacklist"
"polaris/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// BlacklistDelete is the builder for deleting a Blacklist entity.
type BlacklistDelete struct {
config
hooks []Hook
mutation *BlacklistMutation
}
// Where appends a list predicates to the BlacklistDelete builder.
func (bd *BlacklistDelete) Where(ps ...predicate.Blacklist) *BlacklistDelete {
bd.mutation.Where(ps...)
return bd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (bd *BlacklistDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, bd.sqlExec, bd.mutation, bd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (bd *BlacklistDelete) ExecX(ctx context.Context) int {
n, err := bd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (bd *BlacklistDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(blacklist.Table, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
if ps := bd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, bd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
bd.mutation.done = true
return affected, err
}
// BlacklistDeleteOne is the builder for deleting a single Blacklist entity.
type BlacklistDeleteOne struct {
bd *BlacklistDelete
}
// Where appends a list predicates to the BlacklistDelete builder.
func (bdo *BlacklistDeleteOne) Where(ps ...predicate.Blacklist) *BlacklistDeleteOne {
bdo.bd.mutation.Where(ps...)
return bdo
}
// Exec executes the deletion query.
func (bdo *BlacklistDeleteOne) Exec(ctx context.Context) error {
n, err := bdo.bd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{blacklist.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (bdo *BlacklistDeleteOne) ExecX(ctx context.Context) {
if err := bdo.Exec(ctx); err != nil {
panic(err)
}
}

527
ent/blacklist_query.go Normal file
View File

@@ -0,0 +1,527 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"polaris/ent/blacklist"
"polaris/ent/predicate"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// BlacklistQuery is the builder for querying Blacklist entities.
type BlacklistQuery struct {
config
ctx *QueryContext
order []blacklist.OrderOption
inters []Interceptor
predicates []predicate.Blacklist
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the BlacklistQuery builder.
func (bq *BlacklistQuery) Where(ps ...predicate.Blacklist) *BlacklistQuery {
bq.predicates = append(bq.predicates, ps...)
return bq
}
// Limit the number of records to be returned by this query.
func (bq *BlacklistQuery) Limit(limit int) *BlacklistQuery {
bq.ctx.Limit = &limit
return bq
}
// Offset to start from.
func (bq *BlacklistQuery) Offset(offset int) *BlacklistQuery {
bq.ctx.Offset = &offset
return bq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (bq *BlacklistQuery) Unique(unique bool) *BlacklistQuery {
bq.ctx.Unique = &unique
return bq
}
// Order specifies how the records should be ordered.
func (bq *BlacklistQuery) Order(o ...blacklist.OrderOption) *BlacklistQuery {
bq.order = append(bq.order, o...)
return bq
}
// First returns the first Blacklist entity from the query.
// Returns a *NotFoundError when no Blacklist was found.
func (bq *BlacklistQuery) First(ctx context.Context) (*Blacklist, error) {
nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{blacklist.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (bq *BlacklistQuery) FirstX(ctx context.Context) *Blacklist {
node, err := bq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first Blacklist ID from the query.
// Returns a *NotFoundError when no Blacklist ID was found.
func (bq *BlacklistQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{blacklist.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (bq *BlacklistQuery) FirstIDX(ctx context.Context) int {
id, err := bq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single Blacklist entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one Blacklist entity is found.
// Returns a *NotFoundError when no Blacklist entities are found.
func (bq *BlacklistQuery) Only(ctx context.Context) (*Blacklist, error) {
nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{blacklist.Label}
default:
return nil, &NotSingularError{blacklist.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (bq *BlacklistQuery) OnlyX(ctx context.Context) *Blacklist {
node, err := bq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only Blacklist ID in the query.
// Returns a *NotSingularError when more than one Blacklist ID is found.
// Returns a *NotFoundError when no entities are found.
func (bq *BlacklistQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{blacklist.Label}
default:
err = &NotSingularError{blacklist.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (bq *BlacklistQuery) OnlyIDX(ctx context.Context) int {
id, err := bq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of Blacklists.
func (bq *BlacklistQuery) All(ctx context.Context) ([]*Blacklist, error) {
ctx = setContextOp(ctx, bq.ctx, ent.OpQueryAll)
if err := bq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*Blacklist, *BlacklistQuery]()
return withInterceptors[[]*Blacklist](ctx, bq, qr, bq.inters)
}
// AllX is like All, but panics if an error occurs.
func (bq *BlacklistQuery) AllX(ctx context.Context) []*Blacklist {
nodes, err := bq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of Blacklist IDs.
func (bq *BlacklistQuery) IDs(ctx context.Context) (ids []int, err error) {
if bq.ctx.Unique == nil && bq.path != nil {
bq.Unique(true)
}
ctx = setContextOp(ctx, bq.ctx, ent.OpQueryIDs)
if err = bq.Select(blacklist.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (bq *BlacklistQuery) IDsX(ctx context.Context) []int {
ids, err := bq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (bq *BlacklistQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, bq.ctx, ent.OpQueryCount)
if err := bq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, bq, querierCount[*BlacklistQuery](), bq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (bq *BlacklistQuery) CountX(ctx context.Context) int {
count, err := bq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (bq *BlacklistQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, bq.ctx, ent.OpQueryExist)
switch _, err := bq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (bq *BlacklistQuery) ExistX(ctx context.Context) bool {
exist, err := bq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the BlacklistQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (bq *BlacklistQuery) Clone() *BlacklistQuery {
if bq == nil {
return nil
}
return &BlacklistQuery{
config: bq.config,
ctx: bq.ctx.Clone(),
order: append([]blacklist.OrderOption{}, bq.order...),
inters: append([]Interceptor{}, bq.inters...),
predicates: append([]predicate.Blacklist{}, bq.predicates...),
// clone intermediate query.
sql: bq.sql.Clone(),
path: bq.path,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// Type blacklist.Type `json:"type,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.Blacklist.Query().
// GroupBy(blacklist.FieldType).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (bq *BlacklistQuery) GroupBy(field string, fields ...string) *BlacklistGroupBy {
bq.ctx.Fields = append([]string{field}, fields...)
grbuild := &BlacklistGroupBy{build: bq}
grbuild.flds = &bq.ctx.Fields
grbuild.label = blacklist.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// Type blacklist.Type `json:"type,omitempty"`
// }
//
// client.Blacklist.Query().
// Select(blacklist.FieldType).
// Scan(ctx, &v)
func (bq *BlacklistQuery) Select(fields ...string) *BlacklistSelect {
bq.ctx.Fields = append(bq.ctx.Fields, fields...)
sbuild := &BlacklistSelect{BlacklistQuery: bq}
sbuild.label = blacklist.Label
sbuild.flds, sbuild.scan = &bq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a BlacklistSelect configured with the given aggregations.
func (bq *BlacklistQuery) Aggregate(fns ...AggregateFunc) *BlacklistSelect {
return bq.Select().Aggregate(fns...)
}
func (bq *BlacklistQuery) prepareQuery(ctx context.Context) error {
for _, inter := range bq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, bq); err != nil {
return err
}
}
}
for _, f := range bq.ctx.Fields {
if !blacklist.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if bq.path != nil {
prev, err := bq.path(ctx)
if err != nil {
return err
}
bq.sql = prev
}
return nil
}
func (bq *BlacklistQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Blacklist, error) {
var (
nodes = []*Blacklist{}
_spec = bq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*Blacklist).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &Blacklist{config: bq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (bq *BlacklistQuery) sqlCount(ctx context.Context) (int, error) {
_spec := bq.querySpec()
_spec.Node.Columns = bq.ctx.Fields
if len(bq.ctx.Fields) > 0 {
_spec.Unique = bq.ctx.Unique != nil && *bq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, bq.driver, _spec)
}
func (bq *BlacklistQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(blacklist.Table, blacklist.Columns, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
_spec.From = bq.sql
if unique := bq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if bq.path != nil {
_spec.Unique = true
}
if fields := bq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, blacklist.FieldID)
for i := range fields {
if fields[i] != blacklist.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := bq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := bq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := bq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := bq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (bq *BlacklistQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(bq.driver.Dialect())
t1 := builder.Table(blacklist.Table)
columns := bq.ctx.Fields
if len(columns) == 0 {
columns = blacklist.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if bq.sql != nil {
selector = bq.sql
selector.Select(selector.Columns(columns...)...)
}
if bq.ctx.Unique != nil && *bq.ctx.Unique {
selector.Distinct()
}
for _, p := range bq.predicates {
p(selector)
}
for _, p := range bq.order {
p(selector)
}
if offset := bq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := bq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// BlacklistGroupBy is the group-by builder for Blacklist entities.
type BlacklistGroupBy struct {
selector
build *BlacklistQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (bgb *BlacklistGroupBy) Aggregate(fns ...AggregateFunc) *BlacklistGroupBy {
bgb.fns = append(bgb.fns, fns...)
return bgb
}
// Scan applies the selector query and scans the result into the given value.
func (bgb *BlacklistGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, bgb.build.ctx, ent.OpQueryGroupBy)
if err := bgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*BlacklistQuery, *BlacklistGroupBy](ctx, bgb.build, bgb, bgb.build.inters, v)
}
func (bgb *BlacklistGroupBy) sqlScan(ctx context.Context, root *BlacklistQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(bgb.fns))
for _, fn := range bgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*bgb.flds)+len(bgb.fns))
for _, f := range *bgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*bgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := bgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// BlacklistSelect is the builder for selecting fields of Blacklist entities.
type BlacklistSelect struct {
*BlacklistQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (bs *BlacklistSelect) Aggregate(fns ...AggregateFunc) *BlacklistSelect {
bs.fns = append(bs.fns, fns...)
return bs
}
// Scan applies the selector query and scans the result into the given value.
func (bs *BlacklistSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, bs.ctx, ent.OpQuerySelect)
if err := bs.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*BlacklistQuery, *BlacklistSelect](ctx, bs.BlacklistQuery, bs, bs.inters, v)
}
func (bs *BlacklistSelect) sqlScan(ctx context.Context, root *BlacklistQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(bs.fns))
for _, fn := range bs.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*bs.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := bs.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

469
ent/blacklist_update.go Normal file
View File

@@ -0,0 +1,469 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"polaris/ent/blacklist"
"polaris/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// BlacklistUpdate is the builder for updating Blacklist entities.
type BlacklistUpdate struct {
config
hooks []Hook
mutation *BlacklistMutation
}
// Where appends a list predicates to the BlacklistUpdate builder.
func (bu *BlacklistUpdate) Where(ps ...predicate.Blacklist) *BlacklistUpdate {
bu.mutation.Where(ps...)
return bu
}
// SetType sets the "type" field.
func (bu *BlacklistUpdate) SetType(b blacklist.Type) *BlacklistUpdate {
bu.mutation.SetType(b)
return bu
}
// SetNillableType sets the "type" field if the given value is not nil.
func (bu *BlacklistUpdate) SetNillableType(b *blacklist.Type) *BlacklistUpdate {
if b != nil {
bu.SetType(*b)
}
return bu
}
// SetTorrentHash sets the "torrent_hash" field.
func (bu *BlacklistUpdate) SetTorrentHash(s string) *BlacklistUpdate {
bu.mutation.SetTorrentHash(s)
return bu
}
// SetNillableTorrentHash sets the "torrent_hash" field if the given value is not nil.
func (bu *BlacklistUpdate) SetNillableTorrentHash(s *string) *BlacklistUpdate {
if s != nil {
bu.SetTorrentHash(*s)
}
return bu
}
// ClearTorrentHash clears the value of the "torrent_hash" field.
func (bu *BlacklistUpdate) ClearTorrentHash() *BlacklistUpdate {
bu.mutation.ClearTorrentHash()
return bu
}
// SetTorrentName sets the "torrent_name" field.
func (bu *BlacklistUpdate) SetTorrentName(s string) *BlacklistUpdate {
bu.mutation.SetTorrentName(s)
return bu
}
// SetNillableTorrentName sets the "torrent_name" field if the given value is not nil.
func (bu *BlacklistUpdate) SetNillableTorrentName(s *string) *BlacklistUpdate {
if s != nil {
bu.SetTorrentName(*s)
}
return bu
}
// ClearTorrentName clears the value of the "torrent_name" field.
func (bu *BlacklistUpdate) ClearTorrentName() *BlacklistUpdate {
bu.mutation.ClearTorrentName()
return bu
}
// SetMediaID sets the "media_id" field.
func (bu *BlacklistUpdate) SetMediaID(i int) *BlacklistUpdate {
bu.mutation.ResetMediaID()
bu.mutation.SetMediaID(i)
return bu
}
// SetNillableMediaID sets the "media_id" field if the given value is not nil.
func (bu *BlacklistUpdate) SetNillableMediaID(i *int) *BlacklistUpdate {
if i != nil {
bu.SetMediaID(*i)
}
return bu
}
// AddMediaID adds i to the "media_id" field.
func (bu *BlacklistUpdate) AddMediaID(i int) *BlacklistUpdate {
bu.mutation.AddMediaID(i)
return bu
}
// ClearMediaID clears the value of the "media_id" field.
func (bu *BlacklistUpdate) ClearMediaID() *BlacklistUpdate {
bu.mutation.ClearMediaID()
return bu
}
// SetNotes sets the "notes" field.
func (bu *BlacklistUpdate) SetNotes(s string) *BlacklistUpdate {
bu.mutation.SetNotes(s)
return bu
}
// SetNillableNotes sets the "notes" field if the given value is not nil.
func (bu *BlacklistUpdate) SetNillableNotes(s *string) *BlacklistUpdate {
if s != nil {
bu.SetNotes(*s)
}
return bu
}
// ClearNotes clears the value of the "notes" field.
func (bu *BlacklistUpdate) ClearNotes() *BlacklistUpdate {
bu.mutation.ClearNotes()
return bu
}
// Mutation returns the BlacklistMutation object of the builder.
func (bu *BlacklistUpdate) Mutation() *BlacklistMutation {
return bu.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (bu *BlacklistUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (bu *BlacklistUpdate) SaveX(ctx context.Context) int {
affected, err := bu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (bu *BlacklistUpdate) Exec(ctx context.Context) error {
_, err := bu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (bu *BlacklistUpdate) ExecX(ctx context.Context) {
if err := bu.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (bu *BlacklistUpdate) check() error {
if v, ok := bu.mutation.GetType(); ok {
if err := blacklist.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Blacklist.type": %w`, err)}
}
}
return nil
}
func (bu *BlacklistUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := bu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(blacklist.Table, blacklist.Columns, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
if ps := bu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := bu.mutation.GetType(); ok {
_spec.SetField(blacklist.FieldType, field.TypeEnum, value)
}
if value, ok := bu.mutation.TorrentHash(); ok {
_spec.SetField(blacklist.FieldTorrentHash, field.TypeString, value)
}
if bu.mutation.TorrentHashCleared() {
_spec.ClearField(blacklist.FieldTorrentHash, field.TypeString)
}
if value, ok := bu.mutation.TorrentName(); ok {
_spec.SetField(blacklist.FieldTorrentName, field.TypeString, value)
}
if bu.mutation.TorrentNameCleared() {
_spec.ClearField(blacklist.FieldTorrentName, field.TypeString)
}
if value, ok := bu.mutation.MediaID(); ok {
_spec.SetField(blacklist.FieldMediaID, field.TypeInt, value)
}
if value, ok := bu.mutation.AddedMediaID(); ok {
_spec.AddField(blacklist.FieldMediaID, field.TypeInt, value)
}
if bu.mutation.MediaIDCleared() {
_spec.ClearField(blacklist.FieldMediaID, field.TypeInt)
}
if bu.mutation.CreateTimeCleared() {
_spec.ClearField(blacklist.FieldCreateTime, field.TypeTime)
}
if value, ok := bu.mutation.Notes(); ok {
_spec.SetField(blacklist.FieldNotes, field.TypeString, value)
}
if bu.mutation.NotesCleared() {
_spec.ClearField(blacklist.FieldNotes, field.TypeString)
}
if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{blacklist.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
bu.mutation.done = true
return n, nil
}
// BlacklistUpdateOne is the builder for updating a single Blacklist entity.
type BlacklistUpdateOne struct {
config
fields []string
hooks []Hook
mutation *BlacklistMutation
}
// SetType sets the "type" field.
func (buo *BlacklistUpdateOne) SetType(b blacklist.Type) *BlacklistUpdateOne {
buo.mutation.SetType(b)
return buo
}
// SetNillableType sets the "type" field if the given value is not nil.
func (buo *BlacklistUpdateOne) SetNillableType(b *blacklist.Type) *BlacklistUpdateOne {
if b != nil {
buo.SetType(*b)
}
return buo
}
// SetTorrentHash sets the "torrent_hash" field.
func (buo *BlacklistUpdateOne) SetTorrentHash(s string) *BlacklistUpdateOne {
buo.mutation.SetTorrentHash(s)
return buo
}
// SetNillableTorrentHash sets the "torrent_hash" field if the given value is not nil.
func (buo *BlacklistUpdateOne) SetNillableTorrentHash(s *string) *BlacklistUpdateOne {
if s != nil {
buo.SetTorrentHash(*s)
}
return buo
}
// ClearTorrentHash clears the value of the "torrent_hash" field.
func (buo *BlacklistUpdateOne) ClearTorrentHash() *BlacklistUpdateOne {
buo.mutation.ClearTorrentHash()
return buo
}
// SetTorrentName sets the "torrent_name" field.
func (buo *BlacklistUpdateOne) SetTorrentName(s string) *BlacklistUpdateOne {
buo.mutation.SetTorrentName(s)
return buo
}
// SetNillableTorrentName sets the "torrent_name" field if the given value is not nil.
func (buo *BlacklistUpdateOne) SetNillableTorrentName(s *string) *BlacklistUpdateOne {
if s != nil {
buo.SetTorrentName(*s)
}
return buo
}
// ClearTorrentName clears the value of the "torrent_name" field.
func (buo *BlacklistUpdateOne) ClearTorrentName() *BlacklistUpdateOne {
buo.mutation.ClearTorrentName()
return buo
}
// SetMediaID sets the "media_id" field.
func (buo *BlacklistUpdateOne) SetMediaID(i int) *BlacklistUpdateOne {
buo.mutation.ResetMediaID()
buo.mutation.SetMediaID(i)
return buo
}
// SetNillableMediaID sets the "media_id" field if the given value is not nil.
func (buo *BlacklistUpdateOne) SetNillableMediaID(i *int) *BlacklistUpdateOne {
if i != nil {
buo.SetMediaID(*i)
}
return buo
}
// AddMediaID adds i to the "media_id" field.
func (buo *BlacklistUpdateOne) AddMediaID(i int) *BlacklistUpdateOne {
buo.mutation.AddMediaID(i)
return buo
}
// ClearMediaID clears the value of the "media_id" field.
func (buo *BlacklistUpdateOne) ClearMediaID() *BlacklistUpdateOne {
buo.mutation.ClearMediaID()
return buo
}
// SetNotes sets the "notes" field.
func (buo *BlacklistUpdateOne) SetNotes(s string) *BlacklistUpdateOne {
buo.mutation.SetNotes(s)
return buo
}
// SetNillableNotes sets the "notes" field if the given value is not nil.
func (buo *BlacklistUpdateOne) SetNillableNotes(s *string) *BlacklistUpdateOne {
if s != nil {
buo.SetNotes(*s)
}
return buo
}
// ClearNotes clears the value of the "notes" field.
func (buo *BlacklistUpdateOne) ClearNotes() *BlacklistUpdateOne {
buo.mutation.ClearNotes()
return buo
}
// Mutation returns the BlacklistMutation object of the builder.
func (buo *BlacklistUpdateOne) Mutation() *BlacklistMutation {
return buo.mutation
}
// Where appends a list predicates to the BlacklistUpdate builder.
func (buo *BlacklistUpdateOne) Where(ps ...predicate.Blacklist) *BlacklistUpdateOne {
buo.mutation.Where(ps...)
return buo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (buo *BlacklistUpdateOne) Select(field string, fields ...string) *BlacklistUpdateOne {
buo.fields = append([]string{field}, fields...)
return buo
}
// Save executes the query and returns the updated Blacklist entity.
func (buo *BlacklistUpdateOne) Save(ctx context.Context) (*Blacklist, error) {
return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (buo *BlacklistUpdateOne) SaveX(ctx context.Context) *Blacklist {
node, err := buo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (buo *BlacklistUpdateOne) Exec(ctx context.Context) error {
_, err := buo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (buo *BlacklistUpdateOne) ExecX(ctx context.Context) {
if err := buo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (buo *BlacklistUpdateOne) check() error {
if v, ok := buo.mutation.GetType(); ok {
if err := blacklist.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Blacklist.type": %w`, err)}
}
}
return nil
}
func (buo *BlacklistUpdateOne) sqlSave(ctx context.Context) (_node *Blacklist, err error) {
if err := buo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(blacklist.Table, blacklist.Columns, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
id, ok := buo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Blacklist.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := buo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, blacklist.FieldID)
for _, f := range fields {
if !blacklist.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != blacklist.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := buo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := buo.mutation.GetType(); ok {
_spec.SetField(blacklist.FieldType, field.TypeEnum, value)
}
if value, ok := buo.mutation.TorrentHash(); ok {
_spec.SetField(blacklist.FieldTorrentHash, field.TypeString, value)
}
if buo.mutation.TorrentHashCleared() {
_spec.ClearField(blacklist.FieldTorrentHash, field.TypeString)
}
if value, ok := buo.mutation.TorrentName(); ok {
_spec.SetField(blacklist.FieldTorrentName, field.TypeString, value)
}
if buo.mutation.TorrentNameCleared() {
_spec.ClearField(blacklist.FieldTorrentName, field.TypeString)
}
if value, ok := buo.mutation.MediaID(); ok {
_spec.SetField(blacklist.FieldMediaID, field.TypeInt, value)
}
if value, ok := buo.mutation.AddedMediaID(); ok {
_spec.AddField(blacklist.FieldMediaID, field.TypeInt, value)
}
if buo.mutation.MediaIDCleared() {
_spec.ClearField(blacklist.FieldMediaID, field.TypeInt)
}
if buo.mutation.CreateTimeCleared() {
_spec.ClearField(blacklist.FieldCreateTime, field.TypeTime)
}
if value, ok := buo.mutation.Notes(); ok {
_spec.SetField(blacklist.FieldNotes, field.TypeString, value)
}
if buo.mutation.NotesCleared() {
_spec.ClearField(blacklist.FieldNotes, field.TypeString)
}
_node = &Blacklist{config: buo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{blacklist.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
buo.mutation.done = true
return _node, nil
}

View File

@@ -11,11 +11,14 @@ import (
"polaris/ent/migrate"
"polaris/ent/blacklist"
"polaris/ent/downloadclients"
"polaris/ent/episode"
"polaris/ent/history"
"polaris/ent/importlist"
"polaris/ent/indexers"
"polaris/ent/media"
"polaris/ent/notificationclient"
"polaris/ent/settings"
"polaris/ent/storage"
@@ -30,16 +33,22 @@ type Client struct {
config
// Schema is the client for creating, migrating and dropping schema.
Schema *migrate.Schema
// Blacklist is the client for interacting with the Blacklist builders.
Blacklist *BlacklistClient
// DownloadClients is the client for interacting with the DownloadClients builders.
DownloadClients *DownloadClientsClient
// Episode is the client for interacting with the Episode builders.
Episode *EpisodeClient
// History is the client for interacting with the History builders.
History *HistoryClient
// ImportList is the client for interacting with the ImportList builders.
ImportList *ImportListClient
// Indexers is the client for interacting with the Indexers builders.
Indexers *IndexersClient
// Media is the client for interacting with the Media builders.
Media *MediaClient
// NotificationClient is the client for interacting with the NotificationClient builders.
NotificationClient *NotificationClientClient
// Settings is the client for interacting with the Settings builders.
Settings *SettingsClient
// Storage is the client for interacting with the Storage builders.
@@ -55,11 +64,14 @@ func NewClient(opts ...Option) *Client {
func (c *Client) init() {
c.Schema = migrate.NewSchema(c.driver)
c.Blacklist = NewBlacklistClient(c.config)
c.DownloadClients = NewDownloadClientsClient(c.config)
c.Episode = NewEpisodeClient(c.config)
c.History = NewHistoryClient(c.config)
c.ImportList = NewImportListClient(c.config)
c.Indexers = NewIndexersClient(c.config)
c.Media = NewMediaClient(c.config)
c.NotificationClient = NewNotificationClientClient(c.config)
c.Settings = NewSettingsClient(c.config)
c.Storage = NewStorageClient(c.config)
}
@@ -152,15 +164,18 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
cfg := c.config
cfg.driver = tx
return &Tx{
ctx: ctx,
config: cfg,
DownloadClients: NewDownloadClientsClient(cfg),
Episode: NewEpisodeClient(cfg),
History: NewHistoryClient(cfg),
Indexers: NewIndexersClient(cfg),
Media: NewMediaClient(cfg),
Settings: NewSettingsClient(cfg),
Storage: NewStorageClient(cfg),
ctx: ctx,
config: cfg,
Blacklist: NewBlacklistClient(cfg),
DownloadClients: NewDownloadClientsClient(cfg),
Episode: NewEpisodeClient(cfg),
History: NewHistoryClient(cfg),
ImportList: NewImportListClient(cfg),
Indexers: NewIndexersClient(cfg),
Media: NewMediaClient(cfg),
NotificationClient: NewNotificationClientClient(cfg),
Settings: NewSettingsClient(cfg),
Storage: NewStorageClient(cfg),
}, nil
}
@@ -178,22 +193,25 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
cfg := c.config
cfg.driver = &txDriver{tx: tx, drv: c.driver}
return &Tx{
ctx: ctx,
config: cfg,
DownloadClients: NewDownloadClientsClient(cfg),
Episode: NewEpisodeClient(cfg),
History: NewHistoryClient(cfg),
Indexers: NewIndexersClient(cfg),
Media: NewMediaClient(cfg),
Settings: NewSettingsClient(cfg),
Storage: NewStorageClient(cfg),
ctx: ctx,
config: cfg,
Blacklist: NewBlacklistClient(cfg),
DownloadClients: NewDownloadClientsClient(cfg),
Episode: NewEpisodeClient(cfg),
History: NewHistoryClient(cfg),
ImportList: NewImportListClient(cfg),
Indexers: NewIndexersClient(cfg),
Media: NewMediaClient(cfg),
NotificationClient: NewNotificationClientClient(cfg),
Settings: NewSettingsClient(cfg),
Storage: NewStorageClient(cfg),
}, nil
}
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
//
// client.Debug().
// DownloadClients.
// Blacklist.
// Query().
// Count(ctx)
func (c *Client) Debug() *Client {
@@ -216,8 +234,8 @@ func (c *Client) Close() error {
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
func (c *Client) Use(hooks ...Hook) {
for _, n := range []interface{ Use(...Hook) }{
c.DownloadClients, c.Episode, c.History, c.Indexers, c.Media, c.Settings,
c.Storage,
c.Blacklist, c.DownloadClients, c.Episode, c.History, c.ImportList, c.Indexers,
c.Media, c.NotificationClient, c.Settings, c.Storage,
} {
n.Use(hooks...)
}
@@ -227,8 +245,8 @@ func (c *Client) Use(hooks ...Hook) {
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
func (c *Client) Intercept(interceptors ...Interceptor) {
for _, n := range []interface{ Intercept(...Interceptor) }{
c.DownloadClients, c.Episode, c.History, c.Indexers, c.Media, c.Settings,
c.Storage,
c.Blacklist, c.DownloadClients, c.Episode, c.History, c.ImportList, c.Indexers,
c.Media, c.NotificationClient, c.Settings, c.Storage,
} {
n.Intercept(interceptors...)
}
@@ -237,16 +255,22 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
// Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
switch m := m.(type) {
case *BlacklistMutation:
return c.Blacklist.mutate(ctx, m)
case *DownloadClientsMutation:
return c.DownloadClients.mutate(ctx, m)
case *EpisodeMutation:
return c.Episode.mutate(ctx, m)
case *HistoryMutation:
return c.History.mutate(ctx, m)
case *ImportListMutation:
return c.ImportList.mutate(ctx, m)
case *IndexersMutation:
return c.Indexers.mutate(ctx, m)
case *MediaMutation:
return c.Media.mutate(ctx, m)
case *NotificationClientMutation:
return c.NotificationClient.mutate(ctx, m)
case *SettingsMutation:
return c.Settings.mutate(ctx, m)
case *StorageMutation:
@@ -256,6 +280,139 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
}
}
// BlacklistClient is a client for the Blacklist schema.
type BlacklistClient struct {
config
}
// NewBlacklistClient returns a client for the Blacklist from the given config.
func NewBlacklistClient(c config) *BlacklistClient {
return &BlacklistClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `blacklist.Hooks(f(g(h())))`.
func (c *BlacklistClient) Use(hooks ...Hook) {
c.hooks.Blacklist = append(c.hooks.Blacklist, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `blacklist.Intercept(f(g(h())))`.
func (c *BlacklistClient) Intercept(interceptors ...Interceptor) {
c.inters.Blacklist = append(c.inters.Blacklist, interceptors...)
}
// Create returns a builder for creating a Blacklist entity.
func (c *BlacklistClient) Create() *BlacklistCreate {
mutation := newBlacklistMutation(c.config, OpCreate)
return &BlacklistCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Blacklist entities.
func (c *BlacklistClient) CreateBulk(builders ...*BlacklistCreate) *BlacklistCreateBulk {
return &BlacklistCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *BlacklistClient) MapCreateBulk(slice any, setFunc func(*BlacklistCreate, int)) *BlacklistCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &BlacklistCreateBulk{err: fmt.Errorf("calling to BlacklistClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*BlacklistCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &BlacklistCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Blacklist.
func (c *BlacklistClient) Update() *BlacklistUpdate {
mutation := newBlacklistMutation(c.config, OpUpdate)
return &BlacklistUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *BlacklistClient) UpdateOne(b *Blacklist) *BlacklistUpdateOne {
mutation := newBlacklistMutation(c.config, OpUpdateOne, withBlacklist(b))
return &BlacklistUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *BlacklistClient) UpdateOneID(id int) *BlacklistUpdateOne {
mutation := newBlacklistMutation(c.config, OpUpdateOne, withBlacklistID(id))
return &BlacklistUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Blacklist.
func (c *BlacklistClient) Delete() *BlacklistDelete {
mutation := newBlacklistMutation(c.config, OpDelete)
return &BlacklistDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *BlacklistClient) DeleteOne(b *Blacklist) *BlacklistDeleteOne {
return c.DeleteOneID(b.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *BlacklistClient) DeleteOneID(id int) *BlacklistDeleteOne {
builder := c.Delete().Where(blacklist.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &BlacklistDeleteOne{builder}
}
// Query returns a query builder for Blacklist.
func (c *BlacklistClient) Query() *BlacklistQuery {
return &BlacklistQuery{
config: c.config,
ctx: &QueryContext{Type: TypeBlacklist},
inters: c.Interceptors(),
}
}
// Get returns a Blacklist entity by its id.
func (c *BlacklistClient) Get(ctx context.Context, id int) (*Blacklist, error) {
return c.Query().Where(blacklist.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *BlacklistClient) GetX(ctx context.Context, id int) *Blacklist {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *BlacklistClient) Hooks() []Hook {
return c.hooks.Blacklist
}
// Interceptors returns the client interceptors.
func (c *BlacklistClient) Interceptors() []Interceptor {
return c.inters.Blacklist
}
func (c *BlacklistClient) mutate(ctx context.Context, m *BlacklistMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&BlacklistCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&BlacklistUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&BlacklistUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&BlacklistDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Blacklist mutation op: %q", m.Op())
}
}
// DownloadClientsClient is a client for the DownloadClients schema.
type DownloadClientsClient struct {
config
@@ -671,6 +828,139 @@ func (c *HistoryClient) mutate(ctx context.Context, m *HistoryMutation) (Value,
}
}
// ImportListClient is a client for the ImportList schema.
type ImportListClient struct {
config
}
// NewImportListClient returns a client for the ImportList from the given config.
func NewImportListClient(c config) *ImportListClient {
return &ImportListClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `importlist.Hooks(f(g(h())))`.
func (c *ImportListClient) Use(hooks ...Hook) {
c.hooks.ImportList = append(c.hooks.ImportList, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `importlist.Intercept(f(g(h())))`.
func (c *ImportListClient) Intercept(interceptors ...Interceptor) {
c.inters.ImportList = append(c.inters.ImportList, interceptors...)
}
// Create returns a builder for creating a ImportList entity.
func (c *ImportListClient) Create() *ImportListCreate {
mutation := newImportListMutation(c.config, OpCreate)
return &ImportListCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of ImportList entities.
func (c *ImportListClient) CreateBulk(builders ...*ImportListCreate) *ImportListCreateBulk {
return &ImportListCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *ImportListClient) MapCreateBulk(slice any, setFunc func(*ImportListCreate, int)) *ImportListCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &ImportListCreateBulk{err: fmt.Errorf("calling to ImportListClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*ImportListCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &ImportListCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for ImportList.
func (c *ImportListClient) Update() *ImportListUpdate {
mutation := newImportListMutation(c.config, OpUpdate)
return &ImportListUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *ImportListClient) UpdateOne(il *ImportList) *ImportListUpdateOne {
mutation := newImportListMutation(c.config, OpUpdateOne, withImportList(il))
return &ImportListUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *ImportListClient) UpdateOneID(id int) *ImportListUpdateOne {
mutation := newImportListMutation(c.config, OpUpdateOne, withImportListID(id))
return &ImportListUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for ImportList.
func (c *ImportListClient) Delete() *ImportListDelete {
mutation := newImportListMutation(c.config, OpDelete)
return &ImportListDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *ImportListClient) DeleteOne(il *ImportList) *ImportListDeleteOne {
return c.DeleteOneID(il.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *ImportListClient) DeleteOneID(id int) *ImportListDeleteOne {
builder := c.Delete().Where(importlist.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &ImportListDeleteOne{builder}
}
// Query returns a query builder for ImportList.
func (c *ImportListClient) Query() *ImportListQuery {
return &ImportListQuery{
config: c.config,
ctx: &QueryContext{Type: TypeImportList},
inters: c.Interceptors(),
}
}
// Get returns a ImportList entity by its id.
func (c *ImportListClient) Get(ctx context.Context, id int) (*ImportList, error) {
return c.Query().Where(importlist.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *ImportListClient) GetX(ctx context.Context, id int) *ImportList {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *ImportListClient) Hooks() []Hook {
return c.hooks.ImportList
}
// Interceptors returns the client interceptors.
func (c *ImportListClient) Interceptors() []Interceptor {
return c.inters.ImportList
}
func (c *ImportListClient) mutate(ctx context.Context, m *ImportListMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&ImportListCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&ImportListUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&ImportListUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&ImportListDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown ImportList mutation op: %q", m.Op())
}
}
// IndexersClient is a client for the Indexers schema.
type IndexersClient struct {
config
@@ -953,6 +1243,139 @@ func (c *MediaClient) mutate(ctx context.Context, m *MediaMutation) (Value, erro
}
}
// NotificationClientClient is a client for the NotificationClient schema.
type NotificationClientClient struct {
config
}
// NewNotificationClientClient returns a client for the NotificationClient from the given config.
func NewNotificationClientClient(c config) *NotificationClientClient {
return &NotificationClientClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `notificationclient.Hooks(f(g(h())))`.
func (c *NotificationClientClient) Use(hooks ...Hook) {
c.hooks.NotificationClient = append(c.hooks.NotificationClient, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `notificationclient.Intercept(f(g(h())))`.
func (c *NotificationClientClient) Intercept(interceptors ...Interceptor) {
c.inters.NotificationClient = append(c.inters.NotificationClient, interceptors...)
}
// Create returns a builder for creating a NotificationClient entity.
func (c *NotificationClientClient) Create() *NotificationClientCreate {
mutation := newNotificationClientMutation(c.config, OpCreate)
return &NotificationClientCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of NotificationClient entities.
func (c *NotificationClientClient) CreateBulk(builders ...*NotificationClientCreate) *NotificationClientCreateBulk {
return &NotificationClientCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *NotificationClientClient) MapCreateBulk(slice any, setFunc func(*NotificationClientCreate, int)) *NotificationClientCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &NotificationClientCreateBulk{err: fmt.Errorf("calling to NotificationClientClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*NotificationClientCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &NotificationClientCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for NotificationClient.
func (c *NotificationClientClient) Update() *NotificationClientUpdate {
mutation := newNotificationClientMutation(c.config, OpUpdate)
return &NotificationClientUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *NotificationClientClient) UpdateOne(nc *NotificationClient) *NotificationClientUpdateOne {
mutation := newNotificationClientMutation(c.config, OpUpdateOne, withNotificationClient(nc))
return &NotificationClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *NotificationClientClient) UpdateOneID(id int) *NotificationClientUpdateOne {
mutation := newNotificationClientMutation(c.config, OpUpdateOne, withNotificationClientID(id))
return &NotificationClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for NotificationClient.
func (c *NotificationClientClient) Delete() *NotificationClientDelete {
mutation := newNotificationClientMutation(c.config, OpDelete)
return &NotificationClientDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *NotificationClientClient) DeleteOne(nc *NotificationClient) *NotificationClientDeleteOne {
return c.DeleteOneID(nc.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *NotificationClientClient) DeleteOneID(id int) *NotificationClientDeleteOne {
builder := c.Delete().Where(notificationclient.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &NotificationClientDeleteOne{builder}
}
// Query returns a query builder for NotificationClient.
func (c *NotificationClientClient) Query() *NotificationClientQuery {
return &NotificationClientQuery{
config: c.config,
ctx: &QueryContext{Type: TypeNotificationClient},
inters: c.Interceptors(),
}
}
// Get returns a NotificationClient entity by its id.
func (c *NotificationClientClient) Get(ctx context.Context, id int) (*NotificationClient, error) {
return c.Query().Where(notificationclient.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *NotificationClientClient) GetX(ctx context.Context, id int) *NotificationClient {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *NotificationClientClient) Hooks() []Hook {
return c.hooks.NotificationClient
}
// Interceptors returns the client interceptors.
func (c *NotificationClientClient) Interceptors() []Interceptor {
return c.inters.NotificationClient
}
func (c *NotificationClientClient) mutate(ctx context.Context, m *NotificationClientMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&NotificationClientCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&NotificationClientUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&NotificationClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&NotificationClientDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown NotificationClient mutation op: %q", m.Op())
}
}
// SettingsClient is a client for the Settings schema.
type SettingsClient struct {
config
@@ -1222,10 +1645,11 @@ func (c *StorageClient) mutate(ctx context.Context, m *StorageMutation) (Value,
// hooks and interceptors per client, for fast access.
type (
hooks struct {
DownloadClients, Episode, History, Indexers, Media, Settings, Storage []ent.Hook
Blacklist, DownloadClients, Episode, History, ImportList, Indexers, Media,
NotificationClient, Settings, Storage []ent.Hook
}
inters struct {
DownloadClients, Episode, History, Indexers, Media, Settings,
Storage []ent.Interceptor
Blacklist, DownloadClients, Episode, History, ImportList, Indexers, Media,
NotificationClient, Settings, Storage []ent.Interceptor
}
)

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"polaris/ent/downloadclients"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
@@ -21,7 +22,7 @@ type DownloadClients struct {
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Implementation holds the value of the "implementation" field.
Implementation string `json:"implementation,omitempty"`
Implementation downloadclients.Implementation `json:"implementation,omitempty"`
// URL holds the value of the "url" field.
URL string `json:"url,omitempty"`
// User holds the value of the "user" field.
@@ -30,14 +31,18 @@ type DownloadClients struct {
Password string `json:"password,omitempty"`
// Settings holds the value of the "settings" field.
Settings string `json:"settings,omitempty"`
// Priority holds the value of the "priority" field.
Priority string `json:"priority,omitempty"`
// Priority1 holds the value of the "priority1" field.
Priority1 int `json:"priority1,omitempty"`
// use stun server to do nat traversal, enable download client to do uploading successfully
UseNatTraversal bool `json:"use_nat_traversal,omitempty"`
// RemoveCompletedDownloads holds the value of the "remove_completed_downloads" field.
RemoveCompletedDownloads bool `json:"remove_completed_downloads,omitempty"`
// RemoveFailedDownloads holds the value of the "remove_failed_downloads" field.
RemoveFailedDownloads bool `json:"remove_failed_downloads,omitempty"`
// Tags holds the value of the "tags" field.
Tags string `json:"tags,omitempty"`
Tags string `json:"tags,omitempty"`
// CreateTime holds the value of the "create_time" field.
CreateTime time.Time `json:"create_time,omitempty"`
selectValues sql.SelectValues
}
@@ -46,12 +51,14 @@ func (*DownloadClients) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case downloadclients.FieldEnable, downloadclients.FieldRemoveCompletedDownloads, downloadclients.FieldRemoveFailedDownloads:
case downloadclients.FieldEnable, downloadclients.FieldUseNatTraversal, downloadclients.FieldRemoveCompletedDownloads, downloadclients.FieldRemoveFailedDownloads:
values[i] = new(sql.NullBool)
case downloadclients.FieldID:
case downloadclients.FieldID, downloadclients.FieldPriority1:
values[i] = new(sql.NullInt64)
case downloadclients.FieldName, downloadclients.FieldImplementation, downloadclients.FieldURL, downloadclients.FieldUser, downloadclients.FieldPassword, downloadclients.FieldSettings, downloadclients.FieldPriority, downloadclients.FieldTags:
case downloadclients.FieldName, downloadclients.FieldImplementation, downloadclients.FieldURL, downloadclients.FieldUser, downloadclients.FieldPassword, downloadclients.FieldSettings, downloadclients.FieldTags:
values[i] = new(sql.NullString)
case downloadclients.FieldCreateTime:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
@@ -89,7 +96,7 @@ func (dc *DownloadClients) assignValues(columns []string, values []any) error {
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field implementation", values[i])
} else if value.Valid {
dc.Implementation = value.String
dc.Implementation = downloadclients.Implementation(value.String)
}
case downloadclients.FieldURL:
if value, ok := values[i].(*sql.NullString); !ok {
@@ -115,11 +122,17 @@ func (dc *DownloadClients) assignValues(columns []string, values []any) error {
} else if value.Valid {
dc.Settings = value.String
}
case downloadclients.FieldPriority:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field priority", values[i])
case downloadclients.FieldPriority1:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field priority1", values[i])
} else if value.Valid {
dc.Priority = value.String
dc.Priority1 = int(value.Int64)
}
case downloadclients.FieldUseNatTraversal:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field use_nat_traversal", values[i])
} else if value.Valid {
dc.UseNatTraversal = value.Bool
}
case downloadclients.FieldRemoveCompletedDownloads:
if value, ok := values[i].(*sql.NullBool); !ok {
@@ -139,6 +152,12 @@ func (dc *DownloadClients) assignValues(columns []string, values []any) error {
} else if value.Valid {
dc.Tags = value.String
}
case downloadclients.FieldCreateTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field create_time", values[i])
} else if value.Valid {
dc.CreateTime = value.Time
}
default:
dc.selectValues.Set(columns[i], values[i])
}
@@ -182,7 +201,7 @@ func (dc *DownloadClients) String() string {
builder.WriteString(dc.Name)
builder.WriteString(", ")
builder.WriteString("implementation=")
builder.WriteString(dc.Implementation)
builder.WriteString(fmt.Sprintf("%v", dc.Implementation))
builder.WriteString(", ")
builder.WriteString("url=")
builder.WriteString(dc.URL)
@@ -196,8 +215,11 @@ func (dc *DownloadClients) String() string {
builder.WriteString("settings=")
builder.WriteString(dc.Settings)
builder.WriteString(", ")
builder.WriteString("priority=")
builder.WriteString(dc.Priority)
builder.WriteString("priority1=")
builder.WriteString(fmt.Sprintf("%v", dc.Priority1))
builder.WriteString(", ")
builder.WriteString("use_nat_traversal=")
builder.WriteString(fmt.Sprintf("%v", dc.UseNatTraversal))
builder.WriteString(", ")
builder.WriteString("remove_completed_downloads=")
builder.WriteString(fmt.Sprintf("%v", dc.RemoveCompletedDownloads))
@@ -207,6 +229,9 @@ func (dc *DownloadClients) String() string {
builder.WriteString(", ")
builder.WriteString("tags=")
builder.WriteString(dc.Tags)
builder.WriteString(", ")
builder.WriteString("create_time=")
builder.WriteString(dc.CreateTime.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}

View File

@@ -3,6 +3,9 @@
package downloadclients
import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
)
@@ -25,14 +28,18 @@ const (
FieldPassword = "password"
// FieldSettings holds the string denoting the settings field in the database.
FieldSettings = "settings"
// FieldPriority holds the string denoting the priority field in the database.
FieldPriority = "priority"
// FieldPriority1 holds the string denoting the priority1 field in the database.
FieldPriority1 = "priority1"
// FieldUseNatTraversal holds the string denoting the use_nat_traversal field in the database.
FieldUseNatTraversal = "use_nat_traversal"
// FieldRemoveCompletedDownloads holds the string denoting the remove_completed_downloads field in the database.
FieldRemoveCompletedDownloads = "remove_completed_downloads"
// FieldRemoveFailedDownloads holds the string denoting the remove_failed_downloads field in the database.
FieldRemoveFailedDownloads = "remove_failed_downloads"
// FieldTags holds the string denoting the tags field in the database.
FieldTags = "tags"
// FieldCreateTime holds the string denoting the create_time field in the database.
FieldCreateTime = "create_time"
// Table holds the table name of the downloadclients in the database.
Table = "download_clients"
)
@@ -47,10 +54,12 @@ var Columns = []string{
FieldUser,
FieldPassword,
FieldSettings,
FieldPriority,
FieldPriority1,
FieldUseNatTraversal,
FieldRemoveCompletedDownloads,
FieldRemoveFailedDownloads,
FieldTags,
FieldCreateTime,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -70,16 +79,46 @@ var (
DefaultPassword string
// DefaultSettings holds the default value on creation for the "settings" field.
DefaultSettings string
// DefaultPriority holds the default value on creation for the "priority" field.
DefaultPriority string
// DefaultPriority1 holds the default value on creation for the "priority1" field.
DefaultPriority1 int
// Priority1Validator is a validator for the "priority1" field. It is called by the builders before save.
Priority1Validator func(int) error
// DefaultUseNatTraversal holds the default value on creation for the "use_nat_traversal" field.
DefaultUseNatTraversal bool
// DefaultRemoveCompletedDownloads holds the default value on creation for the "remove_completed_downloads" field.
DefaultRemoveCompletedDownloads bool
// DefaultRemoveFailedDownloads holds the default value on creation for the "remove_failed_downloads" field.
DefaultRemoveFailedDownloads bool
// DefaultTags holds the default value on creation for the "tags" field.
DefaultTags string
// DefaultCreateTime holds the default value on creation for the "create_time" field.
DefaultCreateTime func() time.Time
)
// Implementation defines the type for the "implementation" enum field.
type Implementation string
// Implementation values.
const (
ImplementationTransmission Implementation = "transmission"
ImplementationQbittorrent Implementation = "qbittorrent"
ImplementationBuildin Implementation = "buildin"
)
func (i Implementation) String() string {
return string(i)
}
// 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 ImplementationTransmission, ImplementationQbittorrent, ImplementationBuildin:
return nil
default:
return fmt.Errorf("downloadclients: invalid enum value for implementation field: %q", i)
}
}
// OrderOption defines the ordering options for the DownloadClients queries.
type OrderOption func(*sql.Selector)
@@ -123,9 +162,14 @@ func BySettings(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSettings, opts...).ToFunc()
}
// ByPriority orders the results by the priority field.
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPriority, opts...).ToFunc()
// ByPriority1 orders the results by the priority1 field.
func ByPriority1(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPriority1, opts...).ToFunc()
}
// ByUseNatTraversal orders the results by the use_nat_traversal field.
func ByUseNatTraversal(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUseNatTraversal, opts...).ToFunc()
}
// ByRemoveCompletedDownloads orders the results by the remove_completed_downloads field.
@@ -142,3 +186,8 @@ func ByRemoveFailedDownloads(opts ...sql.OrderTermOption) OrderOption {
func ByTags(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTags, opts...).ToFunc()
}
// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}

View File

@@ -4,6 +4,7 @@ package downloadclients
import (
"polaris/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
@@ -63,11 +64,6 @@ func Name(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldName, v))
}
// Implementation applies equality check predicate on the "implementation" field. It's identical to ImplementationEQ.
func Implementation(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldImplementation, v))
}
// URL applies equality check predicate on the "url" field. It's identical to URLEQ.
func URL(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldURL, v))
@@ -88,9 +84,14 @@ func Settings(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldSettings, v))
}
// Priority applies equality check predicate on the "priority" field. It's identical to PriorityEQ.
func Priority(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldPriority, v))
// Priority1 applies equality check predicate on the "priority1" field. It's identical to Priority1EQ.
func Priority1(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldPriority1, v))
}
// UseNatTraversal applies equality check predicate on the "use_nat_traversal" field. It's identical to UseNatTraversalEQ.
func UseNatTraversal(v bool) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldUseNatTraversal, v))
}
// RemoveCompletedDownloads applies equality check predicate on the "remove_completed_downloads" field. It's identical to RemoveCompletedDownloadsEQ.
@@ -108,6 +109,11 @@ func Tags(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldTags, v))
}
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
func CreateTime(v time.Time) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldCreateTime, v))
}
// EnableEQ applies the EQ predicate on the "enable" field.
func EnableEQ(v bool) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldEnable, v))
@@ -184,70 +190,25 @@ func NameContainsFold(v string) predicate.DownloadClients {
}
// ImplementationEQ applies the EQ predicate on the "implementation" field.
func ImplementationEQ(v string) predicate.DownloadClients {
func ImplementationEQ(v Implementation) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldImplementation, v))
}
// ImplementationNEQ applies the NEQ predicate on the "implementation" field.
func ImplementationNEQ(v string) predicate.DownloadClients {
func ImplementationNEQ(v Implementation) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNEQ(FieldImplementation, v))
}
// ImplementationIn applies the In predicate on the "implementation" field.
func ImplementationIn(vs ...string) predicate.DownloadClients {
func ImplementationIn(vs ...Implementation) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldIn(FieldImplementation, vs...))
}
// ImplementationNotIn applies the NotIn predicate on the "implementation" field.
func ImplementationNotIn(vs ...string) predicate.DownloadClients {
func ImplementationNotIn(vs ...Implementation) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNotIn(FieldImplementation, vs...))
}
// ImplementationGT applies the GT predicate on the "implementation" field.
func ImplementationGT(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGT(FieldImplementation, v))
}
// ImplementationGTE applies the GTE predicate on the "implementation" field.
func ImplementationGTE(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGTE(FieldImplementation, v))
}
// ImplementationLT applies the LT predicate on the "implementation" field.
func ImplementationLT(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLT(FieldImplementation, v))
}
// ImplementationLTE applies the LTE predicate on the "implementation" field.
func ImplementationLTE(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLTE(FieldImplementation, v))
}
// ImplementationContains applies the Contains predicate on the "implementation" field.
func ImplementationContains(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldContains(FieldImplementation, v))
}
// ImplementationHasPrefix applies the HasPrefix predicate on the "implementation" field.
func ImplementationHasPrefix(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldHasPrefix(FieldImplementation, v))
}
// ImplementationHasSuffix applies the HasSuffix predicate on the "implementation" field.
func ImplementationHasSuffix(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldHasSuffix(FieldImplementation, v))
}
// ImplementationEqualFold applies the EqualFold predicate on the "implementation" field.
func ImplementationEqualFold(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEqualFold(FieldImplementation, v))
}
// ImplementationContainsFold applies the ContainsFold predicate on the "implementation" field.
func ImplementationContainsFold(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldContainsFold(FieldImplementation, v))
}
// URLEQ applies the EQ predicate on the "url" field.
func URLEQ(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldURL, v))
@@ -508,69 +469,64 @@ func SettingsContainsFold(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldContainsFold(FieldSettings, v))
}
// PriorityEQ applies the EQ predicate on the "priority" field.
func PriorityEQ(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldPriority, v))
// Priority1EQ applies the EQ predicate on the "priority1" field.
func Priority1EQ(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldPriority1, v))
}
// PriorityNEQ applies the NEQ predicate on the "priority" field.
func PriorityNEQ(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNEQ(FieldPriority, v))
// Priority1NEQ applies the NEQ predicate on the "priority1" field.
func Priority1NEQ(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNEQ(FieldPriority1, v))
}
// PriorityIn applies the In predicate on the "priority" field.
func PriorityIn(vs ...string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldIn(FieldPriority, vs...))
// Priority1In applies the In predicate on the "priority1" field.
func Priority1In(vs ...int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldIn(FieldPriority1, vs...))
}
// PriorityNotIn applies the NotIn predicate on the "priority" field.
func PriorityNotIn(vs ...string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNotIn(FieldPriority, vs...))
// Priority1NotIn applies the NotIn predicate on the "priority1" field.
func Priority1NotIn(vs ...int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNotIn(FieldPriority1, vs...))
}
// PriorityGT applies the GT predicate on the "priority" field.
func PriorityGT(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGT(FieldPriority, v))
// Priority1GT applies the GT predicate on the "priority1" field.
func Priority1GT(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGT(FieldPriority1, v))
}
// PriorityGTE applies the GTE predicate on the "priority" field.
func PriorityGTE(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGTE(FieldPriority, v))
// Priority1GTE applies the GTE predicate on the "priority1" field.
func Priority1GTE(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGTE(FieldPriority1, v))
}
// PriorityLT applies the LT predicate on the "priority" field.
func PriorityLT(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLT(FieldPriority, v))
// Priority1LT applies the LT predicate on the "priority1" field.
func Priority1LT(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLT(FieldPriority1, v))
}
// PriorityLTE applies the LTE predicate on the "priority" field.
func PriorityLTE(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLTE(FieldPriority, v))
// Priority1LTE applies the LTE predicate on the "priority1" field.
func Priority1LTE(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLTE(FieldPriority1, v))
}
// PriorityContains applies the Contains predicate on the "priority" field.
func PriorityContains(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldContains(FieldPriority, v))
// UseNatTraversalEQ applies the EQ predicate on the "use_nat_traversal" field.
func UseNatTraversalEQ(v bool) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldUseNatTraversal, v))
}
// PriorityHasPrefix applies the HasPrefix predicate on the "priority" field.
func PriorityHasPrefix(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldHasPrefix(FieldPriority, v))
// UseNatTraversalNEQ applies the NEQ predicate on the "use_nat_traversal" field.
func UseNatTraversalNEQ(v bool) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNEQ(FieldUseNatTraversal, v))
}
// PriorityHasSuffix applies the HasSuffix predicate on the "priority" field.
func PriorityHasSuffix(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldHasSuffix(FieldPriority, v))
// UseNatTraversalIsNil applies the IsNil predicate on the "use_nat_traversal" field.
func UseNatTraversalIsNil() predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldIsNull(FieldUseNatTraversal))
}
// PriorityEqualFold applies the EqualFold predicate on the "priority" field.
func PriorityEqualFold(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEqualFold(FieldPriority, v))
}
// PriorityContainsFold applies the ContainsFold predicate on the "priority" field.
func PriorityContainsFold(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldContainsFold(FieldPriority, v))
// UseNatTraversalNotNil applies the NotNil predicate on the "use_nat_traversal" field.
func UseNatTraversalNotNil() predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNotNull(FieldUseNatTraversal))
}
// RemoveCompletedDownloadsEQ applies the EQ predicate on the "remove_completed_downloads" field.
@@ -658,6 +614,56 @@ func TagsContainsFold(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldContainsFold(FieldTags, v))
}
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
func CreateTimeEQ(v time.Time) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldCreateTime, v))
}
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
func CreateTimeNEQ(v time.Time) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNEQ(FieldCreateTime, v))
}
// CreateTimeIn applies the In predicate on the "create_time" field.
func CreateTimeIn(vs ...time.Time) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldIn(FieldCreateTime, vs...))
}
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
func CreateTimeNotIn(vs ...time.Time) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNotIn(FieldCreateTime, vs...))
}
// CreateTimeGT applies the GT predicate on the "create_time" field.
func CreateTimeGT(v time.Time) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGT(FieldCreateTime, v))
}
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
func CreateTimeGTE(v time.Time) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGTE(FieldCreateTime, v))
}
// CreateTimeLT applies the LT predicate on the "create_time" field.
func CreateTimeLT(v time.Time) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLT(FieldCreateTime, v))
}
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
func CreateTimeLTE(v time.Time) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLTE(FieldCreateTime, v))
}
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
func CreateTimeIsNil() predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldIsNull(FieldCreateTime))
}
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
func CreateTimeNotNil() predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNotNull(FieldCreateTime))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.DownloadClients) predicate.DownloadClients {
return predicate.DownloadClients(sql.AndPredicates(predicates...))

View File

@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"polaris/ent/downloadclients"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -32,8 +33,8 @@ func (dcc *DownloadClientsCreate) SetName(s string) *DownloadClientsCreate {
}
// SetImplementation sets the "implementation" field.
func (dcc *DownloadClientsCreate) SetImplementation(s string) *DownloadClientsCreate {
dcc.mutation.SetImplementation(s)
func (dcc *DownloadClientsCreate) SetImplementation(d downloadclients.Implementation) *DownloadClientsCreate {
dcc.mutation.SetImplementation(d)
return dcc
}
@@ -85,16 +86,30 @@ func (dcc *DownloadClientsCreate) SetNillableSettings(s *string) *DownloadClient
return dcc
}
// SetPriority sets the "priority" field.
func (dcc *DownloadClientsCreate) SetPriority(s string) *DownloadClientsCreate {
dcc.mutation.SetPriority(s)
// SetPriority1 sets the "priority1" field.
func (dcc *DownloadClientsCreate) SetPriority1(i int) *DownloadClientsCreate {
dcc.mutation.SetPriority1(i)
return dcc
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func (dcc *DownloadClientsCreate) SetNillablePriority(s *string) *DownloadClientsCreate {
if s != nil {
dcc.SetPriority(*s)
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
func (dcc *DownloadClientsCreate) SetNillablePriority1(i *int) *DownloadClientsCreate {
if i != nil {
dcc.SetPriority1(*i)
}
return dcc
}
// SetUseNatTraversal sets the "use_nat_traversal" field.
func (dcc *DownloadClientsCreate) SetUseNatTraversal(b bool) *DownloadClientsCreate {
dcc.mutation.SetUseNatTraversal(b)
return dcc
}
// SetNillableUseNatTraversal sets the "use_nat_traversal" field if the given value is not nil.
func (dcc *DownloadClientsCreate) SetNillableUseNatTraversal(b *bool) *DownloadClientsCreate {
if b != nil {
dcc.SetUseNatTraversal(*b)
}
return dcc
}
@@ -141,6 +156,20 @@ func (dcc *DownloadClientsCreate) SetNillableTags(s *string) *DownloadClientsCre
return dcc
}
// SetCreateTime sets the "create_time" field.
func (dcc *DownloadClientsCreate) SetCreateTime(t time.Time) *DownloadClientsCreate {
dcc.mutation.SetCreateTime(t)
return dcc
}
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
func (dcc *DownloadClientsCreate) SetNillableCreateTime(t *time.Time) *DownloadClientsCreate {
if t != nil {
dcc.SetCreateTime(*t)
}
return dcc
}
// Mutation returns the DownloadClientsMutation object of the builder.
func (dcc *DownloadClientsCreate) Mutation() *DownloadClientsMutation {
return dcc.mutation
@@ -188,9 +217,13 @@ func (dcc *DownloadClientsCreate) defaults() {
v := downloadclients.DefaultSettings
dcc.mutation.SetSettings(v)
}
if _, ok := dcc.mutation.Priority(); !ok {
v := downloadclients.DefaultPriority
dcc.mutation.SetPriority(v)
if _, ok := dcc.mutation.Priority1(); !ok {
v := downloadclients.DefaultPriority1
dcc.mutation.SetPriority1(v)
}
if _, ok := dcc.mutation.UseNatTraversal(); !ok {
v := downloadclients.DefaultUseNatTraversal
dcc.mutation.SetUseNatTraversal(v)
}
if _, ok := dcc.mutation.RemoveCompletedDownloads(); !ok {
v := downloadclients.DefaultRemoveCompletedDownloads
@@ -204,6 +237,10 @@ func (dcc *DownloadClientsCreate) defaults() {
v := downloadclients.DefaultTags
dcc.mutation.SetTags(v)
}
if _, ok := dcc.mutation.CreateTime(); !ok {
v := downloadclients.DefaultCreateTime()
dcc.mutation.SetCreateTime(v)
}
}
// check runs all checks and user-defined validators on the builder.
@@ -217,6 +254,11 @@ func (dcc *DownloadClientsCreate) check() error {
if _, ok := dcc.mutation.Implementation(); !ok {
return &ValidationError{Name: "implementation", err: errors.New(`ent: missing required field "DownloadClients.implementation"`)}
}
if v, ok := dcc.mutation.Implementation(); ok {
if err := downloadclients.ImplementationValidator(v); err != nil {
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
}
}
if _, ok := dcc.mutation.URL(); !ok {
return &ValidationError{Name: "url", err: errors.New(`ent: missing required field "DownloadClients.url"`)}
}
@@ -229,8 +271,13 @@ func (dcc *DownloadClientsCreate) check() error {
if _, ok := dcc.mutation.Settings(); !ok {
return &ValidationError{Name: "settings", err: errors.New(`ent: missing required field "DownloadClients.settings"`)}
}
if _, ok := dcc.mutation.Priority(); !ok {
return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "DownloadClients.priority"`)}
if _, ok := dcc.mutation.Priority1(); !ok {
return &ValidationError{Name: "priority1", err: errors.New(`ent: missing required field "DownloadClients.priority1"`)}
}
if v, ok := dcc.mutation.Priority1(); ok {
if err := downloadclients.Priority1Validator(v); err != nil {
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
}
}
if _, ok := dcc.mutation.RemoveCompletedDownloads(); !ok {
return &ValidationError{Name: "remove_completed_downloads", err: errors.New(`ent: missing required field "DownloadClients.remove_completed_downloads"`)}
@@ -276,7 +323,7 @@ func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.Crea
_node.Name = value
}
if value, ok := dcc.mutation.Implementation(); ok {
_spec.SetField(downloadclients.FieldImplementation, field.TypeString, value)
_spec.SetField(downloadclients.FieldImplementation, field.TypeEnum, value)
_node.Implementation = value
}
if value, ok := dcc.mutation.URL(); ok {
@@ -295,9 +342,13 @@ func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.Crea
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
_node.Settings = value
}
if value, ok := dcc.mutation.Priority(); ok {
_spec.SetField(downloadclients.FieldPriority, field.TypeString, value)
_node.Priority = value
if value, ok := dcc.mutation.Priority1(); ok {
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
_node.Priority1 = value
}
if value, ok := dcc.mutation.UseNatTraversal(); ok {
_spec.SetField(downloadclients.FieldUseNatTraversal, field.TypeBool, value)
_node.UseNatTraversal = value
}
if value, ok := dcc.mutation.RemoveCompletedDownloads(); ok {
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
@@ -311,6 +362,10 @@ func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.Crea
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
_node.Tags = value
}
if value, ok := dcc.mutation.CreateTime(); ok {
_spec.SetField(downloadclients.FieldCreateTime, field.TypeTime, value)
_node.CreateTime = value
}
return _node, _spec
}

View File

@@ -9,6 +9,7 @@ import (
"polaris/ent/downloadclients"
"polaris/ent/predicate"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -60,7 +61,7 @@ func (dcq *DownloadClientsQuery) Order(o ...downloadclients.OrderOption) *Downlo
// First returns the first DownloadClients entity from the query.
// Returns a *NotFoundError when no DownloadClients was found.
func (dcq *DownloadClientsQuery) First(ctx context.Context) (*DownloadClients, error) {
nodes, err := dcq.Limit(1).All(setContextOp(ctx, dcq.ctx, "First"))
nodes, err := dcq.Limit(1).All(setContextOp(ctx, dcq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -83,7 +84,7 @@ func (dcq *DownloadClientsQuery) FirstX(ctx context.Context) *DownloadClients {
// Returns a *NotFoundError when no DownloadClients ID was found.
func (dcq *DownloadClientsQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = dcq.Limit(1).IDs(setContextOp(ctx, dcq.ctx, "FirstID")); err != nil {
if ids, err = dcq.Limit(1).IDs(setContextOp(ctx, dcq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -106,7 +107,7 @@ func (dcq *DownloadClientsQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one DownloadClients entity is found.
// Returns a *NotFoundError when no DownloadClients entities are found.
func (dcq *DownloadClientsQuery) Only(ctx context.Context) (*DownloadClients, error) {
nodes, err := dcq.Limit(2).All(setContextOp(ctx, dcq.ctx, "Only"))
nodes, err := dcq.Limit(2).All(setContextOp(ctx, dcq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -134,7 +135,7 @@ func (dcq *DownloadClientsQuery) OnlyX(ctx context.Context) *DownloadClients {
// Returns a *NotFoundError when no entities are found.
func (dcq *DownloadClientsQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = dcq.Limit(2).IDs(setContextOp(ctx, dcq.ctx, "OnlyID")); err != nil {
if ids, err = dcq.Limit(2).IDs(setContextOp(ctx, dcq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -159,7 +160,7 @@ func (dcq *DownloadClientsQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of DownloadClientsSlice.
func (dcq *DownloadClientsQuery) All(ctx context.Context) ([]*DownloadClients, error) {
ctx = setContextOp(ctx, dcq.ctx, "All")
ctx = setContextOp(ctx, dcq.ctx, ent.OpQueryAll)
if err := dcq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -181,7 +182,7 @@ func (dcq *DownloadClientsQuery) IDs(ctx context.Context) (ids []int, err error)
if dcq.ctx.Unique == nil && dcq.path != nil {
dcq.Unique(true)
}
ctx = setContextOp(ctx, dcq.ctx, "IDs")
ctx = setContextOp(ctx, dcq.ctx, ent.OpQueryIDs)
if err = dcq.Select(downloadclients.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -199,7 +200,7 @@ func (dcq *DownloadClientsQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (dcq *DownloadClientsQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, dcq.ctx, "Count")
ctx = setContextOp(ctx, dcq.ctx, ent.OpQueryCount)
if err := dcq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -217,7 +218,7 @@ func (dcq *DownloadClientsQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (dcq *DownloadClientsQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, dcq.ctx, "Exist")
ctx = setContextOp(ctx, dcq.ctx, ent.OpQueryExist)
switch _, err := dcq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -449,7 +450,7 @@ func (dcgb *DownloadClientsGroupBy) Aggregate(fns ...AggregateFunc) *DownloadCli
// Scan applies the selector query and scans the result into the given value.
func (dcgb *DownloadClientsGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, dcgb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, dcgb.build.ctx, ent.OpQueryGroupBy)
if err := dcgb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -497,7 +498,7 @@ func (dcs *DownloadClientsSelect) Aggregate(fns ...AggregateFunc) *DownloadClien
// Scan applies the selector query and scans the result into the given value.
func (dcs *DownloadClientsSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, dcs.ctx, "Select")
ctx = setContextOp(ctx, dcs.ctx, ent.OpQuerySelect)
if err := dcs.prepareQuery(ctx); err != nil {
return err
}

View File

@@ -56,15 +56,15 @@ func (dcu *DownloadClientsUpdate) SetNillableName(s *string) *DownloadClientsUpd
}
// SetImplementation sets the "implementation" field.
func (dcu *DownloadClientsUpdate) SetImplementation(s string) *DownloadClientsUpdate {
dcu.mutation.SetImplementation(s)
func (dcu *DownloadClientsUpdate) SetImplementation(d downloadclients.Implementation) *DownloadClientsUpdate {
dcu.mutation.SetImplementation(d)
return dcu
}
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
func (dcu *DownloadClientsUpdate) SetNillableImplementation(s *string) *DownloadClientsUpdate {
if s != nil {
dcu.SetImplementation(*s)
func (dcu *DownloadClientsUpdate) SetNillableImplementation(d *downloadclients.Implementation) *DownloadClientsUpdate {
if d != nil {
dcu.SetImplementation(*d)
}
return dcu
}
@@ -125,20 +125,47 @@ func (dcu *DownloadClientsUpdate) SetNillableSettings(s *string) *DownloadClient
return dcu
}
// SetPriority sets the "priority" field.
func (dcu *DownloadClientsUpdate) SetPriority(s string) *DownloadClientsUpdate {
dcu.mutation.SetPriority(s)
// SetPriority1 sets the "priority1" field.
func (dcu *DownloadClientsUpdate) SetPriority1(i int) *DownloadClientsUpdate {
dcu.mutation.ResetPriority1()
dcu.mutation.SetPriority1(i)
return dcu
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func (dcu *DownloadClientsUpdate) SetNillablePriority(s *string) *DownloadClientsUpdate {
if s != nil {
dcu.SetPriority(*s)
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
func (dcu *DownloadClientsUpdate) SetNillablePriority1(i *int) *DownloadClientsUpdate {
if i != nil {
dcu.SetPriority1(*i)
}
return dcu
}
// AddPriority1 adds i to the "priority1" field.
func (dcu *DownloadClientsUpdate) AddPriority1(i int) *DownloadClientsUpdate {
dcu.mutation.AddPriority1(i)
return dcu
}
// SetUseNatTraversal sets the "use_nat_traversal" field.
func (dcu *DownloadClientsUpdate) SetUseNatTraversal(b bool) *DownloadClientsUpdate {
dcu.mutation.SetUseNatTraversal(b)
return dcu
}
// SetNillableUseNatTraversal sets the "use_nat_traversal" field if the given value is not nil.
func (dcu *DownloadClientsUpdate) SetNillableUseNatTraversal(b *bool) *DownloadClientsUpdate {
if b != nil {
dcu.SetUseNatTraversal(*b)
}
return dcu
}
// ClearUseNatTraversal clears the value of the "use_nat_traversal" field.
func (dcu *DownloadClientsUpdate) ClearUseNatTraversal() *DownloadClientsUpdate {
dcu.mutation.ClearUseNatTraversal()
return dcu
}
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
func (dcu *DownloadClientsUpdate) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdate {
dcu.mutation.SetRemoveCompletedDownloads(b)
@@ -213,7 +240,25 @@ func (dcu *DownloadClientsUpdate) ExecX(ctx context.Context) {
}
}
// check runs all checks and user-defined validators on the builder.
func (dcu *DownloadClientsUpdate) check() error {
if v, ok := dcu.mutation.Implementation(); ok {
if err := downloadclients.ImplementationValidator(v); err != nil {
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
}
}
if v, ok := dcu.mutation.Priority1(); ok {
if err := downloadclients.Priority1Validator(v); err != nil {
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
}
}
return nil
}
func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := dcu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(downloadclients.Table, downloadclients.Columns, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
if ps := dcu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
@@ -229,7 +274,7 @@ func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error
_spec.SetField(downloadclients.FieldName, field.TypeString, value)
}
if value, ok := dcu.mutation.Implementation(); ok {
_spec.SetField(downloadclients.FieldImplementation, field.TypeString, value)
_spec.SetField(downloadclients.FieldImplementation, field.TypeEnum, value)
}
if value, ok := dcu.mutation.URL(); ok {
_spec.SetField(downloadclients.FieldURL, field.TypeString, value)
@@ -243,8 +288,17 @@ func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error
if value, ok := dcu.mutation.Settings(); ok {
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
}
if value, ok := dcu.mutation.Priority(); ok {
_spec.SetField(downloadclients.FieldPriority, field.TypeString, value)
if value, ok := dcu.mutation.Priority1(); ok {
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
}
if value, ok := dcu.mutation.AddedPriority1(); ok {
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
}
if value, ok := dcu.mutation.UseNatTraversal(); ok {
_spec.SetField(downloadclients.FieldUseNatTraversal, field.TypeBool, value)
}
if dcu.mutation.UseNatTraversalCleared() {
_spec.ClearField(downloadclients.FieldUseNatTraversal, field.TypeBool)
}
if value, ok := dcu.mutation.RemoveCompletedDownloads(); ok {
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
@@ -255,6 +309,9 @@ func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error
if value, ok := dcu.mutation.Tags(); ok {
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
}
if dcu.mutation.CreateTimeCleared() {
_spec.ClearField(downloadclients.FieldCreateTime, field.TypeTime)
}
if n, err = sqlgraph.UpdateNodes(ctx, dcu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{downloadclients.Label}
@@ -304,15 +361,15 @@ func (dcuo *DownloadClientsUpdateOne) SetNillableName(s *string) *DownloadClient
}
// SetImplementation sets the "implementation" field.
func (dcuo *DownloadClientsUpdateOne) SetImplementation(s string) *DownloadClientsUpdateOne {
dcuo.mutation.SetImplementation(s)
func (dcuo *DownloadClientsUpdateOne) SetImplementation(d downloadclients.Implementation) *DownloadClientsUpdateOne {
dcuo.mutation.SetImplementation(d)
return dcuo
}
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
func (dcuo *DownloadClientsUpdateOne) SetNillableImplementation(s *string) *DownloadClientsUpdateOne {
if s != nil {
dcuo.SetImplementation(*s)
func (dcuo *DownloadClientsUpdateOne) SetNillableImplementation(d *downloadclients.Implementation) *DownloadClientsUpdateOne {
if d != nil {
dcuo.SetImplementation(*d)
}
return dcuo
}
@@ -373,20 +430,47 @@ func (dcuo *DownloadClientsUpdateOne) SetNillableSettings(s *string) *DownloadCl
return dcuo
}
// SetPriority sets the "priority" field.
func (dcuo *DownloadClientsUpdateOne) SetPriority(s string) *DownloadClientsUpdateOne {
dcuo.mutation.SetPriority(s)
// SetPriority1 sets the "priority1" field.
func (dcuo *DownloadClientsUpdateOne) SetPriority1(i int) *DownloadClientsUpdateOne {
dcuo.mutation.ResetPriority1()
dcuo.mutation.SetPriority1(i)
return dcuo
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func (dcuo *DownloadClientsUpdateOne) SetNillablePriority(s *string) *DownloadClientsUpdateOne {
if s != nil {
dcuo.SetPriority(*s)
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
func (dcuo *DownloadClientsUpdateOne) SetNillablePriority1(i *int) *DownloadClientsUpdateOne {
if i != nil {
dcuo.SetPriority1(*i)
}
return dcuo
}
// AddPriority1 adds i to the "priority1" field.
func (dcuo *DownloadClientsUpdateOne) AddPriority1(i int) *DownloadClientsUpdateOne {
dcuo.mutation.AddPriority1(i)
return dcuo
}
// SetUseNatTraversal sets the "use_nat_traversal" field.
func (dcuo *DownloadClientsUpdateOne) SetUseNatTraversal(b bool) *DownloadClientsUpdateOne {
dcuo.mutation.SetUseNatTraversal(b)
return dcuo
}
// SetNillableUseNatTraversal sets the "use_nat_traversal" field if the given value is not nil.
func (dcuo *DownloadClientsUpdateOne) SetNillableUseNatTraversal(b *bool) *DownloadClientsUpdateOne {
if b != nil {
dcuo.SetUseNatTraversal(*b)
}
return dcuo
}
// ClearUseNatTraversal clears the value of the "use_nat_traversal" field.
func (dcuo *DownloadClientsUpdateOne) ClearUseNatTraversal() *DownloadClientsUpdateOne {
dcuo.mutation.ClearUseNatTraversal()
return dcuo
}
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
func (dcuo *DownloadClientsUpdateOne) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdateOne {
dcuo.mutation.SetRemoveCompletedDownloads(b)
@@ -474,7 +558,25 @@ func (dcuo *DownloadClientsUpdateOne) ExecX(ctx context.Context) {
}
}
// check runs all checks and user-defined validators on the builder.
func (dcuo *DownloadClientsUpdateOne) check() error {
if v, ok := dcuo.mutation.Implementation(); ok {
if err := downloadclients.ImplementationValidator(v); err != nil {
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
}
}
if v, ok := dcuo.mutation.Priority1(); ok {
if err := downloadclients.Priority1Validator(v); err != nil {
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
}
}
return nil
}
func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *DownloadClients, err error) {
if err := dcuo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(downloadclients.Table, downloadclients.Columns, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
id, ok := dcuo.mutation.ID()
if !ok {
@@ -507,7 +609,7 @@ func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *Downl
_spec.SetField(downloadclients.FieldName, field.TypeString, value)
}
if value, ok := dcuo.mutation.Implementation(); ok {
_spec.SetField(downloadclients.FieldImplementation, field.TypeString, value)
_spec.SetField(downloadclients.FieldImplementation, field.TypeEnum, value)
}
if value, ok := dcuo.mutation.URL(); ok {
_spec.SetField(downloadclients.FieldURL, field.TypeString, value)
@@ -521,8 +623,17 @@ func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *Downl
if value, ok := dcuo.mutation.Settings(); ok {
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
}
if value, ok := dcuo.mutation.Priority(); ok {
_spec.SetField(downloadclients.FieldPriority, field.TypeString, value)
if value, ok := dcuo.mutation.Priority1(); ok {
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
}
if value, ok := dcuo.mutation.AddedPriority1(); ok {
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
}
if value, ok := dcuo.mutation.UseNatTraversal(); ok {
_spec.SetField(downloadclients.FieldUseNatTraversal, field.TypeBool, value)
}
if dcuo.mutation.UseNatTraversalCleared() {
_spec.ClearField(downloadclients.FieldUseNatTraversal, field.TypeBool)
}
if value, ok := dcuo.mutation.RemoveCompletedDownloads(); ok {
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
@@ -533,6 +644,9 @@ func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *Downl
if value, ok := dcuo.mutation.Tags(); ok {
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
}
if dcuo.mutation.CreateTimeCleared() {
_spec.ClearField(downloadclients.FieldCreateTime, field.TypeTime)
}
_node = &DownloadClients{config: dcuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues

View File

@@ -6,11 +6,14 @@ import (
"context"
"errors"
"fmt"
"polaris/ent/blacklist"
"polaris/ent/downloadclients"
"polaris/ent/episode"
"polaris/ent/history"
"polaris/ent/importlist"
"polaris/ent/indexers"
"polaris/ent/media"
"polaris/ent/notificationclient"
"polaris/ent/settings"
"polaris/ent/storage"
"reflect"
@@ -75,17 +78,20 @@ var (
columnCheck sql.ColumnCheck
)
// columnChecker checks if the column exists in the given table.
// checkColumn checks if the column exists in the given table.
func checkColumn(table, column string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
downloadclients.Table: downloadclients.ValidColumn,
episode.Table: episode.ValidColumn,
history.Table: history.ValidColumn,
indexers.Table: indexers.ValidColumn,
media.Table: media.ValidColumn,
settings.Table: settings.ValidColumn,
storage.Table: storage.ValidColumn,
blacklist.Table: blacklist.ValidColumn,
downloadclients.Table: downloadclients.ValidColumn,
episode.Table: episode.ValidColumn,
history.Table: history.ValidColumn,
importlist.Table: importlist.ValidColumn,
indexers.Table: indexers.ValidColumn,
media.Table: media.ValidColumn,
notificationclient.Table: notificationclient.ValidColumn,
settings.Table: settings.ValidColumn,
storage.Table: storage.ValidColumn,
})
})
return columnCheck(table, column)

View File

@@ -4,6 +4,7 @@ package enttest
import (
"context"
"polaris/ent"
// required by schema hooks.
_ "polaris/ent/runtime"

View File

@@ -7,6 +7,7 @@ import (
"polaris/ent/episode"
"polaris/ent/media"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
@@ -31,8 +32,12 @@ type Episode struct {
AirDate string `json:"air_date,omitempty"`
// Status holds the value of the "status" field.
Status episode.Status `json:"status,omitempty"`
// FileInStorage holds the value of the "file_in_storage" field.
FileInStorage string `json:"file_in_storage,omitempty"`
// Monitored holds the value of the "monitored" field.
Monitored bool `json:"monitored"`
// TargetFile holds the value of the "target_file" field.
TargetFile string `json:"target_file,omitempty"`
// CreateTime holds the value of the "create_time" field.
CreateTime time.Time `json:"create_time,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the EpisodeQuery when eager-loading is set.
Edges EpisodeEdges `json:"edges"`
@@ -64,10 +69,14 @@ func (*Episode) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case episode.FieldMonitored:
values[i] = new(sql.NullBool)
case episode.FieldID, episode.FieldMediaID, episode.FieldSeasonNumber, episode.FieldEpisodeNumber:
values[i] = new(sql.NullInt64)
case episode.FieldTitle, episode.FieldOverview, episode.FieldAirDate, episode.FieldStatus, episode.FieldFileInStorage:
case episode.FieldTitle, episode.FieldOverview, episode.FieldAirDate, episode.FieldStatus, episode.FieldTargetFile:
values[i] = new(sql.NullString)
case episode.FieldCreateTime:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
@@ -131,11 +140,23 @@ func (e *Episode) assignValues(columns []string, values []any) error {
} else if value.Valid {
e.Status = episode.Status(value.String)
}
case episode.FieldFileInStorage:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field file_in_storage", values[i])
case episode.FieldMonitored:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field monitored", values[i])
} else if value.Valid {
e.FileInStorage = value.String
e.Monitored = value.Bool
}
case episode.FieldTargetFile:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field target_file", values[i])
} else if value.Valid {
e.TargetFile = value.String
}
case episode.FieldCreateTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field create_time", values[i])
} else if value.Valid {
e.CreateTime = value.Time
}
default:
e.selectValues.Set(columns[i], values[i])
@@ -199,8 +220,14 @@ func (e *Episode) String() string {
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", e.Status))
builder.WriteString(", ")
builder.WriteString("file_in_storage=")
builder.WriteString(e.FileInStorage)
builder.WriteString("monitored=")
builder.WriteString(fmt.Sprintf("%v", e.Monitored))
builder.WriteString(", ")
builder.WriteString("target_file=")
builder.WriteString(e.TargetFile)
builder.WriteString(", ")
builder.WriteString("create_time=")
builder.WriteString(e.CreateTime.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}

View File

@@ -4,6 +4,7 @@ package episode
import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@@ -28,8 +29,12 @@ const (
FieldAirDate = "air_date"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldFileInStorage holds the string denoting the file_in_storage field in the database.
FieldFileInStorage = "file_in_storage"
// FieldMonitored holds the string denoting the monitored field in the database.
FieldMonitored = "monitored"
// FieldTargetFile holds the string denoting the target_file field in the database.
FieldTargetFile = "target_file"
// FieldCreateTime holds the string denoting the create_time field in the database.
FieldCreateTime = "create_time"
// EdgeMedia holds the string denoting the media edge name in mutations.
EdgeMedia = "media"
// Table holds the table name of the episode in the database.
@@ -53,7 +58,9 @@ var Columns = []string{
FieldOverview,
FieldAirDate,
FieldStatus,
FieldFileInStorage,
FieldMonitored,
FieldTargetFile,
FieldCreateTime,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -66,6 +73,13 @@ func ValidColumn(column string) bool {
return false
}
var (
// DefaultMonitored holds the default value on creation for the "monitored" field.
DefaultMonitored bool
// DefaultCreateTime holds the default value on creation for the "create_time" field.
DefaultCreateTime func() time.Time
)
// Status defines the type for the "status" enum field.
type Status string
@@ -136,9 +150,19 @@ func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByFileInStorage orders the results by the file_in_storage field.
func ByFileInStorage(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFileInStorage, opts...).ToFunc()
// ByMonitored orders the results by the monitored field.
func ByMonitored(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMonitored, opts...).ToFunc()
}
// ByTargetFile orders the results by the target_file field.
func ByTargetFile(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTargetFile, opts...).ToFunc()
}
// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}
// ByMediaField orders the results by media field.

View File

@@ -4,6 +4,7 @@ package episode
import (
"polaris/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@@ -84,9 +85,19 @@ func AirDate(v string) predicate.Episode {
return predicate.Episode(sql.FieldEQ(FieldAirDate, v))
}
// FileInStorage applies equality check predicate on the "file_in_storage" field. It's identical to FileInStorageEQ.
func FileInStorage(v string) predicate.Episode {
return predicate.Episode(sql.FieldEQ(FieldFileInStorage, v))
// Monitored applies equality check predicate on the "monitored" field. It's identical to MonitoredEQ.
func Monitored(v bool) predicate.Episode {
return predicate.Episode(sql.FieldEQ(FieldMonitored, v))
}
// TargetFile applies equality check predicate on the "target_file" field. It's identical to TargetFileEQ.
func TargetFile(v string) predicate.Episode {
return predicate.Episode(sql.FieldEQ(FieldTargetFile, v))
}
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
func CreateTime(v time.Time) predicate.Episode {
return predicate.Episode(sql.FieldEQ(FieldCreateTime, v))
}
// MediaIDEQ applies the EQ predicate on the "media_id" field.
@@ -414,79 +425,139 @@ func StatusNotIn(vs ...Status) predicate.Episode {
return predicate.Episode(sql.FieldNotIn(FieldStatus, vs...))
}
// FileInStorageEQ applies the EQ predicate on the "file_in_storage" field.
func FileInStorageEQ(v string) predicate.Episode {
return predicate.Episode(sql.FieldEQ(FieldFileInStorage, v))
// MonitoredEQ applies the EQ predicate on the "monitored" field.
func MonitoredEQ(v bool) predicate.Episode {
return predicate.Episode(sql.FieldEQ(FieldMonitored, v))
}
// FileInStorageNEQ applies the NEQ predicate on the "file_in_storage" field.
func FileInStorageNEQ(v string) predicate.Episode {
return predicate.Episode(sql.FieldNEQ(FieldFileInStorage, v))
// MonitoredNEQ applies the NEQ predicate on the "monitored" field.
func MonitoredNEQ(v bool) predicate.Episode {
return predicate.Episode(sql.FieldNEQ(FieldMonitored, v))
}
// FileInStorageIn applies the In predicate on the "file_in_storage" field.
func FileInStorageIn(vs ...string) predicate.Episode {
return predicate.Episode(sql.FieldIn(FieldFileInStorage, vs...))
// TargetFileEQ applies the EQ predicate on the "target_file" field.
func TargetFileEQ(v string) predicate.Episode {
return predicate.Episode(sql.FieldEQ(FieldTargetFile, v))
}
// FileInStorageNotIn applies the NotIn predicate on the "file_in_storage" field.
func FileInStorageNotIn(vs ...string) predicate.Episode {
return predicate.Episode(sql.FieldNotIn(FieldFileInStorage, vs...))
// TargetFileNEQ applies the NEQ predicate on the "target_file" field.
func TargetFileNEQ(v string) predicate.Episode {
return predicate.Episode(sql.FieldNEQ(FieldTargetFile, v))
}
// FileInStorageGT applies the GT predicate on the "file_in_storage" field.
func FileInStorageGT(v string) predicate.Episode {
return predicate.Episode(sql.FieldGT(FieldFileInStorage, v))
// TargetFileIn applies the In predicate on the "target_file" field.
func TargetFileIn(vs ...string) predicate.Episode {
return predicate.Episode(sql.FieldIn(FieldTargetFile, vs...))
}
// FileInStorageGTE applies the GTE predicate on the "file_in_storage" field.
func FileInStorageGTE(v string) predicate.Episode {
return predicate.Episode(sql.FieldGTE(FieldFileInStorage, v))
// TargetFileNotIn applies the NotIn predicate on the "target_file" field.
func TargetFileNotIn(vs ...string) predicate.Episode {
return predicate.Episode(sql.FieldNotIn(FieldTargetFile, vs...))
}
// FileInStorageLT applies the LT predicate on the "file_in_storage" field.
func FileInStorageLT(v string) predicate.Episode {
return predicate.Episode(sql.FieldLT(FieldFileInStorage, v))
// TargetFileGT applies the GT predicate on the "target_file" field.
func TargetFileGT(v string) predicate.Episode {
return predicate.Episode(sql.FieldGT(FieldTargetFile, v))
}
// FileInStorageLTE applies the LTE predicate on the "file_in_storage" field.
func FileInStorageLTE(v string) predicate.Episode {
return predicate.Episode(sql.FieldLTE(FieldFileInStorage, v))
// TargetFileGTE applies the GTE predicate on the "target_file" field.
func TargetFileGTE(v string) predicate.Episode {
return predicate.Episode(sql.FieldGTE(FieldTargetFile, v))
}
// FileInStorageContains applies the Contains predicate on the "file_in_storage" field.
func FileInStorageContains(v string) predicate.Episode {
return predicate.Episode(sql.FieldContains(FieldFileInStorage, v))
// TargetFileLT applies the LT predicate on the "target_file" field.
func TargetFileLT(v string) predicate.Episode {
return predicate.Episode(sql.FieldLT(FieldTargetFile, v))
}
// FileInStorageHasPrefix applies the HasPrefix predicate on the "file_in_storage" field.
func FileInStorageHasPrefix(v string) predicate.Episode {
return predicate.Episode(sql.FieldHasPrefix(FieldFileInStorage, v))
// TargetFileLTE applies the LTE predicate on the "target_file" field.
func TargetFileLTE(v string) predicate.Episode {
return predicate.Episode(sql.FieldLTE(FieldTargetFile, v))
}
// FileInStorageHasSuffix applies the HasSuffix predicate on the "file_in_storage" field.
func FileInStorageHasSuffix(v string) predicate.Episode {
return predicate.Episode(sql.FieldHasSuffix(FieldFileInStorage, v))
// TargetFileContains applies the Contains predicate on the "target_file" field.
func TargetFileContains(v string) predicate.Episode {
return predicate.Episode(sql.FieldContains(FieldTargetFile, v))
}
// FileInStorageIsNil applies the IsNil predicate on the "file_in_storage" field.
func FileInStorageIsNil() predicate.Episode {
return predicate.Episode(sql.FieldIsNull(FieldFileInStorage))
// TargetFileHasPrefix applies the HasPrefix predicate on the "target_file" field.
func TargetFileHasPrefix(v string) predicate.Episode {
return predicate.Episode(sql.FieldHasPrefix(FieldTargetFile, v))
}
// FileInStorageNotNil applies the NotNil predicate on the "file_in_storage" field.
func FileInStorageNotNil() predicate.Episode {
return predicate.Episode(sql.FieldNotNull(FieldFileInStorage))
// TargetFileHasSuffix applies the HasSuffix predicate on the "target_file" field.
func TargetFileHasSuffix(v string) predicate.Episode {
return predicate.Episode(sql.FieldHasSuffix(FieldTargetFile, v))
}
// FileInStorageEqualFold applies the EqualFold predicate on the "file_in_storage" field.
func FileInStorageEqualFold(v string) predicate.Episode {
return predicate.Episode(sql.FieldEqualFold(FieldFileInStorage, v))
// TargetFileIsNil applies the IsNil predicate on the "target_file" field.
func TargetFileIsNil() predicate.Episode {
return predicate.Episode(sql.FieldIsNull(FieldTargetFile))
}
// FileInStorageContainsFold applies the ContainsFold predicate on the "file_in_storage" field.
func FileInStorageContainsFold(v string) predicate.Episode {
return predicate.Episode(sql.FieldContainsFold(FieldFileInStorage, v))
// TargetFileNotNil applies the NotNil predicate on the "target_file" field.
func TargetFileNotNil() predicate.Episode {
return predicate.Episode(sql.FieldNotNull(FieldTargetFile))
}
// TargetFileEqualFold applies the EqualFold predicate on the "target_file" field.
func TargetFileEqualFold(v string) predicate.Episode {
return predicate.Episode(sql.FieldEqualFold(FieldTargetFile, v))
}
// TargetFileContainsFold applies the ContainsFold predicate on the "target_file" field.
func TargetFileContainsFold(v string) predicate.Episode {
return predicate.Episode(sql.FieldContainsFold(FieldTargetFile, v))
}
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
func CreateTimeEQ(v time.Time) predicate.Episode {
return predicate.Episode(sql.FieldEQ(FieldCreateTime, v))
}
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
func CreateTimeNEQ(v time.Time) predicate.Episode {
return predicate.Episode(sql.FieldNEQ(FieldCreateTime, v))
}
// CreateTimeIn applies the In predicate on the "create_time" field.
func CreateTimeIn(vs ...time.Time) predicate.Episode {
return predicate.Episode(sql.FieldIn(FieldCreateTime, vs...))
}
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
func CreateTimeNotIn(vs ...time.Time) predicate.Episode {
return predicate.Episode(sql.FieldNotIn(FieldCreateTime, vs...))
}
// CreateTimeGT applies the GT predicate on the "create_time" field.
func CreateTimeGT(v time.Time) predicate.Episode {
return predicate.Episode(sql.FieldGT(FieldCreateTime, v))
}
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
func CreateTimeGTE(v time.Time) predicate.Episode {
return predicate.Episode(sql.FieldGTE(FieldCreateTime, v))
}
// CreateTimeLT applies the LT predicate on the "create_time" field.
func CreateTimeLT(v time.Time) predicate.Episode {
return predicate.Episode(sql.FieldLT(FieldCreateTime, v))
}
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
func CreateTimeLTE(v time.Time) predicate.Episode {
return predicate.Episode(sql.FieldLTE(FieldCreateTime, v))
}
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
func CreateTimeIsNil() predicate.Episode {
return predicate.Episode(sql.FieldIsNull(FieldCreateTime))
}
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
func CreateTimeNotNil() predicate.Episode {
return predicate.Episode(sql.FieldNotNull(FieldCreateTime))
}
// HasMedia applies the HasEdge predicate on the "media" edge.

View File

@@ -8,6 +8,7 @@ import (
"fmt"
"polaris/ent/episode"
"polaris/ent/media"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -78,16 +79,44 @@ func (ec *EpisodeCreate) SetNillableStatus(e *episode.Status) *EpisodeCreate {
return ec
}
// SetFileInStorage sets the "file_in_storage" field.
func (ec *EpisodeCreate) SetFileInStorage(s string) *EpisodeCreate {
ec.mutation.SetFileInStorage(s)
// SetMonitored sets the "monitored" field.
func (ec *EpisodeCreate) SetMonitored(b bool) *EpisodeCreate {
ec.mutation.SetMonitored(b)
return ec
}
// SetNillableFileInStorage sets the "file_in_storage" field if the given value is not nil.
func (ec *EpisodeCreate) SetNillableFileInStorage(s *string) *EpisodeCreate {
// SetNillableMonitored sets the "monitored" field if the given value is not nil.
func (ec *EpisodeCreate) SetNillableMonitored(b *bool) *EpisodeCreate {
if b != nil {
ec.SetMonitored(*b)
}
return ec
}
// SetTargetFile sets the "target_file" field.
func (ec *EpisodeCreate) SetTargetFile(s string) *EpisodeCreate {
ec.mutation.SetTargetFile(s)
return ec
}
// SetNillableTargetFile sets the "target_file" field if the given value is not nil.
func (ec *EpisodeCreate) SetNillableTargetFile(s *string) *EpisodeCreate {
if s != nil {
ec.SetFileInStorage(*s)
ec.SetTargetFile(*s)
}
return ec
}
// SetCreateTime sets the "create_time" field.
func (ec *EpisodeCreate) SetCreateTime(t time.Time) *EpisodeCreate {
ec.mutation.SetCreateTime(t)
return ec
}
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
func (ec *EpisodeCreate) SetNillableCreateTime(t *time.Time) *EpisodeCreate {
if t != nil {
ec.SetCreateTime(*t)
}
return ec
}
@@ -136,6 +165,14 @@ func (ec *EpisodeCreate) defaults() {
v := episode.DefaultStatus
ec.mutation.SetStatus(v)
}
if _, ok := ec.mutation.Monitored(); !ok {
v := episode.DefaultMonitored
ec.mutation.SetMonitored(v)
}
if _, ok := ec.mutation.CreateTime(); !ok {
v := episode.DefaultCreateTime()
ec.mutation.SetCreateTime(v)
}
}
// check runs all checks and user-defined validators on the builder.
@@ -163,6 +200,9 @@ func (ec *EpisodeCreate) check() error {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Episode.status": %w`, err)}
}
}
if _, ok := ec.mutation.Monitored(); !ok {
return &ValidationError{Name: "monitored", err: errors.New(`ent: missing required field "Episode.monitored"`)}
}
return nil
}
@@ -213,9 +253,17 @@ func (ec *EpisodeCreate) createSpec() (*Episode, *sqlgraph.CreateSpec) {
_spec.SetField(episode.FieldStatus, field.TypeEnum, value)
_node.Status = value
}
if value, ok := ec.mutation.FileInStorage(); ok {
_spec.SetField(episode.FieldFileInStorage, field.TypeString, value)
_node.FileInStorage = value
if value, ok := ec.mutation.Monitored(); ok {
_spec.SetField(episode.FieldMonitored, field.TypeBool, value)
_node.Monitored = value
}
if value, ok := ec.mutation.TargetFile(); ok {
_spec.SetField(episode.FieldTargetFile, field.TypeString, value)
_node.TargetFile = value
}
if value, ok := ec.mutation.CreateTime(); ok {
_spec.SetField(episode.FieldCreateTime, field.TypeTime, value)
_node.CreateTime = value
}
if nodes := ec.mutation.MediaIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{

View File

@@ -10,6 +10,7 @@ import (
"polaris/ent/media"
"polaris/ent/predicate"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -84,7 +85,7 @@ func (eq *EpisodeQuery) QueryMedia() *MediaQuery {
// First returns the first Episode entity from the query.
// Returns a *NotFoundError when no Episode was found.
func (eq *EpisodeQuery) First(ctx context.Context) (*Episode, error) {
nodes, err := eq.Limit(1).All(setContextOp(ctx, eq.ctx, "First"))
nodes, err := eq.Limit(1).All(setContextOp(ctx, eq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -107,7 +108,7 @@ func (eq *EpisodeQuery) FirstX(ctx context.Context) *Episode {
// Returns a *NotFoundError when no Episode ID was found.
func (eq *EpisodeQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = eq.Limit(1).IDs(setContextOp(ctx, eq.ctx, "FirstID")); err != nil {
if ids, err = eq.Limit(1).IDs(setContextOp(ctx, eq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -130,7 +131,7 @@ func (eq *EpisodeQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Episode entity is found.
// Returns a *NotFoundError when no Episode entities are found.
func (eq *EpisodeQuery) Only(ctx context.Context) (*Episode, error) {
nodes, err := eq.Limit(2).All(setContextOp(ctx, eq.ctx, "Only"))
nodes, err := eq.Limit(2).All(setContextOp(ctx, eq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -158,7 +159,7 @@ func (eq *EpisodeQuery) OnlyX(ctx context.Context) *Episode {
// Returns a *NotFoundError when no entities are found.
func (eq *EpisodeQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = eq.Limit(2).IDs(setContextOp(ctx, eq.ctx, "OnlyID")); err != nil {
if ids, err = eq.Limit(2).IDs(setContextOp(ctx, eq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -183,7 +184,7 @@ func (eq *EpisodeQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Episodes.
func (eq *EpisodeQuery) All(ctx context.Context) ([]*Episode, error) {
ctx = setContextOp(ctx, eq.ctx, "All")
ctx = setContextOp(ctx, eq.ctx, ent.OpQueryAll)
if err := eq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -205,7 +206,7 @@ func (eq *EpisodeQuery) IDs(ctx context.Context) (ids []int, err error) {
if eq.ctx.Unique == nil && eq.path != nil {
eq.Unique(true)
}
ctx = setContextOp(ctx, eq.ctx, "IDs")
ctx = setContextOp(ctx, eq.ctx, ent.OpQueryIDs)
if err = eq.Select(episode.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -223,7 +224,7 @@ func (eq *EpisodeQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (eq *EpisodeQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, eq.ctx, "Count")
ctx = setContextOp(ctx, eq.ctx, ent.OpQueryCount)
if err := eq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -241,7 +242,7 @@ func (eq *EpisodeQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (eq *EpisodeQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, eq.ctx, "Exist")
ctx = setContextOp(ctx, eq.ctx, ent.OpQueryExist)
switch _, err := eq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -528,7 +529,7 @@ func (egb *EpisodeGroupBy) Aggregate(fns ...AggregateFunc) *EpisodeGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (egb *EpisodeGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, egb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, egb.build.ctx, ent.OpQueryGroupBy)
if err := egb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -576,7 +577,7 @@ func (es *EpisodeSelect) Aggregate(fns ...AggregateFunc) *EpisodeSelect {
// Scan applies the selector query and scans the result into the given value.
func (es *EpisodeSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, es.ctx, "Select")
ctx = setContextOp(ctx, es.ctx, ent.OpQuerySelect)
if err := es.prepareQuery(ctx); err != nil {
return err
}

View File

@@ -146,23 +146,37 @@ func (eu *EpisodeUpdate) SetNillableStatus(e *episode.Status) *EpisodeUpdate {
return eu
}
// SetFileInStorage sets the "file_in_storage" field.
func (eu *EpisodeUpdate) SetFileInStorage(s string) *EpisodeUpdate {
eu.mutation.SetFileInStorage(s)
// SetMonitored sets the "monitored" field.
func (eu *EpisodeUpdate) SetMonitored(b bool) *EpisodeUpdate {
eu.mutation.SetMonitored(b)
return eu
}
// SetNillableFileInStorage sets the "file_in_storage" field if the given value is not nil.
func (eu *EpisodeUpdate) SetNillableFileInStorage(s *string) *EpisodeUpdate {
if s != nil {
eu.SetFileInStorage(*s)
// SetNillableMonitored sets the "monitored" field if the given value is not nil.
func (eu *EpisodeUpdate) SetNillableMonitored(b *bool) *EpisodeUpdate {
if b != nil {
eu.SetMonitored(*b)
}
return eu
}
// ClearFileInStorage clears the value of the "file_in_storage" field.
func (eu *EpisodeUpdate) ClearFileInStorage() *EpisodeUpdate {
eu.mutation.ClearFileInStorage()
// SetTargetFile sets the "target_file" field.
func (eu *EpisodeUpdate) SetTargetFile(s string) *EpisodeUpdate {
eu.mutation.SetTargetFile(s)
return eu
}
// SetNillableTargetFile sets the "target_file" field if the given value is not nil.
func (eu *EpisodeUpdate) SetNillableTargetFile(s *string) *EpisodeUpdate {
if s != nil {
eu.SetTargetFile(*s)
}
return eu
}
// ClearTargetFile clears the value of the "target_file" field.
func (eu *EpisodeUpdate) ClearTargetFile() *EpisodeUpdate {
eu.mutation.ClearTargetFile()
return eu
}
@@ -255,11 +269,17 @@ func (eu *EpisodeUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := eu.mutation.Status(); ok {
_spec.SetField(episode.FieldStatus, field.TypeEnum, value)
}
if value, ok := eu.mutation.FileInStorage(); ok {
_spec.SetField(episode.FieldFileInStorage, field.TypeString, value)
if value, ok := eu.mutation.Monitored(); ok {
_spec.SetField(episode.FieldMonitored, field.TypeBool, value)
}
if eu.mutation.FileInStorageCleared() {
_spec.ClearField(episode.FieldFileInStorage, field.TypeString)
if value, ok := eu.mutation.TargetFile(); ok {
_spec.SetField(episode.FieldTargetFile, field.TypeString, value)
}
if eu.mutation.TargetFileCleared() {
_spec.ClearField(episode.FieldTargetFile, field.TypeString)
}
if eu.mutation.CreateTimeCleared() {
_spec.ClearField(episode.FieldCreateTime, field.TypeTime)
}
if eu.mutation.MediaCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -428,23 +448,37 @@ func (euo *EpisodeUpdateOne) SetNillableStatus(e *episode.Status) *EpisodeUpdate
return euo
}
// SetFileInStorage sets the "file_in_storage" field.
func (euo *EpisodeUpdateOne) SetFileInStorage(s string) *EpisodeUpdateOne {
euo.mutation.SetFileInStorage(s)
// SetMonitored sets the "monitored" field.
func (euo *EpisodeUpdateOne) SetMonitored(b bool) *EpisodeUpdateOne {
euo.mutation.SetMonitored(b)
return euo
}
// SetNillableFileInStorage sets the "file_in_storage" field if the given value is not nil.
func (euo *EpisodeUpdateOne) SetNillableFileInStorage(s *string) *EpisodeUpdateOne {
if s != nil {
euo.SetFileInStorage(*s)
// SetNillableMonitored sets the "monitored" field if the given value is not nil.
func (euo *EpisodeUpdateOne) SetNillableMonitored(b *bool) *EpisodeUpdateOne {
if b != nil {
euo.SetMonitored(*b)
}
return euo
}
// ClearFileInStorage clears the value of the "file_in_storage" field.
func (euo *EpisodeUpdateOne) ClearFileInStorage() *EpisodeUpdateOne {
euo.mutation.ClearFileInStorage()
// SetTargetFile sets the "target_file" field.
func (euo *EpisodeUpdateOne) SetTargetFile(s string) *EpisodeUpdateOne {
euo.mutation.SetTargetFile(s)
return euo
}
// SetNillableTargetFile sets the "target_file" field if the given value is not nil.
func (euo *EpisodeUpdateOne) SetNillableTargetFile(s *string) *EpisodeUpdateOne {
if s != nil {
euo.SetTargetFile(*s)
}
return euo
}
// ClearTargetFile clears the value of the "target_file" field.
func (euo *EpisodeUpdateOne) ClearTargetFile() *EpisodeUpdateOne {
euo.mutation.ClearTargetFile()
return euo
}
@@ -567,11 +601,17 @@ func (euo *EpisodeUpdateOne) sqlSave(ctx context.Context) (_node *Episode, err e
if value, ok := euo.mutation.Status(); ok {
_spec.SetField(episode.FieldStatus, field.TypeEnum, value)
}
if value, ok := euo.mutation.FileInStorage(); ok {
_spec.SetField(episode.FieldFileInStorage, field.TypeString, value)
if value, ok := euo.mutation.Monitored(); ok {
_spec.SetField(episode.FieldMonitored, field.TypeBool, value)
}
if euo.mutation.FileInStorageCleared() {
_spec.ClearField(episode.FieldFileInStorage, field.TypeString)
if value, ok := euo.mutation.TargetFile(); ok {
_spec.SetField(episode.FieldTargetFile, field.TypeString, value)
}
if euo.mutation.TargetFileCleared() {
_spec.ClearField(episode.FieldTargetFile, field.TypeString)
}
if euo.mutation.CreateTimeCleared() {
_spec.ClearField(episode.FieldCreateTime, field.TypeTime)
}
if euo.mutation.MediaCleared() {
edge := &sqlgraph.EdgeSpec{

View File

@@ -3,6 +3,7 @@
package ent
import (
"encoding/json"
"fmt"
"polaris/ent/history"
"strings"
@@ -19,8 +20,10 @@ 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.
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.
@@ -29,10 +32,18 @@ type History struct {
TargetDir string `json:"target_dir,omitempty"`
// Size holds the value of the "size" field.
Size int `json:"size,omitempty"`
// DownloadClientID holds the value of the "download_client_id" field.
DownloadClientID int `json:"download_client_id,omitempty"`
// IndexerID holds the value of the "indexer_id" field.
IndexerID int `json:"indexer_id,omitempty"`
// torrent link
Link string `json:"link,omitempty"`
// torrent hash
Hash string `json:"hash,omitempty"`
// Status holds the value of the "status" field.
Status history.Status `json:"status,omitempty"`
// Saved holds the value of the "saved" field.
Saved string `json:"saved,omitempty"`
// CreateTime holds the value of the "create_time" field.
CreateTime time.Time `json:"create_time,omitempty"`
selectValues sql.SelectValues
}
@@ -41,11 +52,13 @@ 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:
case history.FieldEpisodeNums:
values[i] = new([]byte)
case history.FieldID, history.FieldMediaID, history.FieldSeasonNum, history.FieldSize, history.FieldDownloadClientID, history.FieldIndexerID:
values[i] = new(sql.NullInt64)
case history.FieldSourceTitle, history.FieldTargetDir, history.FieldStatus, history.FieldSaved:
case history.FieldSourceTitle, history.FieldTargetDir, history.FieldLink, history.FieldHash, history.FieldStatus:
values[i] = new(sql.NullString)
case history.FieldDate:
case history.FieldDate, history.FieldCreateTime:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
@@ -74,11 +87,19 @@ func (h *History) assignValues(columns []string, values []any) error {
} else if value.Valid {
h.MediaID = int(value.Int64)
}
case history.FieldEpisodeID:
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 episode_id", values[i])
return fmt.Errorf("unexpected type %T for field season_num", values[i])
} else if value.Valid {
h.EpisodeID = int(value.Int64)
h.SeasonNum = int(value.Int64)
}
case history.FieldSourceTitle:
if value, ok := values[i].(*sql.NullString); !ok {
@@ -104,17 +125,41 @@ func (h *History) assignValues(columns []string, values []any) error {
} else if value.Valid {
h.Size = int(value.Int64)
}
case history.FieldDownloadClientID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field download_client_id", values[i])
} else if value.Valid {
h.DownloadClientID = int(value.Int64)
}
case history.FieldIndexerID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field indexer_id", values[i])
} else if value.Valid {
h.IndexerID = int(value.Int64)
}
case history.FieldLink:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field link", values[i])
} else if value.Valid {
h.Link = value.String
}
case history.FieldHash:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field hash", values[i])
} else if value.Valid {
h.Hash = value.String
}
case history.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
h.Status = history.Status(value.String)
}
case history.FieldSaved:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field saved", values[i])
case history.FieldCreateTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field create_time", values[i])
} else if value.Valid {
h.Saved = value.String
h.CreateTime = value.Time
}
default:
h.selectValues.Set(columns[i], values[i])
@@ -155,8 +200,11 @@ func (h *History) String() string {
builder.WriteString("media_id=")
builder.WriteString(fmt.Sprintf("%v", h.MediaID))
builder.WriteString(", ")
builder.WriteString("episode_id=")
builder.WriteString(fmt.Sprintf("%v", h.EpisodeID))
builder.WriteString("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)
@@ -170,11 +218,23 @@ func (h *History) String() string {
builder.WriteString("size=")
builder.WriteString(fmt.Sprintf("%v", h.Size))
builder.WriteString(", ")
builder.WriteString("download_client_id=")
builder.WriteString(fmt.Sprintf("%v", h.DownloadClientID))
builder.WriteString(", ")
builder.WriteString("indexer_id=")
builder.WriteString(fmt.Sprintf("%v", h.IndexerID))
builder.WriteString(", ")
builder.WriteString("link=")
builder.WriteString(h.Link)
builder.WriteString(", ")
builder.WriteString("hash=")
builder.WriteString(h.Hash)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", h.Status))
builder.WriteString(", ")
builder.WriteString("saved=")
builder.WriteString(h.Saved)
builder.WriteString("create_time=")
builder.WriteString(h.CreateTime.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}

View File

@@ -4,6 +4,7 @@ package history
import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
)
@@ -15,8 +16,10 @@ const (
FieldID = "id"
// FieldMediaID holds the string denoting the media_id field in the database.
FieldMediaID = "media_id"
// FieldEpisodeID holds the string denoting the episode_id field in the database.
FieldEpisodeID = "episode_id"
// FieldEpisodeNums holds the string denoting the episode_nums field in the database.
FieldEpisodeNums = "episode_nums"
// FieldSeasonNum holds the string denoting the season_num field in the database.
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.
@@ -25,10 +28,18 @@ const (
FieldTargetDir = "target_dir"
// FieldSize holds the string denoting the size field in the database.
FieldSize = "size"
// FieldDownloadClientID holds the string denoting the download_client_id field in the database.
FieldDownloadClientID = "download_client_id"
// FieldIndexerID holds the string denoting the indexer_id field in the database.
FieldIndexerID = "indexer_id"
// FieldLink holds the string denoting the link field in the database.
FieldLink = "link"
// FieldHash holds the string denoting the hash field in the database.
FieldHash = "hash"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldSaved holds the string denoting the saved field in the database.
FieldSaved = "saved"
// FieldCreateTime holds the string denoting the create_time field in the database.
FieldCreateTime = "create_time"
// Table holds the table name of the history in the database.
Table = "histories"
)
@@ -37,13 +48,18 @@ const (
var Columns = []string{
FieldID,
FieldMediaID,
FieldEpisodeID,
FieldEpisodeNums,
FieldSeasonNum,
FieldSourceTitle,
FieldDate,
FieldTargetDir,
FieldSize,
FieldDownloadClientID,
FieldIndexerID,
FieldLink,
FieldHash,
FieldStatus,
FieldSaved,
FieldCreateTime,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -59,6 +75,8 @@ func ValidColumn(column string) bool {
var (
// DefaultSize holds the default value on creation for the "size" field.
DefaultSize int
// DefaultCreateTime holds the default value on creation for the "create_time" field.
DefaultCreateTime func() time.Time
)
// Status defines the type for the "status" enum field.
@@ -70,6 +88,8 @@ const (
StatusSuccess Status = "success"
StatusFail Status = "fail"
StatusUploading Status = "uploading"
StatusSeeding Status = "seeding"
StatusRemoved Status = "removed"
)
func (s Status) String() string {
@@ -79,7 +99,7 @@ func (s Status) String() string {
// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
func StatusValidator(s Status) error {
switch s {
case StatusRunning, StatusSuccess, StatusFail, StatusUploading:
case StatusRunning, StatusSuccess, StatusFail, StatusUploading, StatusSeeding, StatusRemoved:
return nil
default:
return fmt.Errorf("history: invalid enum value for status field: %q", s)
@@ -99,9 +119,9 @@ func ByMediaID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMediaID, opts...).ToFunc()
}
// ByEpisodeID orders the results by the episode_id field.
func ByEpisodeID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEpisodeID, opts...).ToFunc()
// BySeasonNum orders the results by the season_num field.
func BySeasonNum(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSeasonNum, opts...).ToFunc()
}
// BySourceTitle orders the results by the source_title field.
@@ -124,12 +144,32 @@ func BySize(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSize, opts...).ToFunc()
}
// ByDownloadClientID orders the results by the download_client_id field.
func ByDownloadClientID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDownloadClientID, opts...).ToFunc()
}
// ByIndexerID orders the results by the indexer_id field.
func ByIndexerID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIndexerID, opts...).ToFunc()
}
// ByLink orders the results by the link field.
func ByLink(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLink, opts...).ToFunc()
}
// ByHash orders the results by the hash field.
func ByHash(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHash, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// BySaved orders the results by the saved field.
func BySaved(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSaved, opts...).ToFunc()
// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}

View File

@@ -59,9 +59,9 @@ func MediaID(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldMediaID, v))
}
// EpisodeID applies equality check predicate on the "episode_id" field. It's identical to EpisodeIDEQ.
func EpisodeID(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldEpisodeID, v))
// SeasonNum applies equality check predicate on the "season_num" field. It's identical to SeasonNumEQ.
func SeasonNum(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldSeasonNum, v))
}
// SourceTitle applies equality check predicate on the "source_title" field. It's identical to SourceTitleEQ.
@@ -84,9 +84,29 @@ func Size(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldSize, v))
}
// Saved applies equality check predicate on the "saved" field. It's identical to SavedEQ.
func Saved(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldSaved, v))
// DownloadClientID applies equality check predicate on the "download_client_id" field. It's identical to DownloadClientIDEQ.
func DownloadClientID(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldDownloadClientID, v))
}
// IndexerID applies equality check predicate on the "indexer_id" field. It's identical to IndexerIDEQ.
func IndexerID(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldIndexerID, v))
}
// Link applies equality check predicate on the "link" field. It's identical to LinkEQ.
func Link(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldLink, v))
}
// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ.
func Hash(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldHash, v))
}
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
func CreateTime(v time.Time) predicate.History {
return predicate.History(sql.FieldEQ(FieldCreateTime, v))
}
// MediaIDEQ applies the EQ predicate on the "media_id" field.
@@ -129,54 +149,64 @@ func MediaIDLTE(v int) predicate.History {
return predicate.History(sql.FieldLTE(FieldMediaID, v))
}
// EpisodeIDEQ applies the EQ predicate on the "episode_id" field.
func EpisodeIDEQ(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldEpisodeID, v))
// EpisodeNumsIsNil applies the IsNil predicate on the "episode_nums" field.
func EpisodeNumsIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldEpisodeNums))
}
// EpisodeIDNEQ applies the NEQ predicate on the "episode_id" field.
func EpisodeIDNEQ(v int) predicate.History {
return predicate.History(sql.FieldNEQ(FieldEpisodeID, v))
// EpisodeNumsNotNil applies the NotNil predicate on the "episode_nums" field.
func EpisodeNumsNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldEpisodeNums))
}
// EpisodeIDIn applies the In predicate on the "episode_id" field.
func EpisodeIDIn(vs ...int) predicate.History {
return predicate.History(sql.FieldIn(FieldEpisodeID, vs...))
// SeasonNumEQ applies the EQ predicate on the "season_num" field.
func SeasonNumEQ(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldSeasonNum, v))
}
// EpisodeIDNotIn applies the NotIn predicate on the "episode_id" field.
func EpisodeIDNotIn(vs ...int) predicate.History {
return predicate.History(sql.FieldNotIn(FieldEpisodeID, vs...))
// SeasonNumNEQ applies the NEQ predicate on the "season_num" field.
func SeasonNumNEQ(v int) predicate.History {
return predicate.History(sql.FieldNEQ(FieldSeasonNum, v))
}
// EpisodeIDGT applies the GT predicate on the "episode_id" field.
func EpisodeIDGT(v int) predicate.History {
return predicate.History(sql.FieldGT(FieldEpisodeID, v))
// SeasonNumIn applies the In predicate on the "season_num" field.
func SeasonNumIn(vs ...int) predicate.History {
return predicate.History(sql.FieldIn(FieldSeasonNum, vs...))
}
// EpisodeIDGTE applies the GTE predicate on the "episode_id" field.
func EpisodeIDGTE(v int) predicate.History {
return predicate.History(sql.FieldGTE(FieldEpisodeID, v))
// SeasonNumNotIn applies the NotIn predicate on the "season_num" field.
func SeasonNumNotIn(vs ...int) predicate.History {
return predicate.History(sql.FieldNotIn(FieldSeasonNum, vs...))
}
// EpisodeIDLT applies the LT predicate on the "episode_id" field.
func EpisodeIDLT(v int) predicate.History {
return predicate.History(sql.FieldLT(FieldEpisodeID, v))
// SeasonNumGT applies the GT predicate on the "season_num" field.
func SeasonNumGT(v int) predicate.History {
return predicate.History(sql.FieldGT(FieldSeasonNum, v))
}
// EpisodeIDLTE applies the LTE predicate on the "episode_id" field.
func EpisodeIDLTE(v int) predicate.History {
return predicate.History(sql.FieldLTE(FieldEpisodeID, v))
// SeasonNumGTE applies the GTE predicate on the "season_num" field.
func SeasonNumGTE(v int) predicate.History {
return predicate.History(sql.FieldGTE(FieldSeasonNum, v))
}
// EpisodeIDIsNil applies the IsNil predicate on the "episode_id" field.
func EpisodeIDIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldEpisodeID))
// SeasonNumLT applies the LT predicate on the "season_num" field.
func SeasonNumLT(v int) predicate.History {
return predicate.History(sql.FieldLT(FieldSeasonNum, v))
}
// EpisodeIDNotNil applies the NotNil predicate on the "episode_id" field.
func EpisodeIDNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldEpisodeID))
// 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.
@@ -389,6 +419,256 @@ func SizeLTE(v int) predicate.History {
return predicate.History(sql.FieldLTE(FieldSize, v))
}
// DownloadClientIDEQ applies the EQ predicate on the "download_client_id" field.
func DownloadClientIDEQ(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldDownloadClientID, v))
}
// DownloadClientIDNEQ applies the NEQ predicate on the "download_client_id" field.
func DownloadClientIDNEQ(v int) predicate.History {
return predicate.History(sql.FieldNEQ(FieldDownloadClientID, v))
}
// DownloadClientIDIn applies the In predicate on the "download_client_id" field.
func DownloadClientIDIn(vs ...int) predicate.History {
return predicate.History(sql.FieldIn(FieldDownloadClientID, vs...))
}
// DownloadClientIDNotIn applies the NotIn predicate on the "download_client_id" field.
func DownloadClientIDNotIn(vs ...int) predicate.History {
return predicate.History(sql.FieldNotIn(FieldDownloadClientID, vs...))
}
// DownloadClientIDGT applies the GT predicate on the "download_client_id" field.
func DownloadClientIDGT(v int) predicate.History {
return predicate.History(sql.FieldGT(FieldDownloadClientID, v))
}
// DownloadClientIDGTE applies the GTE predicate on the "download_client_id" field.
func DownloadClientIDGTE(v int) predicate.History {
return predicate.History(sql.FieldGTE(FieldDownloadClientID, v))
}
// DownloadClientIDLT applies the LT predicate on the "download_client_id" field.
func DownloadClientIDLT(v int) predicate.History {
return predicate.History(sql.FieldLT(FieldDownloadClientID, v))
}
// DownloadClientIDLTE applies the LTE predicate on the "download_client_id" field.
func DownloadClientIDLTE(v int) predicate.History {
return predicate.History(sql.FieldLTE(FieldDownloadClientID, v))
}
// DownloadClientIDIsNil applies the IsNil predicate on the "download_client_id" field.
func DownloadClientIDIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldDownloadClientID))
}
// DownloadClientIDNotNil applies the NotNil predicate on the "download_client_id" field.
func DownloadClientIDNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldDownloadClientID))
}
// IndexerIDEQ applies the EQ predicate on the "indexer_id" field.
func IndexerIDEQ(v int) predicate.History {
return predicate.History(sql.FieldEQ(FieldIndexerID, v))
}
// IndexerIDNEQ applies the NEQ predicate on the "indexer_id" field.
func IndexerIDNEQ(v int) predicate.History {
return predicate.History(sql.FieldNEQ(FieldIndexerID, v))
}
// IndexerIDIn applies the In predicate on the "indexer_id" field.
func IndexerIDIn(vs ...int) predicate.History {
return predicate.History(sql.FieldIn(FieldIndexerID, vs...))
}
// IndexerIDNotIn applies the NotIn predicate on the "indexer_id" field.
func IndexerIDNotIn(vs ...int) predicate.History {
return predicate.History(sql.FieldNotIn(FieldIndexerID, vs...))
}
// IndexerIDGT applies the GT predicate on the "indexer_id" field.
func IndexerIDGT(v int) predicate.History {
return predicate.History(sql.FieldGT(FieldIndexerID, v))
}
// IndexerIDGTE applies the GTE predicate on the "indexer_id" field.
func IndexerIDGTE(v int) predicate.History {
return predicate.History(sql.FieldGTE(FieldIndexerID, v))
}
// IndexerIDLT applies the LT predicate on the "indexer_id" field.
func IndexerIDLT(v int) predicate.History {
return predicate.History(sql.FieldLT(FieldIndexerID, v))
}
// IndexerIDLTE applies the LTE predicate on the "indexer_id" field.
func IndexerIDLTE(v int) predicate.History {
return predicate.History(sql.FieldLTE(FieldIndexerID, v))
}
// IndexerIDIsNil applies the IsNil predicate on the "indexer_id" field.
func IndexerIDIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldIndexerID))
}
// IndexerIDNotNil applies the NotNil predicate on the "indexer_id" field.
func IndexerIDNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldIndexerID))
}
// LinkEQ applies the EQ predicate on the "link" field.
func LinkEQ(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldLink, v))
}
// LinkNEQ applies the NEQ predicate on the "link" field.
func LinkNEQ(v string) predicate.History {
return predicate.History(sql.FieldNEQ(FieldLink, v))
}
// LinkIn applies the In predicate on the "link" field.
func LinkIn(vs ...string) predicate.History {
return predicate.History(sql.FieldIn(FieldLink, vs...))
}
// LinkNotIn applies the NotIn predicate on the "link" field.
func LinkNotIn(vs ...string) predicate.History {
return predicate.History(sql.FieldNotIn(FieldLink, vs...))
}
// LinkGT applies the GT predicate on the "link" field.
func LinkGT(v string) predicate.History {
return predicate.History(sql.FieldGT(FieldLink, v))
}
// LinkGTE applies the GTE predicate on the "link" field.
func LinkGTE(v string) predicate.History {
return predicate.History(sql.FieldGTE(FieldLink, v))
}
// LinkLT applies the LT predicate on the "link" field.
func LinkLT(v string) predicate.History {
return predicate.History(sql.FieldLT(FieldLink, v))
}
// LinkLTE applies the LTE predicate on the "link" field.
func LinkLTE(v string) predicate.History {
return predicate.History(sql.FieldLTE(FieldLink, v))
}
// LinkContains applies the Contains predicate on the "link" field.
func LinkContains(v string) predicate.History {
return predicate.History(sql.FieldContains(FieldLink, v))
}
// LinkHasPrefix applies the HasPrefix predicate on the "link" field.
func LinkHasPrefix(v string) predicate.History {
return predicate.History(sql.FieldHasPrefix(FieldLink, v))
}
// LinkHasSuffix applies the HasSuffix predicate on the "link" field.
func LinkHasSuffix(v string) predicate.History {
return predicate.History(sql.FieldHasSuffix(FieldLink, v))
}
// LinkIsNil applies the IsNil predicate on the "link" field.
func LinkIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldLink))
}
// LinkNotNil applies the NotNil predicate on the "link" field.
func LinkNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldLink))
}
// LinkEqualFold applies the EqualFold predicate on the "link" field.
func LinkEqualFold(v string) predicate.History {
return predicate.History(sql.FieldEqualFold(FieldLink, v))
}
// LinkContainsFold applies the ContainsFold predicate on the "link" field.
func LinkContainsFold(v string) predicate.History {
return predicate.History(sql.FieldContainsFold(FieldLink, v))
}
// HashEQ applies the EQ predicate on the "hash" field.
func HashEQ(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldHash, v))
}
// HashNEQ applies the NEQ predicate on the "hash" field.
func HashNEQ(v string) predicate.History {
return predicate.History(sql.FieldNEQ(FieldHash, v))
}
// HashIn applies the In predicate on the "hash" field.
func HashIn(vs ...string) predicate.History {
return predicate.History(sql.FieldIn(FieldHash, vs...))
}
// HashNotIn applies the NotIn predicate on the "hash" field.
func HashNotIn(vs ...string) predicate.History {
return predicate.History(sql.FieldNotIn(FieldHash, vs...))
}
// HashGT applies the GT predicate on the "hash" field.
func HashGT(v string) predicate.History {
return predicate.History(sql.FieldGT(FieldHash, v))
}
// HashGTE applies the GTE predicate on the "hash" field.
func HashGTE(v string) predicate.History {
return predicate.History(sql.FieldGTE(FieldHash, v))
}
// HashLT applies the LT predicate on the "hash" field.
func HashLT(v string) predicate.History {
return predicate.History(sql.FieldLT(FieldHash, v))
}
// HashLTE applies the LTE predicate on the "hash" field.
func HashLTE(v string) predicate.History {
return predicate.History(sql.FieldLTE(FieldHash, v))
}
// HashContains applies the Contains predicate on the "hash" field.
func HashContains(v string) predicate.History {
return predicate.History(sql.FieldContains(FieldHash, v))
}
// HashHasPrefix applies the HasPrefix predicate on the "hash" field.
func HashHasPrefix(v string) predicate.History {
return predicate.History(sql.FieldHasPrefix(FieldHash, v))
}
// HashHasSuffix applies the HasSuffix predicate on the "hash" field.
func HashHasSuffix(v string) predicate.History {
return predicate.History(sql.FieldHasSuffix(FieldHash, v))
}
// HashIsNil applies the IsNil predicate on the "hash" field.
func HashIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldHash))
}
// HashNotNil applies the NotNil predicate on the "hash" field.
func HashNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldHash))
}
// HashEqualFold applies the EqualFold predicate on the "hash" field.
func HashEqualFold(v string) predicate.History {
return predicate.History(sql.FieldEqualFold(FieldHash, v))
}
// HashContainsFold applies the ContainsFold predicate on the "hash" field.
func HashContainsFold(v string) predicate.History {
return predicate.History(sql.FieldContainsFold(FieldHash, v))
}
// StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v Status) predicate.History {
return predicate.History(sql.FieldEQ(FieldStatus, v))
@@ -409,79 +689,54 @@ func StatusNotIn(vs ...Status) predicate.History {
return predicate.History(sql.FieldNotIn(FieldStatus, vs...))
}
// SavedEQ applies the EQ predicate on the "saved" field.
func SavedEQ(v string) predicate.History {
return predicate.History(sql.FieldEQ(FieldSaved, v))
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
func CreateTimeEQ(v time.Time) predicate.History {
return predicate.History(sql.FieldEQ(FieldCreateTime, v))
}
// SavedNEQ applies the NEQ predicate on the "saved" field.
func SavedNEQ(v string) predicate.History {
return predicate.History(sql.FieldNEQ(FieldSaved, v))
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
func CreateTimeNEQ(v time.Time) predicate.History {
return predicate.History(sql.FieldNEQ(FieldCreateTime, v))
}
// SavedIn applies the In predicate on the "saved" field.
func SavedIn(vs ...string) predicate.History {
return predicate.History(sql.FieldIn(FieldSaved, vs...))
// CreateTimeIn applies the In predicate on the "create_time" field.
func CreateTimeIn(vs ...time.Time) predicate.History {
return predicate.History(sql.FieldIn(FieldCreateTime, vs...))
}
// SavedNotIn applies the NotIn predicate on the "saved" field.
func SavedNotIn(vs ...string) predicate.History {
return predicate.History(sql.FieldNotIn(FieldSaved, vs...))
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
func CreateTimeNotIn(vs ...time.Time) predicate.History {
return predicate.History(sql.FieldNotIn(FieldCreateTime, vs...))
}
// SavedGT applies the GT predicate on the "saved" field.
func SavedGT(v string) predicate.History {
return predicate.History(sql.FieldGT(FieldSaved, v))
// CreateTimeGT applies the GT predicate on the "create_time" field.
func CreateTimeGT(v time.Time) predicate.History {
return predicate.History(sql.FieldGT(FieldCreateTime, v))
}
// SavedGTE applies the GTE predicate on the "saved" field.
func SavedGTE(v string) predicate.History {
return predicate.History(sql.FieldGTE(FieldSaved, v))
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
func CreateTimeGTE(v time.Time) predicate.History {
return predicate.History(sql.FieldGTE(FieldCreateTime, v))
}
// SavedLT applies the LT predicate on the "saved" field.
func SavedLT(v string) predicate.History {
return predicate.History(sql.FieldLT(FieldSaved, v))
// CreateTimeLT applies the LT predicate on the "create_time" field.
func CreateTimeLT(v time.Time) predicate.History {
return predicate.History(sql.FieldLT(FieldCreateTime, v))
}
// SavedLTE applies the LTE predicate on the "saved" field.
func SavedLTE(v string) predicate.History {
return predicate.History(sql.FieldLTE(FieldSaved, v))
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
func CreateTimeLTE(v time.Time) predicate.History {
return predicate.History(sql.FieldLTE(FieldCreateTime, v))
}
// SavedContains applies the Contains predicate on the "saved" field.
func SavedContains(v string) predicate.History {
return predicate.History(sql.FieldContains(FieldSaved, v))
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
func CreateTimeIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldCreateTime))
}
// SavedHasPrefix applies the HasPrefix predicate on the "saved" field.
func SavedHasPrefix(v string) predicate.History {
return predicate.History(sql.FieldHasPrefix(FieldSaved, v))
}
// SavedHasSuffix applies the HasSuffix predicate on the "saved" field.
func SavedHasSuffix(v string) predicate.History {
return predicate.History(sql.FieldHasSuffix(FieldSaved, v))
}
// SavedIsNil applies the IsNil predicate on the "saved" field.
func SavedIsNil() predicate.History {
return predicate.History(sql.FieldIsNull(FieldSaved))
}
// SavedNotNil applies the NotNil predicate on the "saved" field.
func SavedNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldSaved))
}
// SavedEqualFold applies the EqualFold predicate on the "saved" field.
func SavedEqualFold(v string) predicate.History {
return predicate.History(sql.FieldEqualFold(FieldSaved, v))
}
// SavedContainsFold applies the ContainsFold predicate on the "saved" field.
func SavedContainsFold(v string) predicate.History {
return predicate.History(sql.FieldContainsFold(FieldSaved, v))
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
func CreateTimeNotNil() predicate.History {
return predicate.History(sql.FieldNotNull(FieldCreateTime))
}
// And groups predicates with the AND operator between them.

View File

@@ -26,16 +26,22 @@ func (hc *HistoryCreate) SetMediaID(i int) *HistoryCreate {
return hc
}
// SetEpisodeID sets the "episode_id" field.
func (hc *HistoryCreate) SetEpisodeID(i int) *HistoryCreate {
hc.mutation.SetEpisodeID(i)
// SetEpisodeNums sets the "episode_nums" field.
func (hc *HistoryCreate) SetEpisodeNums(i []int) *HistoryCreate {
hc.mutation.SetEpisodeNums(i)
return hc
}
// SetNillableEpisodeID sets the "episode_id" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableEpisodeID(i *int) *HistoryCreate {
// 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.SetEpisodeID(*i)
hc.SetSeasonNum(*i)
}
return hc
}
@@ -72,22 +78,78 @@ func (hc *HistoryCreate) SetNillableSize(i *int) *HistoryCreate {
return hc
}
// SetDownloadClientID sets the "download_client_id" field.
func (hc *HistoryCreate) SetDownloadClientID(i int) *HistoryCreate {
hc.mutation.SetDownloadClientID(i)
return hc
}
// SetNillableDownloadClientID sets the "download_client_id" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableDownloadClientID(i *int) *HistoryCreate {
if i != nil {
hc.SetDownloadClientID(*i)
}
return hc
}
// SetIndexerID sets the "indexer_id" field.
func (hc *HistoryCreate) SetIndexerID(i int) *HistoryCreate {
hc.mutation.SetIndexerID(i)
return hc
}
// SetNillableIndexerID sets the "indexer_id" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableIndexerID(i *int) *HistoryCreate {
if i != nil {
hc.SetIndexerID(*i)
}
return hc
}
// SetLink sets the "link" field.
func (hc *HistoryCreate) SetLink(s string) *HistoryCreate {
hc.mutation.SetLink(s)
return hc
}
// SetNillableLink sets the "link" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableLink(s *string) *HistoryCreate {
if s != nil {
hc.SetLink(*s)
}
return hc
}
// SetHash sets the "hash" field.
func (hc *HistoryCreate) SetHash(s string) *HistoryCreate {
hc.mutation.SetHash(s)
return hc
}
// SetNillableHash sets the "hash" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableHash(s *string) *HistoryCreate {
if s != nil {
hc.SetHash(*s)
}
return hc
}
// SetStatus sets the "status" field.
func (hc *HistoryCreate) SetStatus(h history.Status) *HistoryCreate {
hc.mutation.SetStatus(h)
return hc
}
// SetSaved sets the "saved" field.
func (hc *HistoryCreate) SetSaved(s string) *HistoryCreate {
hc.mutation.SetSaved(s)
// SetCreateTime sets the "create_time" field.
func (hc *HistoryCreate) SetCreateTime(t time.Time) *HistoryCreate {
hc.mutation.SetCreateTime(t)
return hc
}
// SetNillableSaved sets the "saved" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableSaved(s *string) *HistoryCreate {
if s != nil {
hc.SetSaved(*s)
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
func (hc *HistoryCreate) SetNillableCreateTime(t *time.Time) *HistoryCreate {
if t != nil {
hc.SetCreateTime(*t)
}
return hc
}
@@ -131,6 +193,10 @@ func (hc *HistoryCreate) defaults() {
v := history.DefaultSize
hc.mutation.SetSize(v)
}
if _, ok := hc.mutation.CreateTime(); !ok {
v := history.DefaultCreateTime()
hc.mutation.SetCreateTime(v)
}
}
// check runs all checks and user-defined validators on the builder.
@@ -188,9 +254,13 @@ func (hc *HistoryCreate) createSpec() (*History, *sqlgraph.CreateSpec) {
_spec.SetField(history.FieldMediaID, field.TypeInt, value)
_node.MediaID = value
}
if value, ok := hc.mutation.EpisodeID(); ok {
_spec.SetField(history.FieldEpisodeID, field.TypeInt, value)
_node.EpisodeID = value
if value, ok := hc.mutation.EpisodeNums(); ok {
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
_node.EpisodeNums = value
}
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)
@@ -208,13 +278,29 @@ func (hc *HistoryCreate) createSpec() (*History, *sqlgraph.CreateSpec) {
_spec.SetField(history.FieldSize, field.TypeInt, value)
_node.Size = value
}
if value, ok := hc.mutation.DownloadClientID(); ok {
_spec.SetField(history.FieldDownloadClientID, field.TypeInt, value)
_node.DownloadClientID = value
}
if value, ok := hc.mutation.IndexerID(); ok {
_spec.SetField(history.FieldIndexerID, field.TypeInt, value)
_node.IndexerID = value
}
if value, ok := hc.mutation.Link(); ok {
_spec.SetField(history.FieldLink, field.TypeString, value)
_node.Link = value
}
if value, ok := hc.mutation.Hash(); ok {
_spec.SetField(history.FieldHash, field.TypeString, value)
_node.Hash = value
}
if value, ok := hc.mutation.Status(); ok {
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
_node.Status = value
}
if value, ok := hc.mutation.Saved(); ok {
_spec.SetField(history.FieldSaved, field.TypeString, value)
_node.Saved = value
if value, ok := hc.mutation.CreateTime(); ok {
_spec.SetField(history.FieldCreateTime, field.TypeTime, value)
_node.CreateTime = value
}
return _node, _spec
}

View File

@@ -9,6 +9,7 @@ import (
"polaris/ent/history"
"polaris/ent/predicate"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -60,7 +61,7 @@ func (hq *HistoryQuery) Order(o ...history.OrderOption) *HistoryQuery {
// First returns the first History entity from the query.
// Returns a *NotFoundError when no History was found.
func (hq *HistoryQuery) First(ctx context.Context) (*History, error) {
nodes, err := hq.Limit(1).All(setContextOp(ctx, hq.ctx, "First"))
nodes, err := hq.Limit(1).All(setContextOp(ctx, hq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -83,7 +84,7 @@ func (hq *HistoryQuery) FirstX(ctx context.Context) *History {
// Returns a *NotFoundError when no History ID was found.
func (hq *HistoryQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = hq.Limit(1).IDs(setContextOp(ctx, hq.ctx, "FirstID")); err != nil {
if ids, err = hq.Limit(1).IDs(setContextOp(ctx, hq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -106,7 +107,7 @@ func (hq *HistoryQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one History entity is found.
// Returns a *NotFoundError when no History entities are found.
func (hq *HistoryQuery) Only(ctx context.Context) (*History, error) {
nodes, err := hq.Limit(2).All(setContextOp(ctx, hq.ctx, "Only"))
nodes, err := hq.Limit(2).All(setContextOp(ctx, hq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -134,7 +135,7 @@ func (hq *HistoryQuery) OnlyX(ctx context.Context) *History {
// Returns a *NotFoundError when no entities are found.
func (hq *HistoryQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = hq.Limit(2).IDs(setContextOp(ctx, hq.ctx, "OnlyID")); err != nil {
if ids, err = hq.Limit(2).IDs(setContextOp(ctx, hq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -159,7 +160,7 @@ func (hq *HistoryQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Histories.
func (hq *HistoryQuery) All(ctx context.Context) ([]*History, error) {
ctx = setContextOp(ctx, hq.ctx, "All")
ctx = setContextOp(ctx, hq.ctx, ent.OpQueryAll)
if err := hq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -181,7 +182,7 @@ func (hq *HistoryQuery) IDs(ctx context.Context) (ids []int, err error) {
if hq.ctx.Unique == nil && hq.path != nil {
hq.Unique(true)
}
ctx = setContextOp(ctx, hq.ctx, "IDs")
ctx = setContextOp(ctx, hq.ctx, ent.OpQueryIDs)
if err = hq.Select(history.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -199,7 +200,7 @@ func (hq *HistoryQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (hq *HistoryQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, hq.ctx, "Count")
ctx = setContextOp(ctx, hq.ctx, ent.OpQueryCount)
if err := hq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -217,7 +218,7 @@ func (hq *HistoryQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (hq *HistoryQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, hq.ctx, "Exist")
ctx = setContextOp(ctx, hq.ctx, ent.OpQueryExist)
switch _, err := hq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -449,7 +450,7 @@ func (hgb *HistoryGroupBy) Aggregate(fns ...AggregateFunc) *HistoryGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (hgb *HistoryGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, hgb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, hgb.build.ctx, ent.OpQueryGroupBy)
if err := hgb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -497,7 +498,7 @@ func (hs *HistorySelect) Aggregate(fns ...AggregateFunc) *HistorySelect {
// Scan applies the selector query and scans the result into the given value.
func (hs *HistorySelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, hs.ctx, "Select")
ctx = setContextOp(ctx, hs.ctx, ent.OpQuerySelect)
if err := hs.prepareQuery(ctx); err != nil {
return err
}

View File

@@ -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"
)
@@ -49,30 +50,48 @@ func (hu *HistoryUpdate) AddMediaID(i int) *HistoryUpdate {
return hu
}
// SetEpisodeID sets the "episode_id" field.
func (hu *HistoryUpdate) SetEpisodeID(i int) *HistoryUpdate {
hu.mutation.ResetEpisodeID()
hu.mutation.SetEpisodeID(i)
// SetEpisodeNums sets the "episode_nums" field.
func (hu *HistoryUpdate) SetEpisodeNums(i []int) *HistoryUpdate {
hu.mutation.SetEpisodeNums(i)
return hu
}
// SetNillableEpisodeID sets the "episode_id" field if the given value is not nil.
func (hu *HistoryUpdate) SetNillableEpisodeID(i *int) *HistoryUpdate {
// 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.SetEpisodeID(*i)
hu.SetSeasonNum(*i)
}
return hu
}
// AddEpisodeID adds i to the "episode_id" field.
func (hu *HistoryUpdate) AddEpisodeID(i int) *HistoryUpdate {
hu.mutation.AddEpisodeID(i)
// AddSeasonNum adds i to the "season_num" field.
func (hu *HistoryUpdate) AddSeasonNum(i int) *HistoryUpdate {
hu.mutation.AddSeasonNum(i)
return hu
}
// ClearEpisodeID clears the value of the "episode_id" field.
func (hu *HistoryUpdate) ClearEpisodeID() *HistoryUpdate {
hu.mutation.ClearEpisodeID()
// ClearSeasonNum clears the value of the "season_num" field.
func (hu *HistoryUpdate) ClearSeasonNum() *HistoryUpdate {
hu.mutation.ClearSeasonNum()
return hu
}
@@ -139,6 +158,100 @@ func (hu *HistoryUpdate) AddSize(i int) *HistoryUpdate {
return hu
}
// SetDownloadClientID sets the "download_client_id" field.
func (hu *HistoryUpdate) SetDownloadClientID(i int) *HistoryUpdate {
hu.mutation.ResetDownloadClientID()
hu.mutation.SetDownloadClientID(i)
return hu
}
// SetNillableDownloadClientID sets the "download_client_id" field if the given value is not nil.
func (hu *HistoryUpdate) SetNillableDownloadClientID(i *int) *HistoryUpdate {
if i != nil {
hu.SetDownloadClientID(*i)
}
return hu
}
// AddDownloadClientID adds i to the "download_client_id" field.
func (hu *HistoryUpdate) AddDownloadClientID(i int) *HistoryUpdate {
hu.mutation.AddDownloadClientID(i)
return hu
}
// ClearDownloadClientID clears the value of the "download_client_id" field.
func (hu *HistoryUpdate) ClearDownloadClientID() *HistoryUpdate {
hu.mutation.ClearDownloadClientID()
return hu
}
// SetIndexerID sets the "indexer_id" field.
func (hu *HistoryUpdate) SetIndexerID(i int) *HistoryUpdate {
hu.mutation.ResetIndexerID()
hu.mutation.SetIndexerID(i)
return hu
}
// SetNillableIndexerID sets the "indexer_id" field if the given value is not nil.
func (hu *HistoryUpdate) SetNillableIndexerID(i *int) *HistoryUpdate {
if i != nil {
hu.SetIndexerID(*i)
}
return hu
}
// AddIndexerID adds i to the "indexer_id" field.
func (hu *HistoryUpdate) AddIndexerID(i int) *HistoryUpdate {
hu.mutation.AddIndexerID(i)
return hu
}
// ClearIndexerID clears the value of the "indexer_id" field.
func (hu *HistoryUpdate) ClearIndexerID() *HistoryUpdate {
hu.mutation.ClearIndexerID()
return hu
}
// SetLink sets the "link" field.
func (hu *HistoryUpdate) SetLink(s string) *HistoryUpdate {
hu.mutation.SetLink(s)
return hu
}
// SetNillableLink sets the "link" field if the given value is not nil.
func (hu *HistoryUpdate) SetNillableLink(s *string) *HistoryUpdate {
if s != nil {
hu.SetLink(*s)
}
return hu
}
// ClearLink clears the value of the "link" field.
func (hu *HistoryUpdate) ClearLink() *HistoryUpdate {
hu.mutation.ClearLink()
return hu
}
// SetHash sets the "hash" field.
func (hu *HistoryUpdate) SetHash(s string) *HistoryUpdate {
hu.mutation.SetHash(s)
return hu
}
// SetNillableHash sets the "hash" field if the given value is not nil.
func (hu *HistoryUpdate) SetNillableHash(s *string) *HistoryUpdate {
if s != nil {
hu.SetHash(*s)
}
return hu
}
// ClearHash clears the value of the "hash" field.
func (hu *HistoryUpdate) ClearHash() *HistoryUpdate {
hu.mutation.ClearHash()
return hu
}
// SetStatus sets the "status" field.
func (hu *HistoryUpdate) SetStatus(h history.Status) *HistoryUpdate {
hu.mutation.SetStatus(h)
@@ -153,26 +266,6 @@ func (hu *HistoryUpdate) SetNillableStatus(h *history.Status) *HistoryUpdate {
return hu
}
// SetSaved sets the "saved" field.
func (hu *HistoryUpdate) SetSaved(s string) *HistoryUpdate {
hu.mutation.SetSaved(s)
return hu
}
// SetNillableSaved sets the "saved" field if the given value is not nil.
func (hu *HistoryUpdate) SetNillableSaved(s *string) *HistoryUpdate {
if s != nil {
hu.SetSaved(*s)
}
return hu
}
// ClearSaved clears the value of the "saved" field.
func (hu *HistoryUpdate) ClearSaved() *HistoryUpdate {
hu.mutation.ClearSaved()
return hu
}
// Mutation returns the HistoryMutation object of the builder.
func (hu *HistoryUpdate) Mutation() *HistoryMutation {
return hu.mutation
@@ -233,14 +326,25 @@ func (hu *HistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := hu.mutation.AddedMediaID(); ok {
_spec.AddField(history.FieldMediaID, field.TypeInt, value)
}
if value, ok := hu.mutation.EpisodeID(); ok {
_spec.SetField(history.FieldEpisodeID, field.TypeInt, value)
if value, ok := hu.mutation.EpisodeNums(); ok {
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
}
if value, ok := hu.mutation.AddedEpisodeID(); ok {
_spec.AddField(history.FieldEpisodeID, field.TypeInt, value)
if value, ok := hu.mutation.AppendedEpisodeNums(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, history.FieldEpisodeNums, value)
})
}
if hu.mutation.EpisodeIDCleared() {
_spec.ClearField(history.FieldEpisodeID, field.TypeInt)
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)
@@ -257,14 +361,41 @@ func (hu *HistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := hu.mutation.AddedSize(); ok {
_spec.AddField(history.FieldSize, field.TypeInt, value)
}
if value, ok := hu.mutation.DownloadClientID(); ok {
_spec.SetField(history.FieldDownloadClientID, field.TypeInt, value)
}
if value, ok := hu.mutation.AddedDownloadClientID(); ok {
_spec.AddField(history.FieldDownloadClientID, field.TypeInt, value)
}
if hu.mutation.DownloadClientIDCleared() {
_spec.ClearField(history.FieldDownloadClientID, field.TypeInt)
}
if value, ok := hu.mutation.IndexerID(); ok {
_spec.SetField(history.FieldIndexerID, field.TypeInt, value)
}
if value, ok := hu.mutation.AddedIndexerID(); ok {
_spec.AddField(history.FieldIndexerID, field.TypeInt, value)
}
if hu.mutation.IndexerIDCleared() {
_spec.ClearField(history.FieldIndexerID, field.TypeInt)
}
if value, ok := hu.mutation.Link(); ok {
_spec.SetField(history.FieldLink, field.TypeString, value)
}
if hu.mutation.LinkCleared() {
_spec.ClearField(history.FieldLink, field.TypeString)
}
if value, ok := hu.mutation.Hash(); ok {
_spec.SetField(history.FieldHash, field.TypeString, value)
}
if hu.mutation.HashCleared() {
_spec.ClearField(history.FieldHash, field.TypeString)
}
if value, ok := hu.mutation.Status(); ok {
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
}
if value, ok := hu.mutation.Saved(); ok {
_spec.SetField(history.FieldSaved, field.TypeString, value)
}
if hu.mutation.SavedCleared() {
_spec.ClearField(history.FieldSaved, field.TypeString)
if hu.mutation.CreateTimeCleared() {
_spec.ClearField(history.FieldCreateTime, field.TypeTime)
}
if n, err = sqlgraph.UpdateNodes(ctx, hu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
@@ -307,30 +438,48 @@ func (huo *HistoryUpdateOne) AddMediaID(i int) *HistoryUpdateOne {
return huo
}
// SetEpisodeID sets the "episode_id" field.
func (huo *HistoryUpdateOne) SetEpisodeID(i int) *HistoryUpdateOne {
huo.mutation.ResetEpisodeID()
huo.mutation.SetEpisodeID(i)
// SetEpisodeNums sets the "episode_nums" field.
func (huo *HistoryUpdateOne) SetEpisodeNums(i []int) *HistoryUpdateOne {
huo.mutation.SetEpisodeNums(i)
return huo
}
// SetNillableEpisodeID sets the "episode_id" field if the given value is not nil.
func (huo *HistoryUpdateOne) SetNillableEpisodeID(i *int) *HistoryUpdateOne {
// 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.SetEpisodeID(*i)
huo.SetSeasonNum(*i)
}
return huo
}
// AddEpisodeID adds i to the "episode_id" field.
func (huo *HistoryUpdateOne) AddEpisodeID(i int) *HistoryUpdateOne {
huo.mutation.AddEpisodeID(i)
// AddSeasonNum adds i to the "season_num" field.
func (huo *HistoryUpdateOne) AddSeasonNum(i int) *HistoryUpdateOne {
huo.mutation.AddSeasonNum(i)
return huo
}
// ClearEpisodeID clears the value of the "episode_id" field.
func (huo *HistoryUpdateOne) ClearEpisodeID() *HistoryUpdateOne {
huo.mutation.ClearEpisodeID()
// ClearSeasonNum clears the value of the "season_num" field.
func (huo *HistoryUpdateOne) ClearSeasonNum() *HistoryUpdateOne {
huo.mutation.ClearSeasonNum()
return huo
}
@@ -397,6 +546,100 @@ func (huo *HistoryUpdateOne) AddSize(i int) *HistoryUpdateOne {
return huo
}
// SetDownloadClientID sets the "download_client_id" field.
func (huo *HistoryUpdateOne) SetDownloadClientID(i int) *HistoryUpdateOne {
huo.mutation.ResetDownloadClientID()
huo.mutation.SetDownloadClientID(i)
return huo
}
// SetNillableDownloadClientID sets the "download_client_id" field if the given value is not nil.
func (huo *HistoryUpdateOne) SetNillableDownloadClientID(i *int) *HistoryUpdateOne {
if i != nil {
huo.SetDownloadClientID(*i)
}
return huo
}
// AddDownloadClientID adds i to the "download_client_id" field.
func (huo *HistoryUpdateOne) AddDownloadClientID(i int) *HistoryUpdateOne {
huo.mutation.AddDownloadClientID(i)
return huo
}
// ClearDownloadClientID clears the value of the "download_client_id" field.
func (huo *HistoryUpdateOne) ClearDownloadClientID() *HistoryUpdateOne {
huo.mutation.ClearDownloadClientID()
return huo
}
// SetIndexerID sets the "indexer_id" field.
func (huo *HistoryUpdateOne) SetIndexerID(i int) *HistoryUpdateOne {
huo.mutation.ResetIndexerID()
huo.mutation.SetIndexerID(i)
return huo
}
// SetNillableIndexerID sets the "indexer_id" field if the given value is not nil.
func (huo *HistoryUpdateOne) SetNillableIndexerID(i *int) *HistoryUpdateOne {
if i != nil {
huo.SetIndexerID(*i)
}
return huo
}
// AddIndexerID adds i to the "indexer_id" field.
func (huo *HistoryUpdateOne) AddIndexerID(i int) *HistoryUpdateOne {
huo.mutation.AddIndexerID(i)
return huo
}
// ClearIndexerID clears the value of the "indexer_id" field.
func (huo *HistoryUpdateOne) ClearIndexerID() *HistoryUpdateOne {
huo.mutation.ClearIndexerID()
return huo
}
// SetLink sets the "link" field.
func (huo *HistoryUpdateOne) SetLink(s string) *HistoryUpdateOne {
huo.mutation.SetLink(s)
return huo
}
// SetNillableLink sets the "link" field if the given value is not nil.
func (huo *HistoryUpdateOne) SetNillableLink(s *string) *HistoryUpdateOne {
if s != nil {
huo.SetLink(*s)
}
return huo
}
// ClearLink clears the value of the "link" field.
func (huo *HistoryUpdateOne) ClearLink() *HistoryUpdateOne {
huo.mutation.ClearLink()
return huo
}
// SetHash sets the "hash" field.
func (huo *HistoryUpdateOne) SetHash(s string) *HistoryUpdateOne {
huo.mutation.SetHash(s)
return huo
}
// SetNillableHash sets the "hash" field if the given value is not nil.
func (huo *HistoryUpdateOne) SetNillableHash(s *string) *HistoryUpdateOne {
if s != nil {
huo.SetHash(*s)
}
return huo
}
// ClearHash clears the value of the "hash" field.
func (huo *HistoryUpdateOne) ClearHash() *HistoryUpdateOne {
huo.mutation.ClearHash()
return huo
}
// SetStatus sets the "status" field.
func (huo *HistoryUpdateOne) SetStatus(h history.Status) *HistoryUpdateOne {
huo.mutation.SetStatus(h)
@@ -411,26 +654,6 @@ func (huo *HistoryUpdateOne) SetNillableStatus(h *history.Status) *HistoryUpdate
return huo
}
// SetSaved sets the "saved" field.
func (huo *HistoryUpdateOne) SetSaved(s string) *HistoryUpdateOne {
huo.mutation.SetSaved(s)
return huo
}
// SetNillableSaved sets the "saved" field if the given value is not nil.
func (huo *HistoryUpdateOne) SetNillableSaved(s *string) *HistoryUpdateOne {
if s != nil {
huo.SetSaved(*s)
}
return huo
}
// ClearSaved clears the value of the "saved" field.
func (huo *HistoryUpdateOne) ClearSaved() *HistoryUpdateOne {
huo.mutation.ClearSaved()
return huo
}
// Mutation returns the HistoryMutation object of the builder.
func (huo *HistoryUpdateOne) Mutation() *HistoryMutation {
return huo.mutation
@@ -521,14 +744,25 @@ func (huo *HistoryUpdateOne) sqlSave(ctx context.Context) (_node *History, err e
if value, ok := huo.mutation.AddedMediaID(); ok {
_spec.AddField(history.FieldMediaID, field.TypeInt, value)
}
if value, ok := huo.mutation.EpisodeID(); ok {
_spec.SetField(history.FieldEpisodeID, field.TypeInt, value)
if value, ok := huo.mutation.EpisodeNums(); ok {
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
}
if value, ok := huo.mutation.AddedEpisodeID(); ok {
_spec.AddField(history.FieldEpisodeID, field.TypeInt, value)
if value, ok := huo.mutation.AppendedEpisodeNums(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, history.FieldEpisodeNums, value)
})
}
if huo.mutation.EpisodeIDCleared() {
_spec.ClearField(history.FieldEpisodeID, field.TypeInt)
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)
@@ -545,14 +779,41 @@ func (huo *HistoryUpdateOne) sqlSave(ctx context.Context) (_node *History, err e
if value, ok := huo.mutation.AddedSize(); ok {
_spec.AddField(history.FieldSize, field.TypeInt, value)
}
if value, ok := huo.mutation.DownloadClientID(); ok {
_spec.SetField(history.FieldDownloadClientID, field.TypeInt, value)
}
if value, ok := huo.mutation.AddedDownloadClientID(); ok {
_spec.AddField(history.FieldDownloadClientID, field.TypeInt, value)
}
if huo.mutation.DownloadClientIDCleared() {
_spec.ClearField(history.FieldDownloadClientID, field.TypeInt)
}
if value, ok := huo.mutation.IndexerID(); ok {
_spec.SetField(history.FieldIndexerID, field.TypeInt, value)
}
if value, ok := huo.mutation.AddedIndexerID(); ok {
_spec.AddField(history.FieldIndexerID, field.TypeInt, value)
}
if huo.mutation.IndexerIDCleared() {
_spec.ClearField(history.FieldIndexerID, field.TypeInt)
}
if value, ok := huo.mutation.Link(); ok {
_spec.SetField(history.FieldLink, field.TypeString, value)
}
if huo.mutation.LinkCleared() {
_spec.ClearField(history.FieldLink, field.TypeString)
}
if value, ok := huo.mutation.Hash(); ok {
_spec.SetField(history.FieldHash, field.TypeString, value)
}
if huo.mutation.HashCleared() {
_spec.ClearField(history.FieldHash, field.TypeString)
}
if value, ok := huo.mutation.Status(); ok {
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
}
if value, ok := huo.mutation.Saved(); ok {
_spec.SetField(history.FieldSaved, field.TypeString, value)
}
if huo.mutation.SavedCleared() {
_spec.ClearField(history.FieldSaved, field.TypeString)
if huo.mutation.CreateTimeCleared() {
_spec.ClearField(history.FieldCreateTime, field.TypeTime)
}
_node = &History{config: huo.config}
_spec.Assign = _node.assignValues

View File

@@ -8,6 +8,18 @@ import (
"polaris/ent"
)
// The BlacklistFunc type is an adapter to allow the use of ordinary
// function as Blacklist mutator.
type BlacklistFunc func(context.Context, *ent.BlacklistMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f BlacklistFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.BlacklistMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BlacklistMutation", m)
}
// The DownloadClientsFunc type is an adapter to allow the use of ordinary
// function as DownloadClients mutator.
type DownloadClientsFunc func(context.Context, *ent.DownloadClientsMutation) (ent.Value, error)
@@ -44,6 +56,18 @@ func (f HistoryFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, err
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.HistoryMutation", m)
}
// The ImportListFunc type is an adapter to allow the use of ordinary
// function as ImportList mutator.
type ImportListFunc func(context.Context, *ent.ImportListMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ImportListFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ImportListMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ImportListMutation", m)
}
// The IndexersFunc type is an adapter to allow the use of ordinary
// function as Indexers mutator.
type IndexersFunc func(context.Context, *ent.IndexersMutation) (ent.Value, error)
@@ -68,6 +92,18 @@ func (f MediaFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MediaMutation", m)
}
// The NotificationClientFunc type is an adapter to allow the use of ordinary
// function as NotificationClient mutator.
type NotificationClientFunc func(context.Context, *ent.NotificationClientMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f NotificationClientFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.NotificationClientMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NotificationClientMutation", m)
}
// The SettingsFunc type is an adapter to allow the use of ordinary
// function as Settings mutator.
type SettingsFunc func(context.Context, *ent.SettingsMutation) (ent.Value, error)

164
ent/importlist.go Normal file
View File

@@ -0,0 +1,164 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"encoding/json"
"fmt"
"polaris/ent/importlist"
"polaris/ent/schema"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// ImportList is the model entity for the ImportList schema.
type ImportList struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Type holds the value of the "type" field.
Type importlist.Type `json:"type,omitempty"`
// URL holds the value of the "url" field.
URL string `json:"url,omitempty"`
// Qulity holds the value of the "qulity" field.
Qulity string `json:"qulity,omitempty"`
// StorageID holds the value of the "storage_id" field.
StorageID int `json:"storage_id,omitempty"`
// Settings holds the value of the "settings" field.
Settings schema.ImportListSettings `json:"settings,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ImportList) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case importlist.FieldSettings:
values[i] = new([]byte)
case importlist.FieldID, importlist.FieldStorageID:
values[i] = new(sql.NullInt64)
case importlist.FieldName, importlist.FieldType, importlist.FieldURL, importlist.FieldQulity:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ImportList fields.
func (il *ImportList) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case importlist.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
il.ID = int(value.Int64)
case importlist.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
il.Name = value.String
}
case importlist.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
il.Type = importlist.Type(value.String)
}
case importlist.FieldURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field url", values[i])
} else if value.Valid {
il.URL = value.String
}
case importlist.FieldQulity:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field qulity", values[i])
} else if value.Valid {
il.Qulity = value.String
}
case importlist.FieldStorageID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field storage_id", values[i])
} else if value.Valid {
il.StorageID = int(value.Int64)
}
case importlist.FieldSettings:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field settings", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &il.Settings); err != nil {
return fmt.Errorf("unmarshal field settings: %w", err)
}
}
default:
il.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ImportList.
// This includes values selected through modifiers, order, etc.
func (il *ImportList) Value(name string) (ent.Value, error) {
return il.selectValues.Get(name)
}
// Update returns a builder for updating this ImportList.
// Note that you need to call ImportList.Unwrap() before calling this method if this ImportList
// was returned from a transaction, and the transaction was committed or rolled back.
func (il *ImportList) Update() *ImportListUpdateOne {
return NewImportListClient(il.config).UpdateOne(il)
}
// Unwrap unwraps the ImportList entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (il *ImportList) Unwrap() *ImportList {
_tx, ok := il.config.driver.(*txDriver)
if !ok {
panic("ent: ImportList is not a transactional entity")
}
il.config.driver = _tx.drv
return il
}
// String implements the fmt.Stringer.
func (il *ImportList) String() string {
var builder strings.Builder
builder.WriteString("ImportList(")
builder.WriteString(fmt.Sprintf("id=%v, ", il.ID))
builder.WriteString("name=")
builder.WriteString(il.Name)
builder.WriteString(", ")
builder.WriteString("type=")
builder.WriteString(fmt.Sprintf("%v", il.Type))
builder.WriteString(", ")
builder.WriteString("url=")
builder.WriteString(il.URL)
builder.WriteString(", ")
builder.WriteString("qulity=")
builder.WriteString(il.Qulity)
builder.WriteString(", ")
builder.WriteString("storage_id=")
builder.WriteString(fmt.Sprintf("%v", il.StorageID))
builder.WriteString(", ")
builder.WriteString("settings=")
builder.WriteString(fmt.Sprintf("%v", il.Settings))
builder.WriteByte(')')
return builder.String()
}
// ImportLists is a parsable slice of ImportList.
type ImportLists []*ImportList

View File

@@ -0,0 +1,107 @@
// Code generated by ent, DO NOT EDIT.
package importlist
import (
"fmt"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the importlist type in the database.
Label = "import_list"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldURL holds the string denoting the url field in the database.
FieldURL = "url"
// FieldQulity holds the string denoting the qulity field in the database.
FieldQulity = "qulity"
// FieldStorageID holds the string denoting the storage_id field in the database.
FieldStorageID = "storage_id"
// FieldSettings holds the string denoting the settings field in the database.
FieldSettings = "settings"
// Table holds the table name of the importlist in the database.
Table = "import_lists"
)
// Columns holds all SQL columns for importlist fields.
var Columns = []string{
FieldID,
FieldName,
FieldType,
FieldURL,
FieldQulity,
FieldStorageID,
FieldSettings,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
// Type defines the type for the "type" enum field.
type Type string
// Type values.
const (
TypePlex Type = "plex"
TypeDoulist Type = "doulist"
)
func (_type Type) String() string {
return string(_type)
}
// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
func TypeValidator(_type Type) error {
switch _type {
case TypePlex, TypeDoulist:
return nil
default:
return fmt.Errorf("importlist: invalid enum value for type field: %q", _type)
}
}
// OrderOption defines the ordering options for the ImportList queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldType, opts...).ToFunc()
}
// ByURL orders the results by the url field.
func ByURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldURL, opts...).ToFunc()
}
// ByQulity orders the results by the qulity field.
func ByQulity(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldQulity, opts...).ToFunc()
}
// ByStorageID orders the results by the storage_id field.
func ByStorageID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStorageID, opts...).ToFunc()
}

364
ent/importlist/where.go Normal file
View File

@@ -0,0 +1,364 @@
// Code generated by ent, DO NOT EDIT.
package importlist
import (
"polaris/ent/predicate"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.ImportList {
return predicate.ImportList(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.ImportList {
return predicate.ImportList(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.ImportList {
return predicate.ImportList(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.ImportList {
return predicate.ImportList(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.ImportList {
return predicate.ImportList(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.ImportList {
return predicate.ImportList(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.ImportList {
return predicate.ImportList(sql.FieldLTE(FieldID, id))
}
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldName, v))
}
// URL applies equality check predicate on the "url" field. It's identical to URLEQ.
func URL(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldURL, v))
}
// Qulity applies equality check predicate on the "qulity" field. It's identical to QulityEQ.
func Qulity(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldQulity, v))
}
// StorageID applies equality check predicate on the "storage_id" field. It's identical to StorageIDEQ.
func StorageID(v int) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldStorageID, v))
}
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldName, v))
}
// NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldNEQ(FieldName, v))
}
// NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.ImportList {
return predicate.ImportList(sql.FieldIn(FieldName, vs...))
}
// NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.ImportList {
return predicate.ImportList(sql.FieldNotIn(FieldName, vs...))
}
// NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldGT(FieldName, v))
}
// NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldGTE(FieldName, v))
}
// NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldLT(FieldName, v))
}
// NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldLTE(FieldName, v))
}
// NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldContains(FieldName, v))
}
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldHasPrefix(FieldName, v))
}
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldHasSuffix(FieldName, v))
}
// NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldEqualFold(FieldName, v))
}
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldContainsFold(FieldName, v))
}
// TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v Type) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldType, v))
}
// TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v Type) predicate.ImportList {
return predicate.ImportList(sql.FieldNEQ(FieldType, v))
}
// TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...Type) predicate.ImportList {
return predicate.ImportList(sql.FieldIn(FieldType, vs...))
}
// TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...Type) predicate.ImportList {
return predicate.ImportList(sql.FieldNotIn(FieldType, vs...))
}
// URLEQ applies the EQ predicate on the "url" field.
func URLEQ(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldURL, v))
}
// URLNEQ applies the NEQ predicate on the "url" field.
func URLNEQ(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldNEQ(FieldURL, v))
}
// URLIn applies the In predicate on the "url" field.
func URLIn(vs ...string) predicate.ImportList {
return predicate.ImportList(sql.FieldIn(FieldURL, vs...))
}
// URLNotIn applies the NotIn predicate on the "url" field.
func URLNotIn(vs ...string) predicate.ImportList {
return predicate.ImportList(sql.FieldNotIn(FieldURL, vs...))
}
// URLGT applies the GT predicate on the "url" field.
func URLGT(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldGT(FieldURL, v))
}
// URLGTE applies the GTE predicate on the "url" field.
func URLGTE(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldGTE(FieldURL, v))
}
// URLLT applies the LT predicate on the "url" field.
func URLLT(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldLT(FieldURL, v))
}
// URLLTE applies the LTE predicate on the "url" field.
func URLLTE(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldLTE(FieldURL, v))
}
// URLContains applies the Contains predicate on the "url" field.
func URLContains(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldContains(FieldURL, v))
}
// URLHasPrefix applies the HasPrefix predicate on the "url" field.
func URLHasPrefix(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldHasPrefix(FieldURL, v))
}
// URLHasSuffix applies the HasSuffix predicate on the "url" field.
func URLHasSuffix(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldHasSuffix(FieldURL, v))
}
// URLIsNil applies the IsNil predicate on the "url" field.
func URLIsNil() predicate.ImportList {
return predicate.ImportList(sql.FieldIsNull(FieldURL))
}
// URLNotNil applies the NotNil predicate on the "url" field.
func URLNotNil() predicate.ImportList {
return predicate.ImportList(sql.FieldNotNull(FieldURL))
}
// URLEqualFold applies the EqualFold predicate on the "url" field.
func URLEqualFold(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldEqualFold(FieldURL, v))
}
// URLContainsFold applies the ContainsFold predicate on the "url" field.
func URLContainsFold(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldContainsFold(FieldURL, v))
}
// QulityEQ applies the EQ predicate on the "qulity" field.
func QulityEQ(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldQulity, v))
}
// QulityNEQ applies the NEQ predicate on the "qulity" field.
func QulityNEQ(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldNEQ(FieldQulity, v))
}
// QulityIn applies the In predicate on the "qulity" field.
func QulityIn(vs ...string) predicate.ImportList {
return predicate.ImportList(sql.FieldIn(FieldQulity, vs...))
}
// QulityNotIn applies the NotIn predicate on the "qulity" field.
func QulityNotIn(vs ...string) predicate.ImportList {
return predicate.ImportList(sql.FieldNotIn(FieldQulity, vs...))
}
// QulityGT applies the GT predicate on the "qulity" field.
func QulityGT(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldGT(FieldQulity, v))
}
// QulityGTE applies the GTE predicate on the "qulity" field.
func QulityGTE(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldGTE(FieldQulity, v))
}
// QulityLT applies the LT predicate on the "qulity" field.
func QulityLT(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldLT(FieldQulity, v))
}
// QulityLTE applies the LTE predicate on the "qulity" field.
func QulityLTE(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldLTE(FieldQulity, v))
}
// QulityContains applies the Contains predicate on the "qulity" field.
func QulityContains(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldContains(FieldQulity, v))
}
// QulityHasPrefix applies the HasPrefix predicate on the "qulity" field.
func QulityHasPrefix(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldHasPrefix(FieldQulity, v))
}
// QulityHasSuffix applies the HasSuffix predicate on the "qulity" field.
func QulityHasSuffix(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldHasSuffix(FieldQulity, v))
}
// QulityEqualFold applies the EqualFold predicate on the "qulity" field.
func QulityEqualFold(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldEqualFold(FieldQulity, v))
}
// QulityContainsFold applies the ContainsFold predicate on the "qulity" field.
func QulityContainsFold(v string) predicate.ImportList {
return predicate.ImportList(sql.FieldContainsFold(FieldQulity, v))
}
// StorageIDEQ applies the EQ predicate on the "storage_id" field.
func StorageIDEQ(v int) predicate.ImportList {
return predicate.ImportList(sql.FieldEQ(FieldStorageID, v))
}
// StorageIDNEQ applies the NEQ predicate on the "storage_id" field.
func StorageIDNEQ(v int) predicate.ImportList {
return predicate.ImportList(sql.FieldNEQ(FieldStorageID, v))
}
// StorageIDIn applies the In predicate on the "storage_id" field.
func StorageIDIn(vs ...int) predicate.ImportList {
return predicate.ImportList(sql.FieldIn(FieldStorageID, vs...))
}
// StorageIDNotIn applies the NotIn predicate on the "storage_id" field.
func StorageIDNotIn(vs ...int) predicate.ImportList {
return predicate.ImportList(sql.FieldNotIn(FieldStorageID, vs...))
}
// StorageIDGT applies the GT predicate on the "storage_id" field.
func StorageIDGT(v int) predicate.ImportList {
return predicate.ImportList(sql.FieldGT(FieldStorageID, v))
}
// StorageIDGTE applies the GTE predicate on the "storage_id" field.
func StorageIDGTE(v int) predicate.ImportList {
return predicate.ImportList(sql.FieldGTE(FieldStorageID, v))
}
// StorageIDLT applies the LT predicate on the "storage_id" field.
func StorageIDLT(v int) predicate.ImportList {
return predicate.ImportList(sql.FieldLT(FieldStorageID, v))
}
// StorageIDLTE applies the LTE predicate on the "storage_id" field.
func StorageIDLTE(v int) predicate.ImportList {
return predicate.ImportList(sql.FieldLTE(FieldStorageID, v))
}
// SettingsIsNil applies the IsNil predicate on the "settings" field.
func SettingsIsNil() predicate.ImportList {
return predicate.ImportList(sql.FieldIsNull(FieldSettings))
}
// SettingsNotNil applies the NotNil predicate on the "settings" field.
func SettingsNotNil() predicate.ImportList {
return predicate.ImportList(sql.FieldNotNull(FieldSettings))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ImportList) predicate.ImportList {
return predicate.ImportList(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ImportList) predicate.ImportList {
return predicate.ImportList(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ImportList) predicate.ImportList {
return predicate.ImportList(sql.NotPredicates(p))
}

264
ent/importlist_create.go Normal file
View File

@@ -0,0 +1,264 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"polaris/ent/importlist"
"polaris/ent/schema"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ImportListCreate is the builder for creating a ImportList entity.
type ImportListCreate struct {
config
mutation *ImportListMutation
hooks []Hook
}
// SetName sets the "name" field.
func (ilc *ImportListCreate) SetName(s string) *ImportListCreate {
ilc.mutation.SetName(s)
return ilc
}
// SetType sets the "type" field.
func (ilc *ImportListCreate) SetType(i importlist.Type) *ImportListCreate {
ilc.mutation.SetType(i)
return ilc
}
// SetURL sets the "url" field.
func (ilc *ImportListCreate) SetURL(s string) *ImportListCreate {
ilc.mutation.SetURL(s)
return ilc
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (ilc *ImportListCreate) SetNillableURL(s *string) *ImportListCreate {
if s != nil {
ilc.SetURL(*s)
}
return ilc
}
// SetQulity sets the "qulity" field.
func (ilc *ImportListCreate) SetQulity(s string) *ImportListCreate {
ilc.mutation.SetQulity(s)
return ilc
}
// SetStorageID sets the "storage_id" field.
func (ilc *ImportListCreate) SetStorageID(i int) *ImportListCreate {
ilc.mutation.SetStorageID(i)
return ilc
}
// SetSettings sets the "settings" field.
func (ilc *ImportListCreate) SetSettings(sls schema.ImportListSettings) *ImportListCreate {
ilc.mutation.SetSettings(sls)
return ilc
}
// SetNillableSettings sets the "settings" field if the given value is not nil.
func (ilc *ImportListCreate) SetNillableSettings(sls *schema.ImportListSettings) *ImportListCreate {
if sls != nil {
ilc.SetSettings(*sls)
}
return ilc
}
// Mutation returns the ImportListMutation object of the builder.
func (ilc *ImportListCreate) Mutation() *ImportListMutation {
return ilc.mutation
}
// Save creates the ImportList in the database.
func (ilc *ImportListCreate) Save(ctx context.Context) (*ImportList, error) {
return withHooks(ctx, ilc.sqlSave, ilc.mutation, ilc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (ilc *ImportListCreate) SaveX(ctx context.Context) *ImportList {
v, err := ilc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (ilc *ImportListCreate) Exec(ctx context.Context) error {
_, err := ilc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (ilc *ImportListCreate) ExecX(ctx context.Context) {
if err := ilc.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (ilc *ImportListCreate) check() error {
if _, ok := ilc.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ImportList.name"`)}
}
if _, ok := ilc.mutation.GetType(); !ok {
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "ImportList.type"`)}
}
if v, ok := ilc.mutation.GetType(); ok {
if err := importlist.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ImportList.type": %w`, err)}
}
}
if _, ok := ilc.mutation.Qulity(); !ok {
return &ValidationError{Name: "qulity", err: errors.New(`ent: missing required field "ImportList.qulity"`)}
}
if _, ok := ilc.mutation.StorageID(); !ok {
return &ValidationError{Name: "storage_id", err: errors.New(`ent: missing required field "ImportList.storage_id"`)}
}
return nil
}
func (ilc *ImportListCreate) sqlSave(ctx context.Context) (*ImportList, error) {
if err := ilc.check(); err != nil {
return nil, err
}
_node, _spec := ilc.createSpec()
if err := sqlgraph.CreateNode(ctx, ilc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
ilc.mutation.id = &_node.ID
ilc.mutation.done = true
return _node, nil
}
func (ilc *ImportListCreate) createSpec() (*ImportList, *sqlgraph.CreateSpec) {
var (
_node = &ImportList{config: ilc.config}
_spec = sqlgraph.NewCreateSpec(importlist.Table, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
)
if value, ok := ilc.mutation.Name(); ok {
_spec.SetField(importlist.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := ilc.mutation.GetType(); ok {
_spec.SetField(importlist.FieldType, field.TypeEnum, value)
_node.Type = value
}
if value, ok := ilc.mutation.URL(); ok {
_spec.SetField(importlist.FieldURL, field.TypeString, value)
_node.URL = value
}
if value, ok := ilc.mutation.Qulity(); ok {
_spec.SetField(importlist.FieldQulity, field.TypeString, value)
_node.Qulity = value
}
if value, ok := ilc.mutation.StorageID(); ok {
_spec.SetField(importlist.FieldStorageID, field.TypeInt, value)
_node.StorageID = value
}
if value, ok := ilc.mutation.Settings(); ok {
_spec.SetField(importlist.FieldSettings, field.TypeJSON, value)
_node.Settings = value
}
return _node, _spec
}
// ImportListCreateBulk is the builder for creating many ImportList entities in bulk.
type ImportListCreateBulk struct {
config
err error
builders []*ImportListCreate
}
// Save creates the ImportList entities in the database.
func (ilcb *ImportListCreateBulk) Save(ctx context.Context) ([]*ImportList, error) {
if ilcb.err != nil {
return nil, ilcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(ilcb.builders))
nodes := make([]*ImportList, len(ilcb.builders))
mutators := make([]Mutator, len(ilcb.builders))
for i := range ilcb.builders {
func(i int, root context.Context) {
builder := ilcb.builders[i]
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ImportListMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ilcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ilcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, ilcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (ilcb *ImportListCreateBulk) SaveX(ctx context.Context) []*ImportList {
v, err := ilcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (ilcb *ImportListCreateBulk) Exec(ctx context.Context) error {
_, err := ilcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (ilcb *ImportListCreateBulk) ExecX(ctx context.Context) {
if err := ilcb.Exec(ctx); err != nil {
panic(err)
}
}

88
ent/importlist_delete.go Normal file
View File

@@ -0,0 +1,88 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"polaris/ent/importlist"
"polaris/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ImportListDelete is the builder for deleting a ImportList entity.
type ImportListDelete struct {
config
hooks []Hook
mutation *ImportListMutation
}
// Where appends a list predicates to the ImportListDelete builder.
func (ild *ImportListDelete) Where(ps ...predicate.ImportList) *ImportListDelete {
ild.mutation.Where(ps...)
return ild
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (ild *ImportListDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, ild.sqlExec, ild.mutation, ild.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (ild *ImportListDelete) ExecX(ctx context.Context) int {
n, err := ild.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (ild *ImportListDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(importlist.Table, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
if ps := ild.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, ild.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
ild.mutation.done = true
return affected, err
}
// ImportListDeleteOne is the builder for deleting a single ImportList entity.
type ImportListDeleteOne struct {
ild *ImportListDelete
}
// Where appends a list predicates to the ImportListDelete builder.
func (ildo *ImportListDeleteOne) Where(ps ...predicate.ImportList) *ImportListDeleteOne {
ildo.ild.mutation.Where(ps...)
return ildo
}
// Exec executes the deletion query.
func (ildo *ImportListDeleteOne) Exec(ctx context.Context) error {
n, err := ildo.ild.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{importlist.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (ildo *ImportListDeleteOne) ExecX(ctx context.Context) {
if err := ildo.Exec(ctx); err != nil {
panic(err)
}
}

527
ent/importlist_query.go Normal file
View File

@@ -0,0 +1,527 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"polaris/ent/importlist"
"polaris/ent/predicate"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ImportListQuery is the builder for querying ImportList entities.
type ImportListQuery struct {
config
ctx *QueryContext
order []importlist.OrderOption
inters []Interceptor
predicates []predicate.ImportList
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ImportListQuery builder.
func (ilq *ImportListQuery) Where(ps ...predicate.ImportList) *ImportListQuery {
ilq.predicates = append(ilq.predicates, ps...)
return ilq
}
// Limit the number of records to be returned by this query.
func (ilq *ImportListQuery) Limit(limit int) *ImportListQuery {
ilq.ctx.Limit = &limit
return ilq
}
// Offset to start from.
func (ilq *ImportListQuery) Offset(offset int) *ImportListQuery {
ilq.ctx.Offset = &offset
return ilq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (ilq *ImportListQuery) Unique(unique bool) *ImportListQuery {
ilq.ctx.Unique = &unique
return ilq
}
// Order specifies how the records should be ordered.
func (ilq *ImportListQuery) Order(o ...importlist.OrderOption) *ImportListQuery {
ilq.order = append(ilq.order, o...)
return ilq
}
// First returns the first ImportList entity from the query.
// Returns a *NotFoundError when no ImportList was found.
func (ilq *ImportListQuery) First(ctx context.Context) (*ImportList, error) {
nodes, err := ilq.Limit(1).All(setContextOp(ctx, ilq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{importlist.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (ilq *ImportListQuery) FirstX(ctx context.Context) *ImportList {
node, err := ilq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ImportList ID from the query.
// Returns a *NotFoundError when no ImportList ID was found.
func (ilq *ImportListQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = ilq.Limit(1).IDs(setContextOp(ctx, ilq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{importlist.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (ilq *ImportListQuery) FirstIDX(ctx context.Context) int {
id, err := ilq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ImportList entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ImportList entity is found.
// Returns a *NotFoundError when no ImportList entities are found.
func (ilq *ImportListQuery) Only(ctx context.Context) (*ImportList, error) {
nodes, err := ilq.Limit(2).All(setContextOp(ctx, ilq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{importlist.Label}
default:
return nil, &NotSingularError{importlist.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (ilq *ImportListQuery) OnlyX(ctx context.Context) *ImportList {
node, err := ilq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ImportList ID in the query.
// Returns a *NotSingularError when more than one ImportList ID is found.
// Returns a *NotFoundError when no entities are found.
func (ilq *ImportListQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = ilq.Limit(2).IDs(setContextOp(ctx, ilq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{importlist.Label}
default:
err = &NotSingularError{importlist.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (ilq *ImportListQuery) OnlyIDX(ctx context.Context) int {
id, err := ilq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ImportLists.
func (ilq *ImportListQuery) All(ctx context.Context) ([]*ImportList, error) {
ctx = setContextOp(ctx, ilq.ctx, ent.OpQueryAll)
if err := ilq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ImportList, *ImportListQuery]()
return withInterceptors[[]*ImportList](ctx, ilq, qr, ilq.inters)
}
// AllX is like All, but panics if an error occurs.
func (ilq *ImportListQuery) AllX(ctx context.Context) []*ImportList {
nodes, err := ilq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ImportList IDs.
func (ilq *ImportListQuery) IDs(ctx context.Context) (ids []int, err error) {
if ilq.ctx.Unique == nil && ilq.path != nil {
ilq.Unique(true)
}
ctx = setContextOp(ctx, ilq.ctx, ent.OpQueryIDs)
if err = ilq.Select(importlist.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (ilq *ImportListQuery) IDsX(ctx context.Context) []int {
ids, err := ilq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (ilq *ImportListQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, ilq.ctx, ent.OpQueryCount)
if err := ilq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, ilq, querierCount[*ImportListQuery](), ilq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (ilq *ImportListQuery) CountX(ctx context.Context) int {
count, err := ilq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (ilq *ImportListQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, ilq.ctx, ent.OpQueryExist)
switch _, err := ilq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (ilq *ImportListQuery) ExistX(ctx context.Context) bool {
exist, err := ilq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ImportListQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (ilq *ImportListQuery) Clone() *ImportListQuery {
if ilq == nil {
return nil
}
return &ImportListQuery{
config: ilq.config,
ctx: ilq.ctx.Clone(),
order: append([]importlist.OrderOption{}, ilq.order...),
inters: append([]Interceptor{}, ilq.inters...),
predicates: append([]predicate.ImportList{}, ilq.predicates...),
// clone intermediate query.
sql: ilq.sql.Clone(),
path: ilq.path,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// Name string `json:"name,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ImportList.Query().
// GroupBy(importlist.FieldName).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (ilq *ImportListQuery) GroupBy(field string, fields ...string) *ImportListGroupBy {
ilq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ImportListGroupBy{build: ilq}
grbuild.flds = &ilq.ctx.Fields
grbuild.label = importlist.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// Name string `json:"name,omitempty"`
// }
//
// client.ImportList.Query().
// Select(importlist.FieldName).
// Scan(ctx, &v)
func (ilq *ImportListQuery) Select(fields ...string) *ImportListSelect {
ilq.ctx.Fields = append(ilq.ctx.Fields, fields...)
sbuild := &ImportListSelect{ImportListQuery: ilq}
sbuild.label = importlist.Label
sbuild.flds, sbuild.scan = &ilq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ImportListSelect configured with the given aggregations.
func (ilq *ImportListQuery) Aggregate(fns ...AggregateFunc) *ImportListSelect {
return ilq.Select().Aggregate(fns...)
}
func (ilq *ImportListQuery) prepareQuery(ctx context.Context) error {
for _, inter := range ilq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, ilq); err != nil {
return err
}
}
}
for _, f := range ilq.ctx.Fields {
if !importlist.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if ilq.path != nil {
prev, err := ilq.path(ctx)
if err != nil {
return err
}
ilq.sql = prev
}
return nil
}
func (ilq *ImportListQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ImportList, error) {
var (
nodes = []*ImportList{}
_spec = ilq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ImportList).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ImportList{config: ilq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, ilq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (ilq *ImportListQuery) sqlCount(ctx context.Context) (int, error) {
_spec := ilq.querySpec()
_spec.Node.Columns = ilq.ctx.Fields
if len(ilq.ctx.Fields) > 0 {
_spec.Unique = ilq.ctx.Unique != nil && *ilq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, ilq.driver, _spec)
}
func (ilq *ImportListQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(importlist.Table, importlist.Columns, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
_spec.From = ilq.sql
if unique := ilq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if ilq.path != nil {
_spec.Unique = true
}
if fields := ilq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, importlist.FieldID)
for i := range fields {
if fields[i] != importlist.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := ilq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := ilq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := ilq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := ilq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (ilq *ImportListQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(ilq.driver.Dialect())
t1 := builder.Table(importlist.Table)
columns := ilq.ctx.Fields
if len(columns) == 0 {
columns = importlist.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if ilq.sql != nil {
selector = ilq.sql
selector.Select(selector.Columns(columns...)...)
}
if ilq.ctx.Unique != nil && *ilq.ctx.Unique {
selector.Distinct()
}
for _, p := range ilq.predicates {
p(selector)
}
for _, p := range ilq.order {
p(selector)
}
if offset := ilq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := ilq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ImportListGroupBy is the group-by builder for ImportList entities.
type ImportListGroupBy struct {
selector
build *ImportListQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (ilgb *ImportListGroupBy) Aggregate(fns ...AggregateFunc) *ImportListGroupBy {
ilgb.fns = append(ilgb.fns, fns...)
return ilgb
}
// Scan applies the selector query and scans the result into the given value.
func (ilgb *ImportListGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ilgb.build.ctx, ent.OpQueryGroupBy)
if err := ilgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ImportListQuery, *ImportListGroupBy](ctx, ilgb.build, ilgb, ilgb.build.inters, v)
}
func (ilgb *ImportListGroupBy) sqlScan(ctx context.Context, root *ImportListQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(ilgb.fns))
for _, fn := range ilgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*ilgb.flds)+len(ilgb.fns))
for _, f := range *ilgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*ilgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := ilgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ImportListSelect is the builder for selecting fields of ImportList entities.
type ImportListSelect struct {
*ImportListQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (ils *ImportListSelect) Aggregate(fns ...AggregateFunc) *ImportListSelect {
ils.fns = append(ils.fns, fns...)
return ils
}
// Scan applies the selector query and scans the result into the given value.
func (ils *ImportListSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ils.ctx, ent.OpQuerySelect)
if err := ils.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ImportListQuery, *ImportListSelect](ctx, ils.ImportListQuery, ils, ils.inters, v)
}
func (ils *ImportListSelect) sqlScan(ctx context.Context, root *ImportListQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ils.fns))
for _, fn := range ils.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*ils.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := ils.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

462
ent/importlist_update.go Normal file
View File

@@ -0,0 +1,462 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"polaris/ent/importlist"
"polaris/ent/predicate"
"polaris/ent/schema"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ImportListUpdate is the builder for updating ImportList entities.
type ImportListUpdate struct {
config
hooks []Hook
mutation *ImportListMutation
}
// Where appends a list predicates to the ImportListUpdate builder.
func (ilu *ImportListUpdate) Where(ps ...predicate.ImportList) *ImportListUpdate {
ilu.mutation.Where(ps...)
return ilu
}
// SetName sets the "name" field.
func (ilu *ImportListUpdate) SetName(s string) *ImportListUpdate {
ilu.mutation.SetName(s)
return ilu
}
// SetNillableName sets the "name" field if the given value is not nil.
func (ilu *ImportListUpdate) SetNillableName(s *string) *ImportListUpdate {
if s != nil {
ilu.SetName(*s)
}
return ilu
}
// SetType sets the "type" field.
func (ilu *ImportListUpdate) SetType(i importlist.Type) *ImportListUpdate {
ilu.mutation.SetType(i)
return ilu
}
// SetNillableType sets the "type" field if the given value is not nil.
func (ilu *ImportListUpdate) SetNillableType(i *importlist.Type) *ImportListUpdate {
if i != nil {
ilu.SetType(*i)
}
return ilu
}
// SetURL sets the "url" field.
func (ilu *ImportListUpdate) SetURL(s string) *ImportListUpdate {
ilu.mutation.SetURL(s)
return ilu
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (ilu *ImportListUpdate) SetNillableURL(s *string) *ImportListUpdate {
if s != nil {
ilu.SetURL(*s)
}
return ilu
}
// ClearURL clears the value of the "url" field.
func (ilu *ImportListUpdate) ClearURL() *ImportListUpdate {
ilu.mutation.ClearURL()
return ilu
}
// SetQulity sets the "qulity" field.
func (ilu *ImportListUpdate) SetQulity(s string) *ImportListUpdate {
ilu.mutation.SetQulity(s)
return ilu
}
// SetNillableQulity sets the "qulity" field if the given value is not nil.
func (ilu *ImportListUpdate) SetNillableQulity(s *string) *ImportListUpdate {
if s != nil {
ilu.SetQulity(*s)
}
return ilu
}
// SetStorageID sets the "storage_id" field.
func (ilu *ImportListUpdate) SetStorageID(i int) *ImportListUpdate {
ilu.mutation.ResetStorageID()
ilu.mutation.SetStorageID(i)
return ilu
}
// SetNillableStorageID sets the "storage_id" field if the given value is not nil.
func (ilu *ImportListUpdate) SetNillableStorageID(i *int) *ImportListUpdate {
if i != nil {
ilu.SetStorageID(*i)
}
return ilu
}
// AddStorageID adds i to the "storage_id" field.
func (ilu *ImportListUpdate) AddStorageID(i int) *ImportListUpdate {
ilu.mutation.AddStorageID(i)
return ilu
}
// SetSettings sets the "settings" field.
func (ilu *ImportListUpdate) SetSettings(sls schema.ImportListSettings) *ImportListUpdate {
ilu.mutation.SetSettings(sls)
return ilu
}
// SetNillableSettings sets the "settings" field if the given value is not nil.
func (ilu *ImportListUpdate) SetNillableSettings(sls *schema.ImportListSettings) *ImportListUpdate {
if sls != nil {
ilu.SetSettings(*sls)
}
return ilu
}
// ClearSettings clears the value of the "settings" field.
func (ilu *ImportListUpdate) ClearSettings() *ImportListUpdate {
ilu.mutation.ClearSettings()
return ilu
}
// Mutation returns the ImportListMutation object of the builder.
func (ilu *ImportListUpdate) Mutation() *ImportListMutation {
return ilu.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (ilu *ImportListUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, ilu.sqlSave, ilu.mutation, ilu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (ilu *ImportListUpdate) SaveX(ctx context.Context) int {
affected, err := ilu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (ilu *ImportListUpdate) Exec(ctx context.Context) error {
_, err := ilu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (ilu *ImportListUpdate) ExecX(ctx context.Context) {
if err := ilu.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (ilu *ImportListUpdate) check() error {
if v, ok := ilu.mutation.GetType(); ok {
if err := importlist.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ImportList.type": %w`, err)}
}
}
return nil
}
func (ilu *ImportListUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := ilu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(importlist.Table, importlist.Columns, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
if ps := ilu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := ilu.mutation.Name(); ok {
_spec.SetField(importlist.FieldName, field.TypeString, value)
}
if value, ok := ilu.mutation.GetType(); ok {
_spec.SetField(importlist.FieldType, field.TypeEnum, value)
}
if value, ok := ilu.mutation.URL(); ok {
_spec.SetField(importlist.FieldURL, field.TypeString, value)
}
if ilu.mutation.URLCleared() {
_spec.ClearField(importlist.FieldURL, field.TypeString)
}
if value, ok := ilu.mutation.Qulity(); ok {
_spec.SetField(importlist.FieldQulity, field.TypeString, value)
}
if value, ok := ilu.mutation.StorageID(); ok {
_spec.SetField(importlist.FieldStorageID, field.TypeInt, value)
}
if value, ok := ilu.mutation.AddedStorageID(); ok {
_spec.AddField(importlist.FieldStorageID, field.TypeInt, value)
}
if value, ok := ilu.mutation.Settings(); ok {
_spec.SetField(importlist.FieldSettings, field.TypeJSON, value)
}
if ilu.mutation.SettingsCleared() {
_spec.ClearField(importlist.FieldSettings, field.TypeJSON)
}
if n, err = sqlgraph.UpdateNodes(ctx, ilu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{importlist.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
ilu.mutation.done = true
return n, nil
}
// ImportListUpdateOne is the builder for updating a single ImportList entity.
type ImportListUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ImportListMutation
}
// SetName sets the "name" field.
func (iluo *ImportListUpdateOne) SetName(s string) *ImportListUpdateOne {
iluo.mutation.SetName(s)
return iluo
}
// SetNillableName sets the "name" field if the given value is not nil.
func (iluo *ImportListUpdateOne) SetNillableName(s *string) *ImportListUpdateOne {
if s != nil {
iluo.SetName(*s)
}
return iluo
}
// SetType sets the "type" field.
func (iluo *ImportListUpdateOne) SetType(i importlist.Type) *ImportListUpdateOne {
iluo.mutation.SetType(i)
return iluo
}
// SetNillableType sets the "type" field if the given value is not nil.
func (iluo *ImportListUpdateOne) SetNillableType(i *importlist.Type) *ImportListUpdateOne {
if i != nil {
iluo.SetType(*i)
}
return iluo
}
// SetURL sets the "url" field.
func (iluo *ImportListUpdateOne) SetURL(s string) *ImportListUpdateOne {
iluo.mutation.SetURL(s)
return iluo
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (iluo *ImportListUpdateOne) SetNillableURL(s *string) *ImportListUpdateOne {
if s != nil {
iluo.SetURL(*s)
}
return iluo
}
// ClearURL clears the value of the "url" field.
func (iluo *ImportListUpdateOne) ClearURL() *ImportListUpdateOne {
iluo.mutation.ClearURL()
return iluo
}
// SetQulity sets the "qulity" field.
func (iluo *ImportListUpdateOne) SetQulity(s string) *ImportListUpdateOne {
iluo.mutation.SetQulity(s)
return iluo
}
// SetNillableQulity sets the "qulity" field if the given value is not nil.
func (iluo *ImportListUpdateOne) SetNillableQulity(s *string) *ImportListUpdateOne {
if s != nil {
iluo.SetQulity(*s)
}
return iluo
}
// SetStorageID sets the "storage_id" field.
func (iluo *ImportListUpdateOne) SetStorageID(i int) *ImportListUpdateOne {
iluo.mutation.ResetStorageID()
iluo.mutation.SetStorageID(i)
return iluo
}
// SetNillableStorageID sets the "storage_id" field if the given value is not nil.
func (iluo *ImportListUpdateOne) SetNillableStorageID(i *int) *ImportListUpdateOne {
if i != nil {
iluo.SetStorageID(*i)
}
return iluo
}
// AddStorageID adds i to the "storage_id" field.
func (iluo *ImportListUpdateOne) AddStorageID(i int) *ImportListUpdateOne {
iluo.mutation.AddStorageID(i)
return iluo
}
// SetSettings sets the "settings" field.
func (iluo *ImportListUpdateOne) SetSettings(sls schema.ImportListSettings) *ImportListUpdateOne {
iluo.mutation.SetSettings(sls)
return iluo
}
// SetNillableSettings sets the "settings" field if the given value is not nil.
func (iluo *ImportListUpdateOne) SetNillableSettings(sls *schema.ImportListSettings) *ImportListUpdateOne {
if sls != nil {
iluo.SetSettings(*sls)
}
return iluo
}
// ClearSettings clears the value of the "settings" field.
func (iluo *ImportListUpdateOne) ClearSettings() *ImportListUpdateOne {
iluo.mutation.ClearSettings()
return iluo
}
// Mutation returns the ImportListMutation object of the builder.
func (iluo *ImportListUpdateOne) Mutation() *ImportListMutation {
return iluo.mutation
}
// Where appends a list predicates to the ImportListUpdate builder.
func (iluo *ImportListUpdateOne) Where(ps ...predicate.ImportList) *ImportListUpdateOne {
iluo.mutation.Where(ps...)
return iluo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (iluo *ImportListUpdateOne) Select(field string, fields ...string) *ImportListUpdateOne {
iluo.fields = append([]string{field}, fields...)
return iluo
}
// Save executes the query and returns the updated ImportList entity.
func (iluo *ImportListUpdateOne) Save(ctx context.Context) (*ImportList, error) {
return withHooks(ctx, iluo.sqlSave, iluo.mutation, iluo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (iluo *ImportListUpdateOne) SaveX(ctx context.Context) *ImportList {
node, err := iluo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (iluo *ImportListUpdateOne) Exec(ctx context.Context) error {
_, err := iluo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (iluo *ImportListUpdateOne) ExecX(ctx context.Context) {
if err := iluo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (iluo *ImportListUpdateOne) check() error {
if v, ok := iluo.mutation.GetType(); ok {
if err := importlist.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ImportList.type": %w`, err)}
}
}
return nil
}
func (iluo *ImportListUpdateOne) sqlSave(ctx context.Context) (_node *ImportList, err error) {
if err := iluo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(importlist.Table, importlist.Columns, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
id, ok := iluo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ImportList.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := iluo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, importlist.FieldID)
for _, f := range fields {
if !importlist.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != importlist.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := iluo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := iluo.mutation.Name(); ok {
_spec.SetField(importlist.FieldName, field.TypeString, value)
}
if value, ok := iluo.mutation.GetType(); ok {
_spec.SetField(importlist.FieldType, field.TypeEnum, value)
}
if value, ok := iluo.mutation.URL(); ok {
_spec.SetField(importlist.FieldURL, field.TypeString, value)
}
if iluo.mutation.URLCleared() {
_spec.ClearField(importlist.FieldURL, field.TypeString)
}
if value, ok := iluo.mutation.Qulity(); ok {
_spec.SetField(importlist.FieldQulity, field.TypeString, value)
}
if value, ok := iluo.mutation.StorageID(); ok {
_spec.SetField(importlist.FieldStorageID, field.TypeInt, value)
}
if value, ok := iluo.mutation.AddedStorageID(); ok {
_spec.AddField(importlist.FieldStorageID, field.TypeInt, value)
}
if value, ok := iluo.mutation.Settings(); ok {
_spec.SetField(importlist.FieldSettings, field.TypeJSON, value)
}
if iluo.mutation.SettingsCleared() {
_spec.ClearField(importlist.FieldSettings, field.TypeJSON)
}
_node = &ImportList{config: iluo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, iluo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{importlist.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
iluo.mutation.done = true
return _node, nil
}

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"polaris/ent/indexers"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
@@ -20,12 +21,28 @@ type Indexers struct {
Name string `json:"name,omitempty"`
// Implementation holds the value of the "implementation" field.
Implementation string `json:"implementation,omitempty"`
// Settings holds the value of the "settings" field.
// deprecated, use api_key and url
Settings string `json:"settings,omitempty"`
// EnableRss holds the value of the "enable_rss" field.
EnableRss bool `json:"enable_rss,omitempty"`
// Priority holds the value of the "priority" field.
Priority int `json:"priority,omitempty"`
Priority int `json:"priority,omitempty"`
// minimal seed ratio requied, before removing torrent
SeedRatio float32 `json:"seed_ratio,omitempty"`
// Disabled holds the value of the "disabled" field.
Disabled bool `json:"disabled,omitempty"`
// TvSearch holds the value of the "tv_search" field.
TvSearch bool `json:"tv_search,omitempty"`
// MovieSearch holds the value of the "movie_search" field.
MovieSearch bool `json:"movie_search,omitempty"`
// APIKey holds the value of the "api_key" field.
APIKey string `json:"api_key,omitempty"`
// URL holds the value of the "url" field.
URL string `json:"url,omitempty"`
// synced from prowlarr
Synced bool `json:"synced,omitempty"`
// CreateTime holds the value of the "create_time" field.
CreateTime time.Time `json:"create_time,omitempty"`
selectValues sql.SelectValues
}
@@ -34,12 +51,16 @@ func (*Indexers) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case indexers.FieldEnableRss:
case indexers.FieldEnableRss, indexers.FieldDisabled, indexers.FieldTvSearch, indexers.FieldMovieSearch, indexers.FieldSynced:
values[i] = new(sql.NullBool)
case indexers.FieldSeedRatio:
values[i] = new(sql.NullFloat64)
case indexers.FieldID, indexers.FieldPriority:
values[i] = new(sql.NullInt64)
case indexers.FieldName, indexers.FieldImplementation, indexers.FieldSettings:
case indexers.FieldName, indexers.FieldImplementation, indexers.FieldSettings, indexers.FieldAPIKey, indexers.FieldURL:
values[i] = new(sql.NullString)
case indexers.FieldCreateTime:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
@@ -91,6 +112,54 @@ func (i *Indexers) assignValues(columns []string, values []any) error {
} else if value.Valid {
i.Priority = int(value.Int64)
}
case indexers.FieldSeedRatio:
if value, ok := values[j].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field seed_ratio", values[j])
} else if value.Valid {
i.SeedRatio = float32(value.Float64)
}
case indexers.FieldDisabled:
if value, ok := values[j].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field disabled", values[j])
} else if value.Valid {
i.Disabled = value.Bool
}
case indexers.FieldTvSearch:
if value, ok := values[j].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field tv_search", values[j])
} else if value.Valid {
i.TvSearch = value.Bool
}
case indexers.FieldMovieSearch:
if value, ok := values[j].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field movie_search", values[j])
} else if value.Valid {
i.MovieSearch = value.Bool
}
case indexers.FieldAPIKey:
if value, ok := values[j].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field api_key", values[j])
} else if value.Valid {
i.APIKey = value.String
}
case indexers.FieldURL:
if value, ok := values[j].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field url", values[j])
} else if value.Valid {
i.URL = value.String
}
case indexers.FieldSynced:
if value, ok := values[j].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field synced", values[j])
} else if value.Valid {
i.Synced = value.Bool
}
case indexers.FieldCreateTime:
if value, ok := values[j].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field create_time", values[j])
} else if value.Valid {
i.CreateTime = value.Time
}
default:
i.selectValues.Set(columns[j], values[j])
}
@@ -141,6 +210,30 @@ func (i *Indexers) String() string {
builder.WriteString(", ")
builder.WriteString("priority=")
builder.WriteString(fmt.Sprintf("%v", i.Priority))
builder.WriteString(", ")
builder.WriteString("seed_ratio=")
builder.WriteString(fmt.Sprintf("%v", i.SeedRatio))
builder.WriteString(", ")
builder.WriteString("disabled=")
builder.WriteString(fmt.Sprintf("%v", i.Disabled))
builder.WriteString(", ")
builder.WriteString("tv_search=")
builder.WriteString(fmt.Sprintf("%v", i.TvSearch))
builder.WriteString(", ")
builder.WriteString("movie_search=")
builder.WriteString(fmt.Sprintf("%v", i.MovieSearch))
builder.WriteString(", ")
builder.WriteString("api_key=")
builder.WriteString(i.APIKey)
builder.WriteString(", ")
builder.WriteString("url=")
builder.WriteString(i.URL)
builder.WriteString(", ")
builder.WriteString("synced=")
builder.WriteString(fmt.Sprintf("%v", i.Synced))
builder.WriteString(", ")
builder.WriteString("create_time=")
builder.WriteString(i.CreateTime.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}

View File

@@ -3,6 +3,8 @@
package indexers
import (
"time"
"entgo.io/ent/dialect/sql"
)
@@ -21,6 +23,22 @@ const (
FieldEnableRss = "enable_rss"
// FieldPriority holds the string denoting the priority field in the database.
FieldPriority = "priority"
// FieldSeedRatio holds the string denoting the seed_ratio field in the database.
FieldSeedRatio = "seed_ratio"
// FieldDisabled holds the string denoting the disabled field in the database.
FieldDisabled = "disabled"
// FieldTvSearch holds the string denoting the tv_search field in the database.
FieldTvSearch = "tv_search"
// FieldMovieSearch holds the string denoting the movie_search field in the database.
FieldMovieSearch = "movie_search"
// FieldAPIKey holds the string denoting the api_key field in the database.
FieldAPIKey = "api_key"
// FieldURL holds the string denoting the url field in the database.
FieldURL = "url"
// FieldSynced holds the string denoting the synced field in the database.
FieldSynced = "synced"
// FieldCreateTime holds the string denoting the create_time field in the database.
FieldCreateTime = "create_time"
// Table holds the table name of the indexers in the database.
Table = "indexers"
)
@@ -33,6 +51,14 @@ var Columns = []string{
FieldSettings,
FieldEnableRss,
FieldPriority,
FieldSeedRatio,
FieldDisabled,
FieldTvSearch,
FieldMovieSearch,
FieldAPIKey,
FieldURL,
FieldSynced,
FieldCreateTime,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -46,8 +72,26 @@ func ValidColumn(column string) bool {
}
var (
// DefaultSettings holds the default value on creation for the "settings" field.
DefaultSettings string
// DefaultEnableRss holds the default value on creation for the "enable_rss" field.
DefaultEnableRss bool
// DefaultPriority holds the default value on creation for the "priority" field.
DefaultPriority int
// PriorityValidator is a validator for the "priority" field. It is called by the builders before save.
PriorityValidator func(int) error
// DefaultSeedRatio holds the default value on creation for the "seed_ratio" field.
DefaultSeedRatio float32
// DefaultDisabled holds the default value on creation for the "disabled" field.
DefaultDisabled bool
// DefaultTvSearch holds the default value on creation for the "tv_search" field.
DefaultTvSearch bool
// DefaultMovieSearch holds the default value on creation for the "movie_search" field.
DefaultMovieSearch bool
// DefaultSynced holds the default value on creation for the "synced" field.
DefaultSynced bool
// DefaultCreateTime holds the default value on creation for the "create_time" field.
DefaultCreateTime func() time.Time
)
// OrderOption defines the ordering options for the Indexers queries.
@@ -82,3 +126,43 @@ func ByEnableRss(opts ...sql.OrderTermOption) OrderOption {
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPriority, opts...).ToFunc()
}
// BySeedRatio orders the results by the seed_ratio field.
func BySeedRatio(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSeedRatio, opts...).ToFunc()
}
// ByDisabled orders the results by the disabled field.
func ByDisabled(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDisabled, opts...).ToFunc()
}
// ByTvSearch orders the results by the tv_search field.
func ByTvSearch(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTvSearch, opts...).ToFunc()
}
// ByMovieSearch orders the results by the movie_search field.
func ByMovieSearch(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMovieSearch, opts...).ToFunc()
}
// ByAPIKey orders the results by the api_key field.
func ByAPIKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAPIKey, opts...).ToFunc()
}
// ByURL orders the results by the url field.
func ByURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldURL, opts...).ToFunc()
}
// BySynced orders the results by the synced field.
func BySynced(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSynced, opts...).ToFunc()
}
// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}

View File

@@ -4,6 +4,7 @@ package indexers
import (
"polaris/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
@@ -78,6 +79,46 @@ func Priority(v int) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldPriority, v))
}
// SeedRatio applies equality check predicate on the "seed_ratio" field. It's identical to SeedRatioEQ.
func SeedRatio(v float32) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldSeedRatio, v))
}
// Disabled applies equality check predicate on the "disabled" field. It's identical to DisabledEQ.
func Disabled(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldDisabled, v))
}
// TvSearch applies equality check predicate on the "tv_search" field. It's identical to TvSearchEQ.
func TvSearch(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldTvSearch, v))
}
// MovieSearch applies equality check predicate on the "movie_search" field. It's identical to MovieSearchEQ.
func MovieSearch(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldMovieSearch, v))
}
// APIKey applies equality check predicate on the "api_key" field. It's identical to APIKeyEQ.
func APIKey(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldAPIKey, v))
}
// URL applies equality check predicate on the "url" field. It's identical to URLEQ.
func URL(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldURL, v))
}
// Synced applies equality check predicate on the "synced" field. It's identical to SyncedEQ.
func Synced(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldSynced, v))
}
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
func CreateTime(v time.Time) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldCreateTime, v))
}
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldName, v))
@@ -263,6 +304,16 @@ func SettingsHasSuffix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasSuffix(FieldSettings, v))
}
// SettingsIsNil applies the IsNil predicate on the "settings" field.
func SettingsIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldSettings))
}
// SettingsNotNil applies the NotNil predicate on the "settings" field.
func SettingsNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldSettings))
}
// SettingsEqualFold applies the EqualFold predicate on the "settings" field.
func SettingsEqualFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEqualFold(FieldSettings, v))
@@ -323,6 +374,336 @@ func PriorityLTE(v int) predicate.Indexers {
return predicate.Indexers(sql.FieldLTE(FieldPriority, v))
}
// SeedRatioEQ applies the EQ predicate on the "seed_ratio" field.
func SeedRatioEQ(v float32) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldSeedRatio, v))
}
// SeedRatioNEQ applies the NEQ predicate on the "seed_ratio" field.
func SeedRatioNEQ(v float32) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldSeedRatio, v))
}
// SeedRatioIn applies the In predicate on the "seed_ratio" field.
func SeedRatioIn(vs ...float32) predicate.Indexers {
return predicate.Indexers(sql.FieldIn(FieldSeedRatio, vs...))
}
// SeedRatioNotIn applies the NotIn predicate on the "seed_ratio" field.
func SeedRatioNotIn(vs ...float32) predicate.Indexers {
return predicate.Indexers(sql.FieldNotIn(FieldSeedRatio, vs...))
}
// SeedRatioGT applies the GT predicate on the "seed_ratio" field.
func SeedRatioGT(v float32) predicate.Indexers {
return predicate.Indexers(sql.FieldGT(FieldSeedRatio, v))
}
// SeedRatioGTE applies the GTE predicate on the "seed_ratio" field.
func SeedRatioGTE(v float32) predicate.Indexers {
return predicate.Indexers(sql.FieldGTE(FieldSeedRatio, v))
}
// SeedRatioLT applies the LT predicate on the "seed_ratio" field.
func SeedRatioLT(v float32) predicate.Indexers {
return predicate.Indexers(sql.FieldLT(FieldSeedRatio, v))
}
// SeedRatioLTE applies the LTE predicate on the "seed_ratio" field.
func SeedRatioLTE(v float32) predicate.Indexers {
return predicate.Indexers(sql.FieldLTE(FieldSeedRatio, v))
}
// SeedRatioIsNil applies the IsNil predicate on the "seed_ratio" field.
func SeedRatioIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldSeedRatio))
}
// SeedRatioNotNil applies the NotNil predicate on the "seed_ratio" field.
func SeedRatioNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldSeedRatio))
}
// DisabledEQ applies the EQ predicate on the "disabled" field.
func DisabledEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldDisabled, v))
}
// DisabledNEQ applies the NEQ predicate on the "disabled" field.
func DisabledNEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldDisabled, v))
}
// DisabledIsNil applies the IsNil predicate on the "disabled" field.
func DisabledIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldDisabled))
}
// DisabledNotNil applies the NotNil predicate on the "disabled" field.
func DisabledNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldDisabled))
}
// TvSearchEQ applies the EQ predicate on the "tv_search" field.
func TvSearchEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldTvSearch, v))
}
// TvSearchNEQ applies the NEQ predicate on the "tv_search" field.
func TvSearchNEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldTvSearch, v))
}
// TvSearchIsNil applies the IsNil predicate on the "tv_search" field.
func TvSearchIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldTvSearch))
}
// TvSearchNotNil applies the NotNil predicate on the "tv_search" field.
func TvSearchNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldTvSearch))
}
// MovieSearchEQ applies the EQ predicate on the "movie_search" field.
func MovieSearchEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldMovieSearch, v))
}
// MovieSearchNEQ applies the NEQ predicate on the "movie_search" field.
func MovieSearchNEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldMovieSearch, v))
}
// MovieSearchIsNil applies the IsNil predicate on the "movie_search" field.
func MovieSearchIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldMovieSearch))
}
// MovieSearchNotNil applies the NotNil predicate on the "movie_search" field.
func MovieSearchNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldMovieSearch))
}
// APIKeyEQ applies the EQ predicate on the "api_key" field.
func APIKeyEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldAPIKey, v))
}
// APIKeyNEQ applies the NEQ predicate on the "api_key" field.
func APIKeyNEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldAPIKey, v))
}
// APIKeyIn applies the In predicate on the "api_key" field.
func APIKeyIn(vs ...string) predicate.Indexers {
return predicate.Indexers(sql.FieldIn(FieldAPIKey, vs...))
}
// APIKeyNotIn applies the NotIn predicate on the "api_key" field.
func APIKeyNotIn(vs ...string) predicate.Indexers {
return predicate.Indexers(sql.FieldNotIn(FieldAPIKey, vs...))
}
// APIKeyGT applies the GT predicate on the "api_key" field.
func APIKeyGT(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldGT(FieldAPIKey, v))
}
// APIKeyGTE applies the GTE predicate on the "api_key" field.
func APIKeyGTE(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldGTE(FieldAPIKey, v))
}
// APIKeyLT applies the LT predicate on the "api_key" field.
func APIKeyLT(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldLT(FieldAPIKey, v))
}
// APIKeyLTE applies the LTE predicate on the "api_key" field.
func APIKeyLTE(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldLTE(FieldAPIKey, v))
}
// APIKeyContains applies the Contains predicate on the "api_key" field.
func APIKeyContains(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldContains(FieldAPIKey, v))
}
// APIKeyHasPrefix applies the HasPrefix predicate on the "api_key" field.
func APIKeyHasPrefix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasPrefix(FieldAPIKey, v))
}
// APIKeyHasSuffix applies the HasSuffix predicate on the "api_key" field.
func APIKeyHasSuffix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasSuffix(FieldAPIKey, v))
}
// APIKeyIsNil applies the IsNil predicate on the "api_key" field.
func APIKeyIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldAPIKey))
}
// APIKeyNotNil applies the NotNil predicate on the "api_key" field.
func APIKeyNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldAPIKey))
}
// APIKeyEqualFold applies the EqualFold predicate on the "api_key" field.
func APIKeyEqualFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEqualFold(FieldAPIKey, v))
}
// APIKeyContainsFold applies the ContainsFold predicate on the "api_key" field.
func APIKeyContainsFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldContainsFold(FieldAPIKey, v))
}
// URLEQ applies the EQ predicate on the "url" field.
func URLEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldURL, v))
}
// URLNEQ applies the NEQ predicate on the "url" field.
func URLNEQ(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldURL, v))
}
// URLIn applies the In predicate on the "url" field.
func URLIn(vs ...string) predicate.Indexers {
return predicate.Indexers(sql.FieldIn(FieldURL, vs...))
}
// URLNotIn applies the NotIn predicate on the "url" field.
func URLNotIn(vs ...string) predicate.Indexers {
return predicate.Indexers(sql.FieldNotIn(FieldURL, vs...))
}
// URLGT applies the GT predicate on the "url" field.
func URLGT(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldGT(FieldURL, v))
}
// URLGTE applies the GTE predicate on the "url" field.
func URLGTE(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldGTE(FieldURL, v))
}
// URLLT applies the LT predicate on the "url" field.
func URLLT(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldLT(FieldURL, v))
}
// URLLTE applies the LTE predicate on the "url" field.
func URLLTE(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldLTE(FieldURL, v))
}
// URLContains applies the Contains predicate on the "url" field.
func URLContains(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldContains(FieldURL, v))
}
// URLHasPrefix applies the HasPrefix predicate on the "url" field.
func URLHasPrefix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasPrefix(FieldURL, v))
}
// URLHasSuffix applies the HasSuffix predicate on the "url" field.
func URLHasSuffix(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldHasSuffix(FieldURL, v))
}
// URLIsNil applies the IsNil predicate on the "url" field.
func URLIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldURL))
}
// URLNotNil applies the NotNil predicate on the "url" field.
func URLNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldURL))
}
// URLEqualFold applies the EqualFold predicate on the "url" field.
func URLEqualFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldEqualFold(FieldURL, v))
}
// URLContainsFold applies the ContainsFold predicate on the "url" field.
func URLContainsFold(v string) predicate.Indexers {
return predicate.Indexers(sql.FieldContainsFold(FieldURL, v))
}
// SyncedEQ applies the EQ predicate on the "synced" field.
func SyncedEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldSynced, v))
}
// SyncedNEQ applies the NEQ predicate on the "synced" field.
func SyncedNEQ(v bool) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldSynced, v))
}
// SyncedIsNil applies the IsNil predicate on the "synced" field.
func SyncedIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldSynced))
}
// SyncedNotNil applies the NotNil predicate on the "synced" field.
func SyncedNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldSynced))
}
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
func CreateTimeEQ(v time.Time) predicate.Indexers {
return predicate.Indexers(sql.FieldEQ(FieldCreateTime, v))
}
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
func CreateTimeNEQ(v time.Time) predicate.Indexers {
return predicate.Indexers(sql.FieldNEQ(FieldCreateTime, v))
}
// CreateTimeIn applies the In predicate on the "create_time" field.
func CreateTimeIn(vs ...time.Time) predicate.Indexers {
return predicate.Indexers(sql.FieldIn(FieldCreateTime, vs...))
}
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
func CreateTimeNotIn(vs ...time.Time) predicate.Indexers {
return predicate.Indexers(sql.FieldNotIn(FieldCreateTime, vs...))
}
// CreateTimeGT applies the GT predicate on the "create_time" field.
func CreateTimeGT(v time.Time) predicate.Indexers {
return predicate.Indexers(sql.FieldGT(FieldCreateTime, v))
}
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
func CreateTimeGTE(v time.Time) predicate.Indexers {
return predicate.Indexers(sql.FieldGTE(FieldCreateTime, v))
}
// CreateTimeLT applies the LT predicate on the "create_time" field.
func CreateTimeLT(v time.Time) predicate.Indexers {
return predicate.Indexers(sql.FieldLT(FieldCreateTime, v))
}
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
func CreateTimeLTE(v time.Time) predicate.Indexers {
return predicate.Indexers(sql.FieldLTE(FieldCreateTime, v))
}
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
func CreateTimeIsNil() predicate.Indexers {
return predicate.Indexers(sql.FieldIsNull(FieldCreateTime))
}
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
func CreateTimeNotNil() predicate.Indexers {
return predicate.Indexers(sql.FieldNotNull(FieldCreateTime))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Indexers) predicate.Indexers {
return predicate.Indexers(sql.AndPredicates(predicates...))

View File

@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"polaris/ent/indexers"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -37,6 +38,14 @@ func (ic *IndexersCreate) SetSettings(s string) *IndexersCreate {
return ic
}
// SetNillableSettings sets the "settings" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableSettings(s *string) *IndexersCreate {
if s != nil {
ic.SetSettings(*s)
}
return ic
}
// SetEnableRss sets the "enable_rss" field.
func (ic *IndexersCreate) SetEnableRss(b bool) *IndexersCreate {
ic.mutation.SetEnableRss(b)
@@ -57,6 +66,126 @@ func (ic *IndexersCreate) SetPriority(i int) *IndexersCreate {
return ic
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func (ic *IndexersCreate) SetNillablePriority(i *int) *IndexersCreate {
if i != nil {
ic.SetPriority(*i)
}
return ic
}
// SetSeedRatio sets the "seed_ratio" field.
func (ic *IndexersCreate) SetSeedRatio(f float32) *IndexersCreate {
ic.mutation.SetSeedRatio(f)
return ic
}
// SetNillableSeedRatio sets the "seed_ratio" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableSeedRatio(f *float32) *IndexersCreate {
if f != nil {
ic.SetSeedRatio(*f)
}
return ic
}
// SetDisabled sets the "disabled" field.
func (ic *IndexersCreate) SetDisabled(b bool) *IndexersCreate {
ic.mutation.SetDisabled(b)
return ic
}
// SetNillableDisabled sets the "disabled" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableDisabled(b *bool) *IndexersCreate {
if b != nil {
ic.SetDisabled(*b)
}
return ic
}
// SetTvSearch sets the "tv_search" field.
func (ic *IndexersCreate) SetTvSearch(b bool) *IndexersCreate {
ic.mutation.SetTvSearch(b)
return ic
}
// SetNillableTvSearch sets the "tv_search" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableTvSearch(b *bool) *IndexersCreate {
if b != nil {
ic.SetTvSearch(*b)
}
return ic
}
// SetMovieSearch sets the "movie_search" field.
func (ic *IndexersCreate) SetMovieSearch(b bool) *IndexersCreate {
ic.mutation.SetMovieSearch(b)
return ic
}
// SetNillableMovieSearch sets the "movie_search" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableMovieSearch(b *bool) *IndexersCreate {
if b != nil {
ic.SetMovieSearch(*b)
}
return ic
}
// SetAPIKey sets the "api_key" field.
func (ic *IndexersCreate) SetAPIKey(s string) *IndexersCreate {
ic.mutation.SetAPIKey(s)
return ic
}
// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableAPIKey(s *string) *IndexersCreate {
if s != nil {
ic.SetAPIKey(*s)
}
return ic
}
// SetURL sets the "url" field.
func (ic *IndexersCreate) SetURL(s string) *IndexersCreate {
ic.mutation.SetURL(s)
return ic
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableURL(s *string) *IndexersCreate {
if s != nil {
ic.SetURL(*s)
}
return ic
}
// SetSynced sets the "synced" field.
func (ic *IndexersCreate) SetSynced(b bool) *IndexersCreate {
ic.mutation.SetSynced(b)
return ic
}
// SetNillableSynced sets the "synced" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableSynced(b *bool) *IndexersCreate {
if b != nil {
ic.SetSynced(*b)
}
return ic
}
// SetCreateTime sets the "create_time" field.
func (ic *IndexersCreate) SetCreateTime(t time.Time) *IndexersCreate {
ic.mutation.SetCreateTime(t)
return ic
}
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
func (ic *IndexersCreate) SetNillableCreateTime(t *time.Time) *IndexersCreate {
if t != nil {
ic.SetCreateTime(*t)
}
return ic
}
// Mutation returns the IndexersMutation object of the builder.
func (ic *IndexersCreate) Mutation() *IndexersMutation {
return ic.mutation
@@ -92,10 +221,42 @@ func (ic *IndexersCreate) ExecX(ctx context.Context) {
// defaults sets the default values of the builder before save.
func (ic *IndexersCreate) defaults() {
if _, ok := ic.mutation.Settings(); !ok {
v := indexers.DefaultSettings
ic.mutation.SetSettings(v)
}
if _, ok := ic.mutation.EnableRss(); !ok {
v := indexers.DefaultEnableRss
ic.mutation.SetEnableRss(v)
}
if _, ok := ic.mutation.Priority(); !ok {
v := indexers.DefaultPriority
ic.mutation.SetPriority(v)
}
if _, ok := ic.mutation.SeedRatio(); !ok {
v := indexers.DefaultSeedRatio
ic.mutation.SetSeedRatio(v)
}
if _, ok := ic.mutation.Disabled(); !ok {
v := indexers.DefaultDisabled
ic.mutation.SetDisabled(v)
}
if _, ok := ic.mutation.TvSearch(); !ok {
v := indexers.DefaultTvSearch
ic.mutation.SetTvSearch(v)
}
if _, ok := ic.mutation.MovieSearch(); !ok {
v := indexers.DefaultMovieSearch
ic.mutation.SetMovieSearch(v)
}
if _, ok := ic.mutation.Synced(); !ok {
v := indexers.DefaultSynced
ic.mutation.SetSynced(v)
}
if _, ok := ic.mutation.CreateTime(); !ok {
v := indexers.DefaultCreateTime()
ic.mutation.SetCreateTime(v)
}
}
// check runs all checks and user-defined validators on the builder.
@@ -106,15 +267,17 @@ func (ic *IndexersCreate) check() error {
if _, ok := ic.mutation.Implementation(); !ok {
return &ValidationError{Name: "implementation", err: errors.New(`ent: missing required field "Indexers.implementation"`)}
}
if _, ok := ic.mutation.Settings(); !ok {
return &ValidationError{Name: "settings", err: errors.New(`ent: missing required field "Indexers.settings"`)}
}
if _, ok := ic.mutation.EnableRss(); !ok {
return &ValidationError{Name: "enable_rss", err: errors.New(`ent: missing required field "Indexers.enable_rss"`)}
}
if _, ok := ic.mutation.Priority(); !ok {
return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "Indexers.priority"`)}
}
if v, ok := ic.mutation.Priority(); ok {
if err := indexers.PriorityValidator(v); err != nil {
return &ValidationError{Name: "priority", err: fmt.Errorf(`ent: validator failed for field "Indexers.priority": %w`, err)}
}
}
return nil
}
@@ -161,6 +324,38 @@ func (ic *IndexersCreate) createSpec() (*Indexers, *sqlgraph.CreateSpec) {
_spec.SetField(indexers.FieldPriority, field.TypeInt, value)
_node.Priority = value
}
if value, ok := ic.mutation.SeedRatio(); ok {
_spec.SetField(indexers.FieldSeedRatio, field.TypeFloat32, value)
_node.SeedRatio = value
}
if value, ok := ic.mutation.Disabled(); ok {
_spec.SetField(indexers.FieldDisabled, field.TypeBool, value)
_node.Disabled = value
}
if value, ok := ic.mutation.TvSearch(); ok {
_spec.SetField(indexers.FieldTvSearch, field.TypeBool, value)
_node.TvSearch = value
}
if value, ok := ic.mutation.MovieSearch(); ok {
_spec.SetField(indexers.FieldMovieSearch, field.TypeBool, value)
_node.MovieSearch = value
}
if value, ok := ic.mutation.APIKey(); ok {
_spec.SetField(indexers.FieldAPIKey, field.TypeString, value)
_node.APIKey = value
}
if value, ok := ic.mutation.URL(); ok {
_spec.SetField(indexers.FieldURL, field.TypeString, value)
_node.URL = value
}
if value, ok := ic.mutation.Synced(); ok {
_spec.SetField(indexers.FieldSynced, field.TypeBool, value)
_node.Synced = value
}
if value, ok := ic.mutation.CreateTime(); ok {
_spec.SetField(indexers.FieldCreateTime, field.TypeTime, value)
_node.CreateTime = value
}
return _node, _spec
}

View File

@@ -9,6 +9,7 @@ import (
"polaris/ent/indexers"
"polaris/ent/predicate"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -60,7 +61,7 @@ func (iq *IndexersQuery) Order(o ...indexers.OrderOption) *IndexersQuery {
// First returns the first Indexers entity from the query.
// Returns a *NotFoundError when no Indexers was found.
func (iq *IndexersQuery) First(ctx context.Context) (*Indexers, error) {
nodes, err := iq.Limit(1).All(setContextOp(ctx, iq.ctx, "First"))
nodes, err := iq.Limit(1).All(setContextOp(ctx, iq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -83,7 +84,7 @@ func (iq *IndexersQuery) FirstX(ctx context.Context) *Indexers {
// Returns a *NotFoundError when no Indexers ID was found.
func (iq *IndexersQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = iq.Limit(1).IDs(setContextOp(ctx, iq.ctx, "FirstID")); err != nil {
if ids, err = iq.Limit(1).IDs(setContextOp(ctx, iq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -106,7 +107,7 @@ func (iq *IndexersQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Indexers entity is found.
// Returns a *NotFoundError when no Indexers entities are found.
func (iq *IndexersQuery) Only(ctx context.Context) (*Indexers, error) {
nodes, err := iq.Limit(2).All(setContextOp(ctx, iq.ctx, "Only"))
nodes, err := iq.Limit(2).All(setContextOp(ctx, iq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -134,7 +135,7 @@ func (iq *IndexersQuery) OnlyX(ctx context.Context) *Indexers {
// Returns a *NotFoundError when no entities are found.
func (iq *IndexersQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = iq.Limit(2).IDs(setContextOp(ctx, iq.ctx, "OnlyID")); err != nil {
if ids, err = iq.Limit(2).IDs(setContextOp(ctx, iq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -159,7 +160,7 @@ func (iq *IndexersQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of IndexersSlice.
func (iq *IndexersQuery) All(ctx context.Context) ([]*Indexers, error) {
ctx = setContextOp(ctx, iq.ctx, "All")
ctx = setContextOp(ctx, iq.ctx, ent.OpQueryAll)
if err := iq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -181,7 +182,7 @@ func (iq *IndexersQuery) IDs(ctx context.Context) (ids []int, err error) {
if iq.ctx.Unique == nil && iq.path != nil {
iq.Unique(true)
}
ctx = setContextOp(ctx, iq.ctx, "IDs")
ctx = setContextOp(ctx, iq.ctx, ent.OpQueryIDs)
if err = iq.Select(indexers.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -199,7 +200,7 @@ func (iq *IndexersQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (iq *IndexersQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, iq.ctx, "Count")
ctx = setContextOp(ctx, iq.ctx, ent.OpQueryCount)
if err := iq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -217,7 +218,7 @@ func (iq *IndexersQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (iq *IndexersQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, iq.ctx, "Exist")
ctx = setContextOp(ctx, iq.ctx, ent.OpQueryExist)
switch _, err := iq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -449,7 +450,7 @@ func (igb *IndexersGroupBy) Aggregate(fns ...AggregateFunc) *IndexersGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (igb *IndexersGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, igb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, igb.build.ctx, ent.OpQueryGroupBy)
if err := igb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -497,7 +498,7 @@ func (is *IndexersSelect) Aggregate(fns ...AggregateFunc) *IndexersSelect {
// Scan applies the selector query and scans the result into the given value.
func (is *IndexersSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, is.ctx, "Select")
ctx = setContextOp(ctx, is.ctx, ent.OpQuerySelect)
if err := is.prepareQuery(ctx); err != nil {
return err
}

View File

@@ -69,6 +69,12 @@ func (iu *IndexersUpdate) SetNillableSettings(s *string) *IndexersUpdate {
return iu
}
// ClearSettings clears the value of the "settings" field.
func (iu *IndexersUpdate) ClearSettings() *IndexersUpdate {
iu.mutation.ClearSettings()
return iu
}
// SetEnableRss sets the "enable_rss" field.
func (iu *IndexersUpdate) SetEnableRss(b bool) *IndexersUpdate {
iu.mutation.SetEnableRss(b)
@@ -104,6 +110,153 @@ func (iu *IndexersUpdate) AddPriority(i int) *IndexersUpdate {
return iu
}
// SetSeedRatio sets the "seed_ratio" field.
func (iu *IndexersUpdate) SetSeedRatio(f float32) *IndexersUpdate {
iu.mutation.ResetSeedRatio()
iu.mutation.SetSeedRatio(f)
return iu
}
// SetNillableSeedRatio sets the "seed_ratio" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableSeedRatio(f *float32) *IndexersUpdate {
if f != nil {
iu.SetSeedRatio(*f)
}
return iu
}
// AddSeedRatio adds f to the "seed_ratio" field.
func (iu *IndexersUpdate) AddSeedRatio(f float32) *IndexersUpdate {
iu.mutation.AddSeedRatio(f)
return iu
}
// ClearSeedRatio clears the value of the "seed_ratio" field.
func (iu *IndexersUpdate) ClearSeedRatio() *IndexersUpdate {
iu.mutation.ClearSeedRatio()
return iu
}
// SetDisabled sets the "disabled" field.
func (iu *IndexersUpdate) SetDisabled(b bool) *IndexersUpdate {
iu.mutation.SetDisabled(b)
return iu
}
// SetNillableDisabled sets the "disabled" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableDisabled(b *bool) *IndexersUpdate {
if b != nil {
iu.SetDisabled(*b)
}
return iu
}
// ClearDisabled clears the value of the "disabled" field.
func (iu *IndexersUpdate) ClearDisabled() *IndexersUpdate {
iu.mutation.ClearDisabled()
return iu
}
// SetTvSearch sets the "tv_search" field.
func (iu *IndexersUpdate) SetTvSearch(b bool) *IndexersUpdate {
iu.mutation.SetTvSearch(b)
return iu
}
// SetNillableTvSearch sets the "tv_search" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableTvSearch(b *bool) *IndexersUpdate {
if b != nil {
iu.SetTvSearch(*b)
}
return iu
}
// ClearTvSearch clears the value of the "tv_search" field.
func (iu *IndexersUpdate) ClearTvSearch() *IndexersUpdate {
iu.mutation.ClearTvSearch()
return iu
}
// SetMovieSearch sets the "movie_search" field.
func (iu *IndexersUpdate) SetMovieSearch(b bool) *IndexersUpdate {
iu.mutation.SetMovieSearch(b)
return iu
}
// SetNillableMovieSearch sets the "movie_search" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableMovieSearch(b *bool) *IndexersUpdate {
if b != nil {
iu.SetMovieSearch(*b)
}
return iu
}
// ClearMovieSearch clears the value of the "movie_search" field.
func (iu *IndexersUpdate) ClearMovieSearch() *IndexersUpdate {
iu.mutation.ClearMovieSearch()
return iu
}
// SetAPIKey sets the "api_key" field.
func (iu *IndexersUpdate) SetAPIKey(s string) *IndexersUpdate {
iu.mutation.SetAPIKey(s)
return iu
}
// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableAPIKey(s *string) *IndexersUpdate {
if s != nil {
iu.SetAPIKey(*s)
}
return iu
}
// ClearAPIKey clears the value of the "api_key" field.
func (iu *IndexersUpdate) ClearAPIKey() *IndexersUpdate {
iu.mutation.ClearAPIKey()
return iu
}
// SetURL sets the "url" field.
func (iu *IndexersUpdate) SetURL(s string) *IndexersUpdate {
iu.mutation.SetURL(s)
return iu
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableURL(s *string) *IndexersUpdate {
if s != nil {
iu.SetURL(*s)
}
return iu
}
// ClearURL clears the value of the "url" field.
func (iu *IndexersUpdate) ClearURL() *IndexersUpdate {
iu.mutation.ClearURL()
return iu
}
// SetSynced sets the "synced" field.
func (iu *IndexersUpdate) SetSynced(b bool) *IndexersUpdate {
iu.mutation.SetSynced(b)
return iu
}
// SetNillableSynced sets the "synced" field if the given value is not nil.
func (iu *IndexersUpdate) SetNillableSynced(b *bool) *IndexersUpdate {
if b != nil {
iu.SetSynced(*b)
}
return iu
}
// ClearSynced clears the value of the "synced" field.
func (iu *IndexersUpdate) ClearSynced() *IndexersUpdate {
iu.mutation.ClearSynced()
return iu
}
// Mutation returns the IndexersMutation object of the builder.
func (iu *IndexersUpdate) Mutation() *IndexersMutation {
return iu.mutation
@@ -136,7 +289,20 @@ func (iu *IndexersUpdate) ExecX(ctx context.Context) {
}
}
// check runs all checks and user-defined validators on the builder.
func (iu *IndexersUpdate) check() error {
if v, ok := iu.mutation.Priority(); ok {
if err := indexers.PriorityValidator(v); err != nil {
return &ValidationError{Name: "priority", err: fmt.Errorf(`ent: validator failed for field "Indexers.priority": %w`, err)}
}
}
return nil
}
func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := iu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(indexers.Table, indexers.Columns, sqlgraph.NewFieldSpec(indexers.FieldID, field.TypeInt))
if ps := iu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
@@ -154,6 +320,9 @@ func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := iu.mutation.Settings(); ok {
_spec.SetField(indexers.FieldSettings, field.TypeString, value)
}
if iu.mutation.SettingsCleared() {
_spec.ClearField(indexers.FieldSettings, field.TypeString)
}
if value, ok := iu.mutation.EnableRss(); ok {
_spec.SetField(indexers.FieldEnableRss, field.TypeBool, value)
}
@@ -163,6 +332,54 @@ func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := iu.mutation.AddedPriority(); ok {
_spec.AddField(indexers.FieldPriority, field.TypeInt, value)
}
if value, ok := iu.mutation.SeedRatio(); ok {
_spec.SetField(indexers.FieldSeedRatio, field.TypeFloat32, value)
}
if value, ok := iu.mutation.AddedSeedRatio(); ok {
_spec.AddField(indexers.FieldSeedRatio, field.TypeFloat32, value)
}
if iu.mutation.SeedRatioCleared() {
_spec.ClearField(indexers.FieldSeedRatio, field.TypeFloat32)
}
if value, ok := iu.mutation.Disabled(); ok {
_spec.SetField(indexers.FieldDisabled, field.TypeBool, value)
}
if iu.mutation.DisabledCleared() {
_spec.ClearField(indexers.FieldDisabled, field.TypeBool)
}
if value, ok := iu.mutation.TvSearch(); ok {
_spec.SetField(indexers.FieldTvSearch, field.TypeBool, value)
}
if iu.mutation.TvSearchCleared() {
_spec.ClearField(indexers.FieldTvSearch, field.TypeBool)
}
if value, ok := iu.mutation.MovieSearch(); ok {
_spec.SetField(indexers.FieldMovieSearch, field.TypeBool, value)
}
if iu.mutation.MovieSearchCleared() {
_spec.ClearField(indexers.FieldMovieSearch, field.TypeBool)
}
if value, ok := iu.mutation.APIKey(); ok {
_spec.SetField(indexers.FieldAPIKey, field.TypeString, value)
}
if iu.mutation.APIKeyCleared() {
_spec.ClearField(indexers.FieldAPIKey, field.TypeString)
}
if value, ok := iu.mutation.URL(); ok {
_spec.SetField(indexers.FieldURL, field.TypeString, value)
}
if iu.mutation.URLCleared() {
_spec.ClearField(indexers.FieldURL, field.TypeString)
}
if value, ok := iu.mutation.Synced(); ok {
_spec.SetField(indexers.FieldSynced, field.TypeBool, value)
}
if iu.mutation.SyncedCleared() {
_spec.ClearField(indexers.FieldSynced, field.TypeBool)
}
if iu.mutation.CreateTimeCleared() {
_spec.ClearField(indexers.FieldCreateTime, field.TypeTime)
}
if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{indexers.Label}
@@ -225,6 +442,12 @@ func (iuo *IndexersUpdateOne) SetNillableSettings(s *string) *IndexersUpdateOne
return iuo
}
// ClearSettings clears the value of the "settings" field.
func (iuo *IndexersUpdateOne) ClearSettings() *IndexersUpdateOne {
iuo.mutation.ClearSettings()
return iuo
}
// SetEnableRss sets the "enable_rss" field.
func (iuo *IndexersUpdateOne) SetEnableRss(b bool) *IndexersUpdateOne {
iuo.mutation.SetEnableRss(b)
@@ -260,6 +483,153 @@ func (iuo *IndexersUpdateOne) AddPriority(i int) *IndexersUpdateOne {
return iuo
}
// SetSeedRatio sets the "seed_ratio" field.
func (iuo *IndexersUpdateOne) SetSeedRatio(f float32) *IndexersUpdateOne {
iuo.mutation.ResetSeedRatio()
iuo.mutation.SetSeedRatio(f)
return iuo
}
// SetNillableSeedRatio sets the "seed_ratio" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableSeedRatio(f *float32) *IndexersUpdateOne {
if f != nil {
iuo.SetSeedRatio(*f)
}
return iuo
}
// AddSeedRatio adds f to the "seed_ratio" field.
func (iuo *IndexersUpdateOne) AddSeedRatio(f float32) *IndexersUpdateOne {
iuo.mutation.AddSeedRatio(f)
return iuo
}
// ClearSeedRatio clears the value of the "seed_ratio" field.
func (iuo *IndexersUpdateOne) ClearSeedRatio() *IndexersUpdateOne {
iuo.mutation.ClearSeedRatio()
return iuo
}
// SetDisabled sets the "disabled" field.
func (iuo *IndexersUpdateOne) SetDisabled(b bool) *IndexersUpdateOne {
iuo.mutation.SetDisabled(b)
return iuo
}
// SetNillableDisabled sets the "disabled" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableDisabled(b *bool) *IndexersUpdateOne {
if b != nil {
iuo.SetDisabled(*b)
}
return iuo
}
// ClearDisabled clears the value of the "disabled" field.
func (iuo *IndexersUpdateOne) ClearDisabled() *IndexersUpdateOne {
iuo.mutation.ClearDisabled()
return iuo
}
// SetTvSearch sets the "tv_search" field.
func (iuo *IndexersUpdateOne) SetTvSearch(b bool) *IndexersUpdateOne {
iuo.mutation.SetTvSearch(b)
return iuo
}
// SetNillableTvSearch sets the "tv_search" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableTvSearch(b *bool) *IndexersUpdateOne {
if b != nil {
iuo.SetTvSearch(*b)
}
return iuo
}
// ClearTvSearch clears the value of the "tv_search" field.
func (iuo *IndexersUpdateOne) ClearTvSearch() *IndexersUpdateOne {
iuo.mutation.ClearTvSearch()
return iuo
}
// SetMovieSearch sets the "movie_search" field.
func (iuo *IndexersUpdateOne) SetMovieSearch(b bool) *IndexersUpdateOne {
iuo.mutation.SetMovieSearch(b)
return iuo
}
// SetNillableMovieSearch sets the "movie_search" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableMovieSearch(b *bool) *IndexersUpdateOne {
if b != nil {
iuo.SetMovieSearch(*b)
}
return iuo
}
// ClearMovieSearch clears the value of the "movie_search" field.
func (iuo *IndexersUpdateOne) ClearMovieSearch() *IndexersUpdateOne {
iuo.mutation.ClearMovieSearch()
return iuo
}
// SetAPIKey sets the "api_key" field.
func (iuo *IndexersUpdateOne) SetAPIKey(s string) *IndexersUpdateOne {
iuo.mutation.SetAPIKey(s)
return iuo
}
// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableAPIKey(s *string) *IndexersUpdateOne {
if s != nil {
iuo.SetAPIKey(*s)
}
return iuo
}
// ClearAPIKey clears the value of the "api_key" field.
func (iuo *IndexersUpdateOne) ClearAPIKey() *IndexersUpdateOne {
iuo.mutation.ClearAPIKey()
return iuo
}
// SetURL sets the "url" field.
func (iuo *IndexersUpdateOne) SetURL(s string) *IndexersUpdateOne {
iuo.mutation.SetURL(s)
return iuo
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableURL(s *string) *IndexersUpdateOne {
if s != nil {
iuo.SetURL(*s)
}
return iuo
}
// ClearURL clears the value of the "url" field.
func (iuo *IndexersUpdateOne) ClearURL() *IndexersUpdateOne {
iuo.mutation.ClearURL()
return iuo
}
// SetSynced sets the "synced" field.
func (iuo *IndexersUpdateOne) SetSynced(b bool) *IndexersUpdateOne {
iuo.mutation.SetSynced(b)
return iuo
}
// SetNillableSynced sets the "synced" field if the given value is not nil.
func (iuo *IndexersUpdateOne) SetNillableSynced(b *bool) *IndexersUpdateOne {
if b != nil {
iuo.SetSynced(*b)
}
return iuo
}
// ClearSynced clears the value of the "synced" field.
func (iuo *IndexersUpdateOne) ClearSynced() *IndexersUpdateOne {
iuo.mutation.ClearSynced()
return iuo
}
// Mutation returns the IndexersMutation object of the builder.
func (iuo *IndexersUpdateOne) Mutation() *IndexersMutation {
return iuo.mutation
@@ -305,7 +675,20 @@ func (iuo *IndexersUpdateOne) ExecX(ctx context.Context) {
}
}
// check runs all checks and user-defined validators on the builder.
func (iuo *IndexersUpdateOne) check() error {
if v, ok := iuo.mutation.Priority(); ok {
if err := indexers.PriorityValidator(v); err != nil {
return &ValidationError{Name: "priority", err: fmt.Errorf(`ent: validator failed for field "Indexers.priority": %w`, err)}
}
}
return nil
}
func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err error) {
if err := iuo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(indexers.Table, indexers.Columns, sqlgraph.NewFieldSpec(indexers.FieldID, field.TypeInt))
id, ok := iuo.mutation.ID()
if !ok {
@@ -340,6 +723,9 @@ func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err
if value, ok := iuo.mutation.Settings(); ok {
_spec.SetField(indexers.FieldSettings, field.TypeString, value)
}
if iuo.mutation.SettingsCleared() {
_spec.ClearField(indexers.FieldSettings, field.TypeString)
}
if value, ok := iuo.mutation.EnableRss(); ok {
_spec.SetField(indexers.FieldEnableRss, field.TypeBool, value)
}
@@ -349,6 +735,54 @@ func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err
if value, ok := iuo.mutation.AddedPriority(); ok {
_spec.AddField(indexers.FieldPriority, field.TypeInt, value)
}
if value, ok := iuo.mutation.SeedRatio(); ok {
_spec.SetField(indexers.FieldSeedRatio, field.TypeFloat32, value)
}
if value, ok := iuo.mutation.AddedSeedRatio(); ok {
_spec.AddField(indexers.FieldSeedRatio, field.TypeFloat32, value)
}
if iuo.mutation.SeedRatioCleared() {
_spec.ClearField(indexers.FieldSeedRatio, field.TypeFloat32)
}
if value, ok := iuo.mutation.Disabled(); ok {
_spec.SetField(indexers.FieldDisabled, field.TypeBool, value)
}
if iuo.mutation.DisabledCleared() {
_spec.ClearField(indexers.FieldDisabled, field.TypeBool)
}
if value, ok := iuo.mutation.TvSearch(); ok {
_spec.SetField(indexers.FieldTvSearch, field.TypeBool, value)
}
if iuo.mutation.TvSearchCleared() {
_spec.ClearField(indexers.FieldTvSearch, field.TypeBool)
}
if value, ok := iuo.mutation.MovieSearch(); ok {
_spec.SetField(indexers.FieldMovieSearch, field.TypeBool, value)
}
if iuo.mutation.MovieSearchCleared() {
_spec.ClearField(indexers.FieldMovieSearch, field.TypeBool)
}
if value, ok := iuo.mutation.APIKey(); ok {
_spec.SetField(indexers.FieldAPIKey, field.TypeString, value)
}
if iuo.mutation.APIKeyCleared() {
_spec.ClearField(indexers.FieldAPIKey, field.TypeString)
}
if value, ok := iuo.mutation.URL(); ok {
_spec.SetField(indexers.FieldURL, field.TypeString, value)
}
if iuo.mutation.URLCleared() {
_spec.ClearField(indexers.FieldURL, field.TypeString)
}
if value, ok := iuo.mutation.Synced(); ok {
_spec.SetField(indexers.FieldSynced, field.TypeBool, value)
}
if iuo.mutation.SyncedCleared() {
_spec.ClearField(indexers.FieldSynced, field.TypeBool)
}
if iuo.mutation.CreateTimeCleared() {
_spec.ClearField(indexers.FieldCreateTime, field.TypeTime)
}
_node = &Indexers{config: iuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues

Some files were not shown because too many files have changed in this diff Show More