Compare commits

..

550 Commits

Author SHA1 Message Date
IRHM b21d2bf603 Plex: Move auth tokens to new UserServices table and get local auth tokens 2024-03-17 17:04:10 +00:00
IRHM 0667f33250 plex sync: dont parse lastViewedAt for seasons/episodes if not set 2024-03-16 23:37:44 +00:00
IRHM 0da264480c plex auth: update auth token on login
hm mite save twice on creation
2024-03-16 23:23:39 +00:00
IRHM 622d10e743 Plex sync seasons and episodes 2024-03-16 23:18:32 +00:00
IRHM 7c216f4691 Plex sync movies and shows
Based on #401 - Seemed easier to port the relevant changes with some modifications than to fix merge conflicts and mess with history.

Co-Authored-By: stephaje <57157278+stephaje@users.noreply.github.com>
2024-03-16 22:26:01 +00:00
dependabot[bot] b5f9700345 ui: bump @typescript-eslint/eslint-plugin from 7.0.2 to 7.2.0 (#407)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 7.0.2 to 7.2.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v7.2.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-12 19:59:37 +00:00
Mr 7e03557e56 README: Add matrix chat badge to top and text in getting help section 2024-03-11 21:08:23 +00:00
dependabot[bot] 10a79a31cd server: bump github.com/gin-contrib/cors from 1.5.0 to 1.7.0 in /server (#403)
Bumps [github.com/gin-contrib/cors](https://github.com/gin-contrib/cors) from 1.5.0 to 1.7.0.
- [Release notes](https://github.com/gin-contrib/cors/releases)
- [Changelog](https://github.com/gin-contrib/cors/blob/master/.goreleaser.yaml)
- [Commits](https://github.com/gin-contrib/cors/compare/v1.5.0...v1.7.0)

---
updated-dependencies:
- dependency-name: github.com/gin-contrib/cors
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-11 20:28:42 +00:00
dependabot[bot] e41d408cd0 ui: bump eslint from 8.56.0 to 8.57.0 (#378)
Bumps [eslint](https://github.com/eslint/eslint) from 8.56.0 to 8.57.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.56.0...v8.57.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-11 20:27:40 +00:00
dependabot[bot] 6b22b4a4e2 server: bump golang.org/x/crypto from 0.19.0 to 0.21.0 in /server (#393)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.19.0 to 0.21.0.
- [Commits](https://github.com/golang/crypto/compare/v0.19.0...v0.21.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-11 20:26:52 +00:00
dependabot[bot] 67c3083edd server: bump github.com/golang-jwt/jwt/v5 from 5.2.0 to 5.2.1 in /server (#404)
Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.2.0 to 5.2.1.
- [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.0...v5.2.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-11 20:26:25 +00:00
dependabot[bot] e968b7ff28 ui: bump @typescript-eslint/parser from 7.0.2 to 7.2.0 (#406)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 7.0.2 to 7.2.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v7.2.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-11 20:25:39 +00:00
dependabot[bot] adfd983a68 ui: bump @sveltejs/kit from 2.5.0 to 2.5.3 (#405)
Bumps [@sveltejs/kit](https://github.com/sveltejs/kit/tree/HEAD/packages/kit) from 2.5.0 to 2.5.3.
- [Release notes](https://github.com/sveltejs/kit/releases)
- [Changelog](https://github.com/sveltejs/kit/blob/main/packages/kit/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/kit@2.5.3/packages/kit)

---
updated-dependencies:
- dependency-name: "@sveltejs/kit"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-11 20:25:08 +00:00
dependabot[bot] b32ba86c5d ui: bump vite from 5.1.3 to 5.1.6 (#408)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.3 to 5.1.6.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.1.6/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-11 20:23:57 +00:00
Mr ebb0b132bd plex auth improvements (#402)
- Our own auth flow, removed 'plex-oauth' dep.
- Fixed normal registrations
- Combined login/register plex methods
- Changed login page plex btn styling
- Reverted colors on jellyfin/plex btns (couldn't find a nice one and it hurt me)
- Removed plex client id from server config, replaced by plex host and plex machine id config items
- Plex client id is generated on the client and stored for reuse, each client will do that instead of the server storing it for everyone.
- Use plex machine id to ensure only approved users can login via plex (users with access to host server library)
- Renamed some structs and funcs
- Removed background from plex icon
- Made buttons and inputs bigger (more padding, also unrelated to rest of changed but i think it looks nice)
2024-03-11 03:21:03 +00:00
stephaje 4f1fbf4a45 Plex Auth (#387) 2024-03-10 00:49:04 +00:00
IRHM 74f896a8bc docs: Fix viewjs css not loading in build 2024-03-09 03:42:22 +00:00
IRHM 3b1d42c148 docs: Screenshots (+ viewerjs for viewing them closer), demo link in nav 2024-03-09 01:55:06 +00:00
IRHM 7a902212a5 v1.35.2 2024-03-07 11:24:34 +00:00
IRHM 2a718ef6d8 #400 Fix signup_enabled default config value
Set defaults when generating config so they are stored in the json file.
2024-03-07 11:23:56 +00:00
IRHM f71dc287bd v1.35.1 2024-03-06 23:29:06 +00:00
IRHM 77d2c6f49a 1.35.1-dev 2024-03-06 23:10:29 +00:00
Mr 3eb454cc93 Config: Don't omit SIGNUP_ENABLED when empty (#399)
Was being removed from config when set to false, then once the server restarts would be set back to default value (true).

Now is kept in config with value of false when turned off.
2024-03-06 22:40:50 +00:00
Mr 8a5fd8182f Add restart property to docker-compose example (#398)
* #390

and update docker-compose file in proj root to match one in docs

* docker-compose.yml: fix port

i changed this :(
2024-03-06 22:31:47 +00:00
IRHM aa7a38b2ee v1.35.0 2024-03-05 20:50:09 +00:00
IRHM ed7a780c44 1.35.0-dev 2024-03-05 18:57:19 +00:00
Mr 32f72f382e Merge pull request #395 from sbondCo/jellyfin-sync
Jellyfin sync improvements
2024-03-05 18:20:34 +00:00
IRHM 2e0ea4d6c7 seasonAndEpToReadable: Remove padStart and fix showing season 0 as unknown
season 0 = specials, dont want to show 'unknown' in this case.
2024-03-05 17:54:23 +00:00
IRHM 2a9a3691a3 Jellyfin Sync: Add full_item debug log for episodes and seasons 2024-03-05 17:41:14 +00:00
IRHM 49692f5e02 Jellyfin Sync: Save episode/season watch dates
and change activity to show 'synced' instead of 'imported' for JF types
2024-03-05 17:38:44 +00:00
Mr 5f06e7b52f Merge pull request #394 from sbondCo/jellyfin-sync
Jellyfin (Manual) Sync
2024-03-05 01:04:19 +00:00
IRHM 1933ca350d jobs: Remove job after 1m of status being set to done 2024-03-05 01:03:00 +00:00
IRHM 337957fb9f Jellyfin Sync: _JF activity types
Not doing anything with them now, but later we can add to the UI (maybe jf icon if _JF activity variant)
2024-03-05 00:33:52 +00:00
IRHM 458c91d505 Jellyfin Sync: Don't add imported date activity if movie already on list 2024-03-05 00:00:08 +00:00
IRHM 5498236b48 JellyfinSyncModal: Stop job watcher after 10 errors in a row 2024-03-04 23:49:45 +00:00
IRHM 0e7cdb0199 watched episodes/seasons: Don't add activity if we didn't update the status/rating 2024-03-04 20:35:55 +00:00
IRHM 7d25b0bf5d wip: jellyfin sync modal 2024-03-04 03:50:41 +00:00
IRHM ccadcf2152 wip: jellyfin sync 2024-03-03 22:53:05 +00:00
IRHM 8e0fb190d1 ui: bump @typescript-eslint (eslint-plugin and parser) to 7.0.2 2024-02-22 02:43:03 +00:00
dependabot[bot] 62033c66aa ui: bump svelte-check from 3.6.3 to 3.6.4 (#370)
Bumps [svelte-check](https://github.com/sveltejs/language-tools) from 3.6.3 to 3.6.4.
- [Release notes](https://github.com/sveltejs/language-tools/releases)
- [Commits](https://github.com/sveltejs/language-tools/compare/svelte-check-3.6.3...svelte-check-3.6.4)

---
updated-dependencies:
- dependency-name: svelte-check
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 02:36:12 +00:00
dependabot[bot] 95130fd4fb ui: bump prettier-plugin-svelte from 3.1.2 to 3.2.1 (#368)
Bumps [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte) from 3.1.2 to 3.2.1.
- [Changelog](https://github.com/sveltejs/prettier-plugin-svelte/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/prettier-plugin-svelte/compare/v3.1.2...v3.2.1)

---
updated-dependencies:
- dependency-name: prettier-plugin-svelte
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 02:35:54 +00:00
dependabot[bot] c4cebb717c ui: bump @typescript-eslint/eslint-plugin from 6.21.0 to 7.0.0 (#367)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.21.0 to 7.0.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v7.0.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 02:35:21 +00:00
dependabot[bot] d92dd51bc8 ui: bump vite from 5.0.12 to 5.1.3 (#369)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.12 to 5.1.3.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.1.3/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 02:34:55 +00:00
Mr 4e4f8f9fcf ActivityEditor: Accept any valid date (#372)
* Activity: Allow any valid date in editor, add try/catch to updateActivity method

* api: Update updateActivity log
2024-02-22 02:33:34 +00:00
Mr 11a0ec55d5 Merge pull request #366 from stephaje/Issue-#61
Issue #61 - Editing activity
2024-02-22 01:48:46 +00:00
John Stephani 14b3f38b5d Add client validation 2024-02-21 19:17:13 -06:00
stephaje 5799cd649b context => c 2024-02-19 12:44:11 -06:00
stephaje d4b873ec7d Clean up errors, CSS, fix tv/games activity 2024-02-18 23:26:31 -06:00
stephaje d00ae04074 Add user id checking; fix log/error messages 2024-02-18 14:00:07 -06:00
stephaje 8955ca7b26 npm run format 2024-02-18 10:52:17 -06:00
stephaje 82c6729a22 Issue #61 2024-02-18 10:47:16 -06:00
IRHM 1929272705 v1.34.0 2024-02-18 16:45:56 +00:00
IRHM 709dead520 1.34.0-dev 2024-02-18 16:21:40 +00:00
Mr 7cd348804c Merge pull request #365 from sbondCo/fix-discovery
Fix discovery (trending) requests
2024-02-18 16:20:25 +00:00
IRHM ba91f65cee #364 Fix discovery requests
Trailing / causing 404
2024-02-18 16:18:59 +00:00
Mr a09488dbba Merge pull request #363 from sbondCo/rate-episodes
Ratings and Statuses for episodes
2024-02-18 16:08:23 +00:00
IRHM 111b2b1afd getLatestWatchedInTv: Fix undefined check, should be looking for bigger than -1 2024-02-18 16:04:13 +00:00
IRHM c0ff3205a6 Include episode in watching season extra detail 2024-02-18 15:43:59 +00:00
IRHM 92815f6907 #42 Episode Ratings 2024-02-17 23:15:43 +00:00
dependabot[bot] d9257e767f server: bump gorm.io/driver/sqlite from 1.5.4 to 1.5.5 in /server (#353)
Bumps [gorm.io/driver/sqlite](https://github.com/go-gorm/sqlite) from 1.5.4 to 1.5.5.
- [Commits](https://github.com/go-gorm/sqlite/compare/v1.5.4...v1.5.5)

---
updated-dependencies:
- dependency-name: gorm.io/driver/sqlite
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-16 23:12:43 +00:00
dependabot[bot] 26ec0f592a server: bump golang.org/x/crypto from 0.18.0 to 0.19.0 in /server (#354)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.18.0 to 0.19.0.
- [Commits](https://github.com/golang/crypto/compare/v0.18.0...v0.19.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-16 23:11:09 +00:00
dependabot[bot] 1e4814d50a server: bump gorm.io/gorm from 1.25.6 to 1.25.7 in /server (#355)
Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.25.6 to 1.25.7.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/compare/v1.25.6...v1.25.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-16 23:10:49 +00:00
dependabot[bot] bbe2123c1e ui: bump prettier from 3.2.4 to 3.2.5 (#341)
Bumps [prettier](https://github.com/prettier/prettier) from 3.2.4 to 3.2.5.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.2.4...3.2.5)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-16 23:07:04 +00:00
dependabot[bot] d7c2897698 ui: bump @typescript-eslint/eslint-plugin from 6.20.0 to 6.21.0 (#338)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.20.0 to 6.21.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.21.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-16 23:05:45 +00:00
dependabot[bot] 8cd930369d ui: bump svelte from 4.2.8 to 4.2.10 (#337)
Bumps [svelte](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte) from 4.2.8 to 4.2.10.
- [Release notes](https://github.com/sveltejs/svelte/releases)
- [Changelog](https://github.com/sveltejs/svelte/blob/svelte@4.2.10/packages/svelte/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte/commits/svelte@4.2.10/packages/svelte)

---
updated-dependencies:
- dependency-name: svelte
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-16 23:04:47 +00:00
dependabot[bot] 4cea72d8e9 ui: bump axios from 1.6.5 to 1.6.7 (#339)
Bumps [axios](https://github.com/axios/axios) from 1.6.5 to 1.6.7.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.6.5...v1.6.7)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-16 23:04:13 +00:00
imgbot[bot] e9a4629c2a [ImgBot] Optimize images (#357)
*Total -- 936.02kb -> 774.21kb (17.29%)

/doc/docs/server_config/img/twitch-register-app.png -- 80.15kb -> 58.27kb (27.29%)
/doc/docs/server_config/img/watcharr-settings-dropdown.png -- 8.20kb -> 6.11kb (25.44%)
/doc/docs/server_config/img/watcharr-twitch-config.png -- 34.31kb -> 26.69kb (22.2%)
/doc/docs/server_config/img/watcharr-twitch-service.png -- 10.34kb -> 8.17kb (21.04%)
/doc/docs/server_config/img/watcharr-game-details.png -- 803.03kb -> 674.97kb (15.95%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
2024-02-16 15:52:28 +00:00
Mr 3e02af9c40 README: Update description, adding video games. 2024-02-12 01:01:37 +00:00
IRHM 2a5a470347 v1.33.0 2024-02-12 00:33:07 +00:00
IRHM 07e3f5f7a8 1.33.0-dev 2024-02-11 23:44:07 +00:00
Mr 1b83c70b5e Merge pull request #344 from sbondCo/twitch-config-modal-doc-link
TwitchModal: Add link to setup docs.
2024-02-11 23:41:09 +00:00
IRHM 1e5cdc151b TwitchModal: Add link to setup docs. 2024-02-11 23:37:53 +00:00
Mr dcb21a6e1e Merge pull request #343 from sbondCo/game-docs
Game docs
2024-02-11 23:30:41 +00:00
IRHM 0b4f3d5c97 Create game setup guide
i just realised screenshots are in dark mode, not matching the others in another guide, but it's too late to change em cuz what's done is done.
2024-02-11 23:29:14 +00:00
IRHM 0d8ea359e4 doc: Update docusaurus to v3 2024-02-11 22:41:51 +00:00
Mr 1c44b1812a Merge pull request #342 from sbondCo/games
Games
2024-02-11 21:56:58 +00:00
IRHM 3d5cf70ec0 FilterMenu: Change held to on hold 2024-02-10 20:26:35 +00:00
IRHM f1f26d0f57 Dockerfile: Copy game module 2024-02-10 19:54:18 +00:00
IRHM e3fe047afd follow: Fix get watched item logic for followed thoughts
Before it could get two entries if user has two entries that had same id number for content and game ids.
2024-02-10 17:50:10 +00:00
IRHM 4afc32f9d1 FilterMenu: Fix type styling 2024-02-10 17:49:10 +00:00
IRHM 7ea78f2d57 watched: preload game when getting public list 2024-02-10 17:31:10 +00:00
IRHM 6092410b20 Followed thoughts for games 2024-02-10 17:28:29 +00:00
IRHM 8f5293a769 Remove game filter if games disabled, update status filters for games 2024-02-10 16:48:25 +00:00
IRHM 6d25356d30 WatchedList: Fix type filtering 2024-02-10 16:18:14 +00:00
IRHM dbd86b89c7 FilterMenu: Add Game type 2024-02-10 16:18:07 +00:00
IRHM bf0b4fbb6a game: remove log of credentials 2024-02-10 15:56:35 +00:00
IRHM 5585053b85 igdb token refresh logic 2024-02-10 15:53:30 +00:00
IRHM a61b82e9af Search: Fix if games, catch search requests separately 2024-02-08 22:55:30 +00:00
IRHM d4fe6d3653 Search: Remove unused interface, remove comment 2024-02-08 22:45:30 +00:00
IRHM 6d2ab6e7e4 Search: Only search movies/tv if games disabled 2024-02-08 22:44:46 +00:00
IRHM c5e6ae702a Poster: Don't try loading image unless we have a poster path 2024-02-08 22:44:27 +00:00
IRHM 2a9b0443f5 Tv: Fix wListItem find 2024-02-08 00:10:55 +00:00
IRHM e1e933af16 Fix Status 2024-02-08 00:08:39 +00:00
IRHM a5fbecd32a Remove unneeded comments 2024-02-07 23:54:32 +00:00
IRHM 98006efb03 Games: Fix similar games having wrong status/rating 2024-02-07 23:49:11 +00:00
IRHM 926b0f8267 GamePoster: Use blurhash when available for poster loader 2024-02-07 23:46:59 +00:00
IRHM cc3f21aa93 Cache game covers 2024-02-07 22:47:16 +00:00
IRHM e311bcd901 Display status differently for games
Created toUnderstandableStatus and toUnderstandableWatchedStatus helpers to convert statuses into readable.
2024-02-06 23:56:49 +00:00
IRHM eb66baba80 Routes: Remove testing cache exp time for game routes 2024-02-03 21:41:26 +00:00
IRHM 09795b4da3 Game: Display similar games 2024-02-03 21:41:03 +00:00
IRHM 8088184e6b Create getPlayedDependedProps for searched game posters 2024-02-03 21:09:04 +00:00
IRHM 1b6c56dd8f sorta finalize gameposter on own watched list 2024-02-03 21:00:26 +00:00
IRHM 86195eb682 Game: Add check before trying to iterate over genres and modes
and show 'Unknown' message if we have none available
2024-02-03 20:38:12 +00:00
IRHM f40ffa124c GamePoster: Accept generic props so we can reuse on watched list 2024-02-03 20:38:12 +00:00
IRHM 704b6380c7 Game: Use cover if no artwork available for backdrop 2024-02-03 20:38:12 +00:00
IRHM b434665caf fix content undefined issues 2024-02-03 20:38:12 +00:00
IRHM 3554d4bc60 updating games watched item 2024-02-03 20:38:12 +00:00
IRHM 917ddd5401 fix profile stats
since Content pointer stored now
2024-02-03 20:38:12 +00:00
IRHM e7cf21fdb2 basic adding games to list 2024-02-03 20:33:52 +00:00
IRHM c932bd188a basic game detail page 2024-02-03 20:32:44 +00:00
IRHM e5d17bee81 game search ep 2024-02-03 20:31:45 +00:00
IRHM 65836a1654 idk if this works
bakup the beginnings of game support
2024-02-03 20:31:45 +00:00
IRHM 0f7bdaffbb v1.32.1 2024-02-03 15:16:09 +00:00
IRHM 30dae4c5c9 1.32.1-dev1 2024-02-03 14:57:28 +00:00
Mr f67d1641db Merge pull request #336 from sbondCo/awesome-stuff-too
Fix movary importing and include previously watched filter
2024-02-03 14:54:39 +00:00
IRHM 0ff02e00c9 WatchedList: Fix type filter when finished status enabled 2024-02-03 13:37:24 +00:00
IRHM 194081ac2f Profile: get profile stats again after updating includepreviouslywatched setting 2024-02-03 13:34:24 +00:00
IRHM 896f80ebd6 profile: Include previously watched in stats if enabled by user 2024-02-03 13:16:55 +00:00
IRHM 862279e914 import: Fix customDates being the same on all dateswatched activity
pointer value being updated each iteration, so we end up using same date for all object in the array
2024-02-03 12:51:17 +00:00
IRHM bdf5cf54af 1.32.1-dev 2024-02-03 02:53:16 +00:00
Mr 4323ab7086 Merge pull request #335 from sbondCo/amazing-stuff
https://github.com/sbondCo/Watcharr/issues/332#issuecomment-1923230972
2024-02-03 02:51:26 +00:00
IRHM 555b237ed0 WatchedList: Filter on sort change, add STATUS_CHANGED as activity that could make show watched 2024-02-03 02:37:58 +00:00
IRHM 5146af2672 Filtering: Add includePreviouslyWatched setting 2024-02-03 02:13:46 +00:00
IRHM 4d3da51ae7 Movary Import: Keep history data if show is also on watchlist 2024-02-02 21:35:54 +00:00
IRHM 9cba877fe6 Movary Import: Set latest watched date as watched entry CreatedAt 2024-02-02 21:21:21 +00:00
IRHM 924ffcb33f v1.32.0 2024-02-02 02:24:50 +00:00
IRHM b638062d36 1.32.0-dev 2024-02-02 01:47:20 +00:00
dependabot[bot] da64b5ca59 ui: bump svelte-check from 3.6.2 to 3.6.3 (#317)
Bumps [svelte-check](https://github.com/sveltejs/language-tools) from 3.6.2 to 3.6.3.
- [Release notes](https://github.com/sveltejs/language-tools/releases)
- [Commits](https://github.com/sveltejs/language-tools/compare/svelte-check-3.6.2...svelte-check-3.6.3)

---
updated-dependencies:
- dependency-name: svelte-check
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-02 01:30:51 +00:00
dependabot[bot] 8f2d9b0984 ui: bump @typescript-eslint/parser from 6.18.0 to 6.20.0 (#328)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.18.0 to 6.20.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.20.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-02 01:30:34 +00:00
dependabot[bot] c2e85ff8b3 server: bump gorm.io/gorm from 1.25.5 to 1.25.6 in /server (#327)
Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.25.5 to 1.25.6.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/compare/v1.25.5...v1.25.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-02 01:29:18 +00:00
dependabot[bot] 3c9d074169 ui: bump @typescript-eslint/eslint-plugin from 6.18.0 to 6.20.0 (#330)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.18.0 to 6.20.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.20.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-02 01:28:38 +00:00
dependabot[bot] 7a254222a1 ui: bump @sveltejs/adapter-node from 2.0.2 to 4.0.1 (#331)
Bumps [@sveltejs/adapter-node](https://github.com/sveltejs/kit/tree/HEAD/packages/adapter-node) from 2.0.2 to 4.0.1.
- [Release notes](https://github.com/sveltejs/kit/releases)
- [Changelog](https://github.com/sveltejs/kit/blob/main/packages/adapter-node/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/adapter-node@4.0.1/packages/adapter-node)

---
updated-dependencies:
- dependency-name: "@sveltejs/adapter-node"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-02 01:26:35 +00:00
dependabot[bot] 4662977677 ui: bump prettier from 3.1.1 to 3.2.4 (#322)
Bumps [prettier](https://github.com/prettier/prettier) from 3.1.1 to 3.2.4.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.1.1...3.2.4)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-02 01:25:01 +00:00
dependabot[bot] 798c80f69b ui: bump vite from 5.0.11 to 5.0.12 (#320)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.11 to 5.0.12.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.0.12/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.0.12/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-02 01:24:29 +00:00
Mr d8e4182824 Merge pull request #334 from sbondCo/movary-import
Movary Importing
2024-02-02 01:21:49 +00:00
IRHM ac9fb8c28d import/process: Update importText for TMDb to TMDB 2024-02-02 01:11:32 +00:00
IRHM d0b1b9ed17 import: add error to sucimp log 2024-02-02 00:56:16 +00:00
IRHM 548643327d Support importing status, thoughts and datesWatched
for movary import
2024-02-02 00:45:36 +00:00
IRHM a86d2a218a wip build movary import list 2024-02-02 00:18:41 +00:00
IRHM 21ecc4cbbf wip movary importing from the 3 export files 2024-02-01 01:32:01 +00:00
Mr 2e19cad3a8 Merge pull request #314 from sbondCo/update-cache-on-req
Update content table on request
2024-01-13 22:47:48 +00:00
IRHM 8bffc7380e saveContent: remove test log and debug on Updates
and update its error handling, copied from below, removed case not needed for updating... or even that code anymore but whatevz
2024-01-13 22:44:02 +00:00
IRHM 96720caace saveContent: Support onlyUpdate parameter 2024-01-13 17:40:33 +00:00
IRHM 6c130952d7 update cache when content is freshly fetched 2024-01-11 02:29:46 +00:00
IRHM 3c1fc0e950 split out content caching for reuse 2024-01-11 02:05:35 +00:00
IRHM d95990fc56 v1.31.1 2024-01-09 20:45:59 +00:00
dependabot[bot] 9d0a433121 Bump follow-redirects from 1.15.3 to 1.15.4 in /doc (#311)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-09 20:44:50 +00:00
Mr 2bd02439c2 Support ARM64 Arch (#310)
* dev workflow: Add arm64 platform build

in sequence because paralellising the jobs looks hard

* dev action: remove `dev` tag

I think it would be better to just refer to them with their sha256 instead + i dont like that when a `dev` image is built, the `dev` tag goes to top of list of tagged images

* Revert "dev action: remove `dev` tag"

This reverts commit 0179f616fa.

nevermind, that is not a thing.

* release action: add arm platform
2024-01-09 20:42:30 +00:00
dependabot[bot] 6a1fdd69e3 ui: bump @sveltejs/kit from 2.0.7 to 2.0.8 (#308)
Bumps [@sveltejs/kit](https://github.com/sveltejs/kit/tree/HEAD/packages/kit) from 2.0.7 to 2.0.8.
- [Release notes](https://github.com/sveltejs/kit/releases)
- [Changelog](https://github.com/sveltejs/kit/blob/main/packages/kit/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/kit@2.0.8/packages/kit)

---
updated-dependencies:
- dependency-name: "@sveltejs/kit"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-08 20:35:40 +00:00
dependabot[bot] fb7dc5d0f8 ui: bump axios from 1.6.3 to 1.6.5 (#304)
Bumps [axios](https://github.com/axios/axios) from 1.6.3 to 1.6.5.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.6.3...v1.6.5)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-08 20:34:12 +00:00
dependabot[bot] c3d480d47b ui: bump @sveltejs/kit from 2.0.6 to 2.0.7 (#305)
Bumps [@sveltejs/kit](https://github.com/sveltejs/kit/tree/HEAD/packages/kit) from 2.0.6 to 2.0.7.
- [Release notes](https://github.com/sveltejs/kit/releases)
- [Changelog](https://github.com/sveltejs/kit/blob/main/packages/kit/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/kit@2.0.7/packages/kit)

---
updated-dependencies:
- dependency-name: "@sveltejs/kit"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-08 20:33:39 +00:00
dependabot[bot] 274c97bcdd ui: bump @typescript-eslint/eslint-plugin from 6.17.0 to 6.18.0 (#306)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.17.0 to 6.18.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.18.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-08 20:33:20 +00:00
dependabot[bot] d6b5fc9cd3 server: bump golang.org/x/crypto from 0.17.0 to 0.18.0 in /server (#303)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.17.0 to 0.18.0.
- [Commits](https://github.com/golang/crypto/compare/v0.17.0...v0.18.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-08 20:32:51 +00:00
dependabot[bot] 4de9865a39 ui: bump vite from 5.0.10 to 5.0.11 (#307)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.10 to 5.0.11.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.0.11/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-08 20:32:22 +00:00
Mr d278f2cf98 Merge pull request #302 from sbondCo/watchtime
Watchtime Profile Stat
2024-01-07 23:41:21 +00:00
IRHM 5aec83c2f0 Profile: Badly implement show watchtime
for now... hopefully
2024-01-07 23:36:56 +00:00
IRHM fbda3d4b9b Stat: Add disclaimer prop 2024-01-07 23:15:52 +00:00
IRHM dde8fad248 Profile: Implement movies watched runtime stat 2024-01-07 21:52:26 +00:00
IRHM e8309568bc v1.31.0 2024-01-07 17:50:51 +00:00
IRHM 997e3afb7e 1.31.0-dev 2024-01-07 01:07:39 +00:00
Mr 891fc51bcd Input changed validation (#299)
* thoughts change validation

* Rating & Status change validation

* Poster: status change validation
2024-01-07 01:04:00 +00:00
dependabot[bot] ebe42f1d34 ui: bump @typescript-eslint/parser from 6.16.0 to 6.18.0 (#298)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.16.0 to 6.18.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.18.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-06 18:43:04 +00:00
Mr b799c660ca Merge pull request #294 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-6.17.0
ui: bump @typescript-eslint/eslint-plugin from 6.16.0 to 6.17.0
2024-01-06 18:41:14 +00:00
Mr a10f570983 Merge pull request #293 from sbondCo/dependabot/npm_and_yarn/axios-1.6.3
ui: bump axios from 1.6.2 to 1.6.3
2024-01-06 18:40:51 +00:00
Mr f205f96010 Merge pull request #297 from sbondCo/detail-view
Detail view
2024-01-06 18:39:49 +00:00
IRHM 735a98e0b2 Poster: Make extra details box more opaque
and use same color for both themes
2024-01-06 17:45:47 +00:00
IRHM f87aa70a3b Poster: fix extra details colors and spacing 2024-01-06 17:41:13 +00:00
IRHM a2dc418ee6 Poster: Hide empty extra-details 2024-01-05 19:35:39 +00:00
IRHM 4c7982f7be improve getLatestWatchedSeason
it could be improved more though
2024-01-05 06:17:41 +00:00
IRHM 43d603c212 Detailed Poster: Use real data 2024-01-05 05:39:49 +00:00
IRHM ebf623ed1b Redesign poster extra details and allow configuring displayed data 2024-01-05 04:53:00 +00:00
IRHM d925519beb Create DetailedPoster 2024-01-03 23:13:38 +00:00
dependabot[bot] 07b72452e8 ui: bump @typescript-eslint/eslint-plugin from 6.16.0 to 6.17.0
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.16.0 to 6.17.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.17.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-01 19:22:43 +00:00
dependabot[bot] ab4781bec0 ui: bump axios from 1.6.2 to 1.6.3
Bumps [axios](https://github.com/axios/axios) from 1.6.2 to 1.6.3.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.6.2...v1.6.3)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-01 19:21:56 +00:00
IRHM 7719b6336c v1.30.0 2024-01-01 02:50:19 +00:00
IRHM e749e94bfb 1.30.0-dev 2023-12-31 20:23:17 +00:00
IRHM c1ceb17ada Rating: Fix text not updating if network request resolves after we hoverEnd 2023-12-31 20:18:39 +00:00
IRHM 91dd00b556 routes: Set AuthRequired middleware once for auth routes that require it
indenting authd routes definitely helps with readability
2023-12-30 17:37:59 +00:00
Mr 60e873b4c0 Merge pull request #292 from sbondCo/content-stars-text
Content rating text follow hovered star
2023-12-30 05:02:28 +00:00
IRHM 4333591c9c Rating: Add transition to transform
to make it smoother when moving to initial close rating to default middle pos.
2023-12-30 04:53:10 +00:00
IRHM 462a46aabb Rating: Fix causing page overflow on small viewports 2023-12-30 04:52:15 +00:00
IRHM c766d68d49 Rating: Center desc text and make it follow hovered star 2023-12-29 03:04:56 +00:00
Mr 6b7c38aa7a Merge pull request #291 from sbondCo/exportwl
Export Watched List
2023-12-29 02:08:48 +00:00
IRHM 367c79f29c Change empty watch list error text 2023-12-29 02:07:35 +00:00
IRHM c59eb82a1a dont try saving an empty watch list 2023-12-29 02:03:46 +00:00
IRHM 3d40e5554f change suggested export name to watcharr-export.json 2023-12-29 01:58:49 +00:00
IRHM 75f091cfa0 Basic exporting watched list support 2023-12-29 01:55:07 +00:00
Mr 1d0abe4982 Merge pull request #290 from iamericfletcher/user-password-change-issue-279
Implement Change Password Feature (Issue #279)
2023-12-28 22:24:01 +00:00
Mr f8490481a5 Merge branch 'dev' into user-password-change-issue-279 2023-12-28 22:16:54 +00:00
IRHM 1adc56f965 userChangePassword: Select only pass from db 2023-12-28 22:12:50 +00:00
IRHM 8861233aaa Move GetPassArgonParams, Remove DEBUG, add use of ternary operator 2023-12-28 22:01:58 +00:00
iamericfletcher 3c4718bc45 Update error handling in changeUserPassword and display of error messages in pwChangeModal
The 'changeUserPassword' callback is updated such that error messages are passed back to the calling function in `PwChangeModal` allowing errors to show up in the same place.
2023-12-28 16:19:31 -05:00
iamericfletcher f6fa9e7666 Refactor ArgonParams to a function for register and userChangePassword in auth.go 2023-12-28 15:37:11 -05:00
iamericfletcher 98a7c370a8 Removed unneeded else branches in auth.go 2023-12-28 14:59:57 -05:00
iamericfletcher 37f9bffb13 Move server endpoint to /auth/change_password and update corresponding frontend API call 2023-12-28 14:52:19 -05:00
iamericfletcher a4573fe52a Move userChangePassword function to auth.go 2023-12-28 14:40:35 -05:00
iamericfletcher aeaaccda88 Remove Form.svelte and related import
Form.svelte was deleted due to not being used or needed. An associated import line in PwChangeModal.svelte has also been removed.

Additionally, setting parameter DEBUG was removed from server/config.go.
2023-12-27 17:48:18 -05:00
iamericfletcher 3a2ce0c718 Refactor password change feature and update debug messages
Removed a substantial block of commented-out code related to password changing in the `user.go` file, which simplifies the structure and readability of the code. Improved clarity and specificity of console debug/feedback messages throughout the frontend, ensuring easier debugging. Commit also includes minor code clean up in some files.
2023-12-27 17:24:05 -05:00
iamericfletcher 2ac80d0b8c Refine password change error handling and reporting
The commit delivers improved error handling and debugging information for password change functionality. Error messages now provide more detailed context on failures. Additionally, new password hashing has been added in the password change process. The user interface has also been updated to reflect specific error messages returned from the API.
2023-12-27 14:14:53 -05:00
iamericfletcher 3ff5d9836b Refactor user password change functionality
The password change function now involves first querying user data from the database, before checking the validity of their old password. Logic has been updated on both frontend and backend code. Errors have been added for handling instances where password comparison, user retrieval or other processes fail.
2023-12-27 10:08:06 -05:00
iamericfletcher e6d486c2a2 Implement password change feature
A new feature has been added that allows users to change their password. This includes updates in several different files to accommodate this new functionality. Changes include adding a new API endpoint, creating a new function to handle the password change request, and removing the username field from the ChangePasswordForm interface.
2023-12-26 20:43:11 -05:00
iamericfletcher c4e591e2f2 Improve form validation in PwChangeModal.svelte
Updated form validation to check for missing inputs and ensure consistency between new password and re-entered new password. Enhanced logging for better status tracking and error reporting during form validation process.
2023-12-26 12:36:32 -05:00
iamericfletcher 0eb1a88103 Refactoring password button in PwChangeModal to be in line with button in SonarrModal 2023-12-26 11:58:47 -05:00
IRHM ffe6afe2d2 v1.29.0 2023-12-26 14:46:15 +00:00
iamericfletcher c767572905 Refactoring password change modal form 2023-12-26 09:36:24 -05:00
IRHM da803220e4 1.29.0-dev1 2023-12-26 14:23:57 +00:00
IRHM 5c4f023fd8 FollowedThoughts: Fix dark theme status icon fill 2023-12-26 14:23:31 +00:00
IRHM 7e2e64f394 1.29.0-dev 2023-12-26 14:14:07 +00:00
dependabot[bot] 9609909122 ui: bump @typescript-eslint/eslint-plugin from 6.13.0 to 6.16.0 (#285)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.13.0 to 6.16.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.16.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-26 14:09:02 +00:00
dependabot[bot] 7522784f18 ui: bump @typescript-eslint/parser from 6.15.0 to 6.16.0 (#284)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.15.0 to 6.16.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.16.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-26 14:07:09 +00:00
dependabot[bot] 8d5379e38b ui: bump svelte-preprocess from 5.1.1 to 5.1.3 (#283)
Bumps [svelte-preprocess](https://github.com/sveltejs/svelte-preprocess) from 5.1.1 to 5.1.3.
- [Changelog](https://github.com/sveltejs/svelte-preprocess/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte-preprocess/compare/v5.1.1...v5.1.3)

---
updated-dependencies:
- dependency-name: svelte-preprocess
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-26 14:06:43 +00:00
dependabot[bot] 8065349a5c ui: bump eslint from 8.55.0 to 8.56.0 (#286)
Bumps [eslint](https://github.com/eslint/eslint) from 8.55.0 to 8.56.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.55.0...v8.56.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-26 14:04:50 +00:00
dependabot[bot] 26c84ae7c7 ui: bump prettier from 3.1.0 to 3.1.1 (#287)
Bumps [prettier](https://github.com/prettier/prettier) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.1.0...3.1.1)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-26 14:04:07 +00:00
Mr f190bffdd0 Merge pull request #288 from sbondCo/public-thoughts
Public thoughts
2023-12-26 06:36:08 +00:00
IRHM e0f8d753bf follow: remove debug log 2023-12-26 06:27:22 +00:00
IRHM b6223c7ac8 FollowedThoughts: Ensure status icon is always the same size 2023-12-26 06:08:12 +00:00
IRHM ffd8bbe442 expose new privateThoughts setting to user 2023-12-26 05:45:54 +00:00
IRHM bc86b8f6b4 FollowedThoughts: Add extra space between status and rating 2023-12-26 05:26:12 +00:00
IRHM 0cb5c01b5e FollowedThoughts: Add status icon to cards 2023-12-26 05:22:39 +00:00
IRHM 0393966ecc getting and showing followed thoughts on content
Show followed users rating and thoughts on content
2023-12-26 05:04:41 +00:00
iamericfletcher b3ba00cd0d Added beginning stages of password change functionality in user profile
A new interface ChangePasswordForm has been created to handle password change form data.

The 'PwChangeModal.svelte' modal allows the user to input current and new passwords for a change password request.

The user profile page has been updated to include a "Change Password" button which triggers the change password modal.
2023-12-25 21:39:54 -05:00
Mr 5084a5b724 Merge pull request #281 from iamericfletcher/feature-sort-filter-watched-lists
Enhancement: Allow filtering and sorting other watched lists #276
2023-12-24 23:43:30 +00:00
iamericfletcher 43a484f949 Remove unused 'watchedListErrorOccurred' 2023-12-24 12:59:11 -05:00
iamericfletcher 8434e852ce Enhancement: Allow filtering and sorting other watched lists #276
Added a new store variable 'watchedListErrorOccurred' set to true if `getPublicWatchedList()` promise errors.

The aim is that the filter and sort functionality only show if the watched list loads in successfully.
2023-12-24 09:02:35 -05:00
Mr e541dc5cdb Merge pull request #280 from sbondCo/fix-dupe-tmdbids
Fix content with same tmdb ids
2023-12-23 20:29:41 +00:00
IRHM 4a20819803 addWatched: Check content type when fetching 2023-12-23 20:23:22 +00:00
IRHM 9a568b9da7 add content type to .find of wListItem in content pages 2023-12-23 20:15:13 +00:00
dependabot[bot] 9176d97eee ui: bump @sveltejs/kit from 1.27.6 to 2.0.6 (#278)
* ui: bump @sveltejs/kit from 1.27.6 to 2.0.6

Bumps [@sveltejs/kit](https://github.com/sveltejs/kit/tree/HEAD/packages/kit) from 1.27.6 to 2.0.6.
- [Release notes](https://github.com/sveltejs/kit/releases)
- [Changelog](https://github.com/sveltejs/kit/blob/main/packages/kit/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/kit@2.0.6/packages/kit)

---
updated-dependencies:
- dependency-name: "@sveltejs/kit"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* update @sveltejs/adapter-node, @vite-pwa/sveltekit, vite

to fix peer dep issues

* import vitePreprocess from @sveltejs/vite-plugin-svelte

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: IRHM <37304121+IRHM@users.noreply.github.com>
2023-12-23 16:26:06 +00:00
dependabot[bot] 1cbc065b7b ui: bump eslint-plugin-svelte from 2.35.0 to 2.35.1 (#263)
Bumps [eslint-plugin-svelte](https://github.com/sveltejs/eslint-plugin-svelte) from 2.35.0 to 2.35.1.
- [Release notes](https://github.com/sveltejs/eslint-plugin-svelte/releases)
- [Changelog](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/eslint-plugin-svelte/compare/v2.35.0...v2.35.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-svelte
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-23 15:55:52 +00:00
dependabot[bot] b4865aa789 ui: bump prettier-plugin-svelte from 3.0.3 to 3.1.2 (#262)
Bumps [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte) from 3.0.3 to 3.1.2.
- [Changelog](https://github.com/sveltejs/prettier-plugin-svelte/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/prettier-plugin-svelte/compare/v3.0.3...v3.1.2)

---
updated-dependencies:
- dependency-name: prettier-plugin-svelte
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-23 15:55:31 +00:00
dependabot[bot] 0c29927ef6 workflow: bump actions/setup-node from 3 to 4 (#271)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-23 15:54:54 +00:00
dependabot[bot] 75e499a070 ui: bump typescript from 5.3.2 to 5.3.3 (#264)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.3.2 to 5.3.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.3.2...v5.3.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-23 15:54:26 +00:00
dependabot[bot] fe589e7de5 workflow: bump actions/checkout from 3 to 4 (#272)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-23 15:50:41 +00:00
dependabot[bot] 9d7d6b0e3a ui: bump @typescript-eslint/parser from 6.13.1 to 6.15.0 (#274)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.13.1 to 6.15.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.15.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-23 15:49:00 +00:00
Mr 5fb720cca4 Merge pull request #275 from sbondCo/dependabot/go_modules/server/golang.org/x/crypto-0.17.0
server: bump golang.org/x/crypto from 0.16.0 to 0.17.0 in /server
2023-12-23 15:48:20 +00:00
Mr 2084b42098 Merge pull request #277 from sbondCo/fix-tooltips
Fix tooltips on scroll and from causing overflow on window resize
2023-12-23 15:43:52 +00:00
IRHM d26db7759f resetTooltipPos on window resize to fix overflow
resizing window smaller if tooltip is somewhere can cause overflow on page, reset its pos to top left on resize to avoid this.
2023-12-23 15:40:59 +00:00
IRHM 89311d4487 Revert "make tooltips fixed position"
This reverts commit 4d65a16584.
2023-12-23 15:36:29 +00:00
dependabot[bot] 72dca29d69 server: bump golang.org/x/crypto from 0.16.0 to 0.17.0 in /server
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.16.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.16.0...v0.17.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-18 19:50:49 +00:00
imgbot[bot] 36b3bde00e [ImgBot] Optimize images (#268)
*Total -- 5,368.58kb -> 4,578.90kb (14.71%)

/static/logo-sqre.png -- 10.43kb -> 4.68kb (55.15%)
/screenshot/user-profile.png -- 47.51kb -> 36.22kb (23.78%)
/screenshot/content-details-page-dark.png -- 523.03kb -> 429.56kb (17.87%)
/screenshot/content-details-page.png -- 370.65kb -> 304.62kb (17.81%)
/static/logo-sqre-144.png -- 6.43kb -> 5.39kb (16.28%)
/static/logo-sqre-192.png -- 8.61kb -> 7.24kb (15.97%)
/screenshot/homepage-poster-hover.png -- 877.03kb -> 751.92kb (14.27%)
/screenshot/homepage-poster-change-status.png -- 865.78kb -> 743.03kb (14.18%)
/screenshot/discover-page.png -- 765.65kb -> 660.56kb (13.73%)
/screenshot/homepage.png -- 945.27kb -> 816.18kb (13.66%)
/screenshot/homepage-dark.png -- 948.18kb -> 819.52kb (13.57%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
2023-12-10 17:34:04 +00:00
IRHM 425f0da422 v1.28.0 2023-12-10 03:02:38 +00:00
IRHM 6773736113 1.28.0-dev4 2023-12-10 02:57:23 +00:00
IRHM 51ec248b67 add short_name to pwa manifest 2023-12-10 02:57:00 +00:00
IRHM 702084c83c 1.28.0-dev3 2023-12-10 02:51:51 +00:00
IRHM 2aa5f0c4fa Add name, description, bg col and category to pwa manifest config
the lowercase name is too annoying, must have the capital W. Hopefully the bg colour can fix issues where the icon isn't scaled up, but white was shown so it looked odd. That may mask the issue.
2023-12-10 02:51:22 +00:00
IRHM 359f5a372a 1.28.0-dev2 2023-12-10 02:34:53 +00:00
Mr 03a8397498 Merge pull request #267 from sbondCo/new-pwa-icons
new icons for pwa
2023-12-10 02:34:02 +00:00
IRHM 034e6b10e7 new icons for pwa 2023-12-10 02:31:38 +00:00
IRHM 8100c5f9a9 1.28.0-dev1 2023-12-09 23:23:43 +00:00
Mr 95c8f2d5b0 Merge pull request #266 from sbondCo/prs
PR Template and test workflow
2023-12-09 23:15:35 +00:00
IRHM be29170f6d Create test-pr.yml
to check for formatting / linting errors
2023-12-09 23:12:59 +00:00
IRHM f02699b089 fix @html linting errors
the contents come from trusted sources so we should be okay
2023-12-09 23:08:37 +00:00
IRHM 82b7a3d0f6 fix css linting errors 2023-12-09 22:57:46 +00:00
IRHM 8608ad4fd6 format readme 2023-12-09 22:51:17 +00:00
IRHM ab96107797 Create PULL_REQUEST_TEMPLATE.md 2023-12-09 22:47:19 +00:00
Mr a38291c9b9 Merge pull request #260 from sbondCo/dokrfl
Fix dockerfile server build
2023-12-09 22:43:28 +00:00
IRHM 67cfd03a1d run formatter 2023-12-09 22:40:18 +00:00
IRHM c4fa99b5aa Fix dockerfile server build for musl
Workaround from gh issue seems to fix the issue of build failing
2023-12-09 22:28:22 +00:00
Mr 1d904a7188 Merge pull request #259 from ishaanparlikar/feature/pwa
Feature/pwa
2023-12-09 19:31:03 +00:00
ishaanparlikar be8cee5378 removed jsdoc type inference 2023-12-10 00:31:47 +05:30
ishaanparlikar 128a3d4cc6 removed workbox dependancy 2023-12-10 00:29:51 +05:30
ishaanparlikar 610fb3d0c0 fixed indentation 2023-12-09 12:06:59 +05:30
ishaanparlikar 2dd01f296b Feature: Added PWA support for Watcharr #225 2023-12-09 12:02:20 +05:30
Mr 6e118085a9 Merge pull request #258 from sbondCo/episode-overview
SeasonsListEpisode: Fix spoilers
2023-12-09 02:21:26 +00:00
IRHM 2f3400d4d7 SeasonsListEpisode: Fix spoilers 2023-12-09 02:20:53 +00:00
Mr da787741d8 Merge pull request #257 from sbondCo/episode-overview
Episode overview and runtime
2023-12-09 02:16:51 +00:00
IRHM 97bdf2f89c SeasonsListEpisode: Quick fix patch hack code and reimplement fix and repair the star position to fix it 2023-12-09 02:15:30 +00:00
IRHM a8c8431715 SeasonsListEpisode: Add episode runtimes 2023-12-09 02:11:15 +00:00
IRHM 18e3e333c6 SeasonsListEpisode: Add overviews 2023-12-09 02:01:29 +00:00
Mr f7ddb1e14b Merge pull request #255 from ishaanparlikar/fix/#217
Hiding rating when hide spoiler is checked in profile
2023-12-08 22:34:32 +00:00
ishaanparlikar e5c513161e Merge branch 'dev' of https://github.com/ishaanparlikar/Watcharr into dev 2023-12-08 21:49:27 +05:30
ishaanparlikar 55235839ff Hiding rating when hide spoiler is checked in profile 2023-12-08 21:41:21 +05:30
dependabot[bot] e5536c5429 ui: bump svelte-preprocess from 5.1.0 to 5.1.1 (#247)
Bumps [svelte-preprocess](https://github.com/sveltejs/svelte-preprocess) from 5.1.0 to 5.1.1.
- [Changelog](https://github.com/sveltejs/svelte-preprocess/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte-preprocess/compare/v5.1.0...v5.1.1)

---
updated-dependencies:
- dependency-name: svelte-preprocess
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-07 21:02:53 +00:00
dependabot[bot] 02fc0ccb94 ui: bump eslint-config-prettier from 9.0.0 to 9.1.0 (#248)
Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 9.0.0 to 9.1.0.
- [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-config-prettier/compare/v9.0.0...v9.1.0)

---
updated-dependencies:
- dependency-name: eslint-config-prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-07 21:00:25 +00:00
dependabot[bot] 83dcb85e5b server: bump github.com/golang-jwt/jwt/v5 from 5.1.0 to 5.2.0 in /server (#245)
Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.1.0 to 5.2.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.1.0...v5.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-07 21:00:05 +00:00
dependabot[bot] 155cd21b40 ui: bump svelte from 4.2.7 to 4.2.8 (#246)
Bumps [svelte](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte) from 4.2.7 to 4.2.8.
- [Release notes](https://github.com/sveltejs/svelte/releases)
- [Changelog](https://github.com/sveltejs/svelte/blob/svelte@4.2.8/packages/svelte/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte/commits/svelte@4.2.8/packages/svelte)

---
updated-dependencies:
- dependency-name: svelte
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-07 20:57:33 +00:00
dependabot[bot] f06da5b26e ui: bump eslint from 8.54.0 to 8.55.0 (#250)
Bumps [eslint](https://github.com/eslint/eslint) from 8.54.0 to 8.55.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.54.0...v8.55.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-07 20:48:14 +00:00
dependabot[bot] e00bfa0187 ui: bump vite from 4.5.0 to 4.5.1 (#251)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v4.5.1/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.5.1/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-07 20:45:08 +00:00
dependabot[bot] 4a008e4c2f ui: bump @types/papaparse from 5.3.11 to 5.3.14 (#249)
Bumps [@types/papaparse](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/papaparse) from 5.3.11 to 5.3.14.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/papaparse)

---
updated-dependencies:
- dependency-name: "@types/papaparse"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-07 20:35:37 +00:00
Mr 8c84fe29f9 Merge pull request #254 from sbondCo/fix-tooltip-overflow
Fix tooltip and nav overflow
2023-12-07 00:10:13 +00:00
IRHM 3bd03e4e97 nav: fix overflow and improve responsiveness 2023-12-07 00:08:14 +00:00
IRHM 4d65a16584 make tooltips fixed position
to stop overflowing when page resizes
2023-12-06 20:24:56 +00:00
Mr 21b4e49aa0 Merge pull request #253 from sbondCo/sort-indicators
Basic sort and filter indicators
2023-12-06 20:03:45 +00:00
IRHM 1bcc521d3a Basic sort and filter indicators 2023-12-06 20:01:49 +00:00
IRHM 9fa85e3191 v1.27.0 2023-12-03 23:49:12 +00:00
IRHM 55ff90a190 1.27.0-dev1 2023-12-03 23:38:51 +00:00
IRHM 2bf7639ecf fix user cards on dark theme 2023-12-03 23:38:06 +00:00
IRHM 2aabd94311 1.27.0-dev 2023-12-03 23:25:07 +00:00
Mr 17a61c0248 Posters - Use cached images on watched list (#243)
* upload avatar: add comment

* Poster: Use local cached image if show is on watched list
2023-12-03 15:41:12 +00:00
IRHM a17c7a4ce5 profile: update user state when bio updates 2023-12-03 15:28:45 +00:00
IRHM f31009fa5e list: fix profile data not updating 2023-12-03 15:28:45 +00:00
IRHM 559ac8945a fix name overflows not showing ellipsis 2023-12-03 15:28:45 +00:00
IRHM 1ce7f5a938 list: center user card
think it looks better like this
2023-12-03 15:28:45 +00:00
IRHM d634956d76 list: hide bio if not set and add gap to user-row 2023-12-03 15:28:45 +00:00
IRHM 3275ad6620 list: add title of full bio 2023-12-03 15:28:45 +00:00
IRHM 3ac9e94f89 list: fix bio and clamp to 2 lines
i dont care about the newlines anymore
2023-12-03 15:28:45 +00:00
IRHM 9562b3fef0 profile: fix and add notifs to post requests 2023-12-03 15:28:45 +00:00
IRHM ae95329d06 Show avatar/bio on user page, change follow btn to an icon 2023-12-03 15:28:45 +00:00
IRHM 1e81872876 move profile avatar to new UserAvatar component 2023-12-03 15:28:45 +00:00
IRHM 90eb422c9d fix user search and display proper errors 2023-12-03 15:28:45 +00:00
IRHM 3bfcb741f1 tasks: setup daily tasks interval 2023-12-03 15:28:45 +00:00
IRHM e04d72e565 images: cleanup: change debug to info logs 2023-12-03 15:28:45 +00:00
IRHM 99aa4e564a support bio 2023-12-03 15:28:45 +00:00
IRHM eac5c5a91e images: update comment 2023-12-03 15:28:45 +00:00
IRHM 82e9a4c0ea check file type is supported image 2023-12-03 15:28:45 +00:00
IRHM 4dd494dc80 profile: update user avatar when changed 2023-12-03 15:28:45 +00:00
IRHM 4422e83cd7 wip cleanup images task 2023-12-03 15:28:45 +00:00
IRHM eec6e00dac profile: remove canvas after image load
and remove z-indexes on img and canvas
2023-12-03 15:28:45 +00:00
IRHM 579736eb10 perform blurhash magic
probs wanna remove that canvas after img loads
2023-12-03 15:28:45 +00:00
IRHM 06fadeffa1 profile: show avatar 2023-12-03 15:28:45 +00:00
IRHM 97c87ecbf0 wip setting user avatar
uploading and setting working, need to display
2023-12-03 15:28:45 +00:00
Mr e55593d62b Nav: Hide buttons when searchbar is focused (#241) 2023-11-29 16:56:15 +00:00
dependabot[bot] 2a3b5c8746 server: bump github.com/gin-contrib/cors from 1.4.0 to 1.5.0 in /server (#232)
Bumps [github.com/gin-contrib/cors](https://github.com/gin-contrib/cors) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/gin-contrib/cors/releases)
- [Changelog](https://github.com/gin-contrib/cors/blob/master/.goreleaser.yaml)
- [Commits](https://github.com/gin-contrib/cors/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/gin-contrib/cors
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 14:04:04 +00:00
dependabot[bot] 52097df861 ui: bump prettier from 3.0.3 to 3.1.0 (#231)
Bumps [prettier](https://github.com/prettier/prettier) from 3.0.3 to 3.1.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.0.3...3.1.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 14:03:19 +00:00
dependabot[bot] 92637aef3d ui: bump axios from 1.6.1 to 1.6.2 (#230)
Bumps [axios](https://github.com/axios/axios) from 1.6.1 to 1.6.2.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.6.1...v1.6.2)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 14:02:53 +00:00
dependabot[bot] 02f537c5bf ui: bump svelte-check from 3.6.0 to 3.6.2 (#229)
Bumps [svelte-check](https://github.com/sveltejs/language-tools) from 3.6.0 to 3.6.2.
- [Release notes](https://github.com/sveltejs/language-tools/releases)
- [Commits](https://github.com/sveltejs/language-tools/compare/svelte-check-3.6.0...svelte-check-3.6.2)

---
updated-dependencies:
- dependency-name: svelte-check
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 14:02:08 +00:00
dependabot[bot] c63ab3cddf server: bump golang.org/x/crypto from 0.15.0 to 0.16.0 in /server (#233)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.15.0 to 0.16.0.
- [Commits](https://github.com/golang/crypto/compare/v0.15.0...v0.16.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 14:01:33 +00:00
dependabot[bot] cf7457a671 ui: bump @typescript-eslint/parser from 6.11.0 to 6.13.1 (#240)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.11.0 to 6.13.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.13.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 14:00:19 +00:00
dependabot[bot] 095cc21ea4 ui: bump @typescript-eslint/eslint-plugin from 6.11.0 to 6.13.0 (#227)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.11.0 to 6.13.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.13.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 13:57:56 +00:00
IRHM 983f4efa95 v1.26.0 2023-11-28 02:53:50 +00:00
IRHM 4573d69bbf 1.26.0-dev2 2023-11-28 02:45:19 +00:00
IRHM 07cbcb4d41 fix search page padding/margin 2023-11-28 02:44:44 +00:00
IRHM 71e31df2bf 1.26.0-dev1 2023-11-28 02:27:26 +00:00
IRHM f969c591c1 nav menus: fix themeing on arrow 2023-11-28 02:26:50 +00:00
IRHM 6d1e95ff5c 1.26.0-dev 2023-11-28 02:19:02 +00:00
Mr e7a6a888b1 watched: changed movie default status to FINISHED (#239)
* watched: changed movie default status to FINISHED

when adding content to list by rating instead of giving status.

* update comment
2023-11-28 02:16:19 +00:00
Mr ab9fdddc14 Merge pull request #234 from sbondCo/following
Following Users & Fix user lists posters
2023-11-28 02:02:52 +00:00
IRHM 6160e906df poster: fix interaction-disabled for user lists 2023-11-28 01:49:18 +00:00
IRHM dafac30df1 hide following tooltip if menu open 2023-11-26 19:32:45 +00:00
IRHM e98b6a383d style user page 2023-11-26 19:30:50 +00:00
IRHM 679168d88c unfollow, responsive height sub menus 2023-11-26 19:11:11 +00:00
IRHM 8679cdf0c6 tsconfig: include env.d.ts 2023-11-26 15:06:27 +00:00
IRHM 27e2e98ca3 move sort menu and filter menu to their own components 2023-11-26 13:40:28 +00:00
IRHM 3f90b2f0ca sub menu arrows to icon 2023-11-26 13:28:38 +00:00
IRHM dfa4e81dc2 basic following sub menu 2023-11-26 02:33:14 +00:00
IRHM 3d3bfa50bb wip get followers and add new following icon
also fix compass icon (not filled) and fix tooltips
2023-11-25 21:47:39 +00:00
IRHM f4a4b7c6d7 improve search resposiveness for large screens 2023-11-25 21:21:28 +00:00
IRHM db1b1bee65 wip follow routes 2023-11-25 14:32:19 +00:00
IRHM 53aa76f009 translate errors with gorm
and instead of using strings.Contains, we can compare to gorms error now
2023-11-25 14:31:50 +00:00
IRHM 24fe7f4984 create follows table 2023-11-25 13:31:39 +00:00
IRHM 99d9d4866a Cleanup search page and userslist
by cleanup i mean make look nicer
2023-11-21 20:43:50 +00:00
IRHM 7b0594a39b v1.25.0 2023-11-20 22:39:01 +00:00
IRHM 628dfef8d1 1.25.0-dev 2023-11-20 22:28:21 +00:00
Mr a3e305478b Merge pull request #219 from sbondCo/dependabot/npm_and_yarn/svelte-4.2.7
ui: bump svelte from 4.2.3 to 4.2.7
2023-11-20 22:22:20 +00:00
dependabot[bot] 0ca133f002 ui: bump svelte from 4.2.3 to 4.2.7
Bumps [svelte](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte) from 4.2.3 to 4.2.7.
- [Release notes](https://github.com/sveltejs/svelte/releases)
- [Changelog](https://github.com/sveltejs/svelte/blob/svelte@4.2.7/packages/svelte/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte/commits/svelte@4.2.7/packages/svelte)

---
updated-dependencies:
- dependency-name: svelte
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 22:21:30 +00:00
Mr 0586e91b31 Merge pull request #218 from sbondCo/dependabot/npm_and_yarn/svelte-check-3.6.0
ui: bump svelte-check from 3.5.2 to 3.6.0
2023-11-20 22:20:53 +00:00
Mr 3dbcc7b69f Merge pull request #220 from sbondCo/dependabot/npm_and_yarn/typescript-5.3.2
ui: bump typescript from 5.2.2 to 5.3.2
2023-11-20 22:19:33 +00:00
dependabot[bot] 784b6f2559 ui: bump typescript from 5.2.2 to 5.3.2
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.2.2 to 5.3.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.2.2...v5.3.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 22:18:57 +00:00
Mr d61711ace3 Merge pull request #221 from sbondCo/dependabot/npm_and_yarn/eslint-8.54.0
ui: bump eslint from 8.53.0 to 8.54.0
2023-11-20 22:18:41 +00:00
Mr c520cd6be0 Merge pull request #222 from sbondCo/dependabot/npm_and_yarn/sveltejs/kit-1.27.6
ui: bump @sveltejs/kit from 1.27.5 to 1.27.6
2023-11-20 22:18:14 +00:00
Mr 00a3b7041e Merge pull request #223 from sbondCo/tmdb-ratings
Import rating and rating date from TMDb, give activity customDate column
2023-11-20 22:17:25 +00:00
IRHM 6a69fbdab2 i forgot this is a pointer 2023-11-20 22:14:53 +00:00
IRHM deb30ebf03 import: only add IMPORTED_RATING activity if we have a customDate to use
otherwise this activity is useless and a duplicate of the normal IMPORTED activity
2023-11-20 22:13:08 +00:00
IRHM 985e5b3d39 Change imported rating activity text when there is no rating
to "added to watchlist with no rating"
2023-11-20 22:11:02 +00:00
IRHM 2b3dcd57d3 Show activity with customDate if set
also setup imported rating text - same as normal rating, but distinct so we have the ability to change it later if we want
2023-11-20 21:57:40 +00:00
dependabot[bot] 4200b03736 ui: bump @sveltejs/kit from 1.27.5 to 1.27.6
Bumps [@sveltejs/kit](https://github.com/sveltejs/kit/tree/HEAD/packages/kit) from 1.27.5 to 1.27.6.
- [Release notes](https://github.com/sveltejs/kit/releases)
- [Changelog](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/kit@1.27.6/packages/kit)

---
updated-dependencies:
- dependency-name: "@sveltejs/kit"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 19:57:56 +00:00
dependabot[bot] 7190a43604 ui: bump eslint from 8.53.0 to 8.54.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.53.0 to 8.54.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.53.0...v8.54.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 19:57:43 +00:00
dependabot[bot] 7c77d9c536 ui: bump svelte-check from 3.5.2 to 3.6.0
Bumps [svelte-check](https://github.com/sveltejs/language-tools) from 3.5.2 to 3.6.0.
- [Release notes](https://github.com/sveltejs/language-tools/releases)
- [Commits](https://github.com/sveltejs/language-tools/compare/svelte-check-3.5.2...svelte-check-3.6.0)

---
updated-dependencies:
- dependency-name: svelte-check
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 19:57:10 +00:00
IRHM bd844b17c4 Support CustomDate on activity and add import rating activity using it 2023-11-20 15:33:02 +00:00
IRHM 9bf3e6728c Support importing "Your Rating" from tmdb export 2023-11-20 14:36:50 +00:00
IRHM 78542120da v1.24.0 2023-11-19 20:55:31 +00:00
IRHM 6148773965 1.24.0-dev 2023-11-19 20:34:24 +00:00
Mr 1796bc9fb7 Merge pull request #216 from sbondCo/db-importing
TMDb Importing
2023-11-19 20:21:09 +00:00
IRHM 86c82181e1 add try again to err message 2023-11-19 20:17:19 +00:00
IRHM 51aec112b4 add error notify when no files found in dropped items
Co-Authored-By: Mathieu Moalic <21007252+mathieumoalic@users.noreply.github.com>
2023-11-19 20:14:22 +00:00
IRHM bffb7960cc import: update not supported text
Co-Authored-By: Mathieu Moalic <21007252+mathieumoalic@users.noreply.github.com>
2023-11-19 20:09:58 +00:00
IRHM 075b688605 basic tmdb import support
Co-Authored-By: Mathieu Moalic <21007252+mathieumoalic@users.noreply.github.com>
2023-11-19 19:45:46 +00:00
IRHM 6f10d221cf v1.23.0 2023-11-19 06:51:49 +00:00
IRHM 37fad5b8d3 v1.23.0 2023-11-19 06:47:53 +00:00
IRHM 8c544535c6 1.23.0-dev 2023-11-19 06:38:55 +00:00
Mr 23d407fbd6 Merge pull request #213 from sbondCo/admin-stats
Admin stats
2023-11-19 02:09:11 +00:00
IRHM 20ca9ff2be Make most watched stats take you to content on click 2023-11-19 02:05:21 +00:00
IRHM 1b8a8ba491 routes: use store somewhere else so it was worth moving in last commit
told u am smart
2023-11-19 01:50:43 +00:00
IRHM e7d93649c2 routes: move in memory store var to BaseRouter
for REUSE becuz im smart
2023-11-19 01:48:08 +00:00
IRHM 53b8b1d500 getServerStats: Add error logging even though my code has 0% chance of errorring 2023-11-19 01:37:53 +00:00
IRHM 6ae214bd98 Stats: Remove unused media query 2023-11-19 01:20:10 +00:00
IRHM 7f067c62a4 get and display server stats 2023-11-19 01:19:39 +00:00
IRHM 2e6bfc9985 move profile stats to reusable components 2023-11-18 23:16:09 +00:00
IRHM 33ea4cd3fe setup server stats route and service 2023-11-18 23:15:51 +00:00
IRHM 6211901602 v1.22.0 2023-11-17 21:07:17 +00:00
IRHM 4a50de48f0 Dockerfile: Copy in arr package 2023-11-16 00:58:29 +00:00
IRHM b58b92b00f 1.22.0-dev 2023-11-15 23:51:19 +00:00
IRHM 427c70ccb3 getEnabledFeatures: Only get real data for admins
Currently only supports sonarr/radarr, but we dont have perms that for that yet. When we do we can check for that perm instead.
2023-11-15 23:50:15 +00:00
IRHM 8d0af94f9a add beta notice to services 2023-11-15 23:37:40 +00:00
IRHM bbaa830fd9 fix selecting an arr server to use 2023-11-15 23:31:05 +00:00
Mr 221de60c11 Merge pull request #207 from sbondCo/dependabot/go_modules/server/github.com/golang-jwt/jwt/v5-5.1.0
server: bump github.com/golang-jwt/jwt/v5 from 5.0.0 to 5.1.0 in /server
2023-11-15 21:14:08 +00:00
dependabot[bot] c0ff48dc1f server: bump github.com/golang-jwt/jwt/v5 from 5.0.0 to 5.1.0 in /server
Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.0.0 to 5.1.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.0.0...v5.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-15 21:13:29 +00:00
Mr ea4dade1f7 Merge pull request #206 from sbondCo/dependabot/go_modules/server/golang.org/x/crypto-0.15.0
server: bump golang.org/x/crypto from 0.14.0 to 0.15.0 in /server
2023-11-15 21:12:41 +00:00
Mr 6432b18beb Merge pull request #205 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-6.11.0
ui: bump @typescript-eslint/eslint-plugin from 6.10.0 to 6.11.0
2023-11-15 21:11:47 +00:00
dependabot[bot] 16b4b87185 ui: bump @typescript-eslint/eslint-plugin from 6.10.0 to 6.11.0
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.10.0 to 6.11.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.11.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-15 21:11:16 +00:00
Mr 126db58cc4 Merge pull request #204 from sbondCo/dependabot/npm_and_yarn/svelte-4.2.3
ui: bump svelte from 4.2.2 to 4.2.3
2023-11-15 21:10:57 +00:00
dependabot[bot] 67d62ef957 ui: bump svelte from 4.2.2 to 4.2.3
Bumps [svelte](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte) from 4.2.2 to 4.2.3.
- [Release notes](https://github.com/sveltejs/svelte/releases)
- [Changelog](https://github.com/sveltejs/svelte/blob/main/packages/svelte/CHANGELOG-pre-5.md)
- [Commits](https://github.com/sveltejs/svelte/commits/svelte@4.2.3/packages/svelte)

---
updated-dependencies:
- dependency-name: svelte
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-15 21:10:22 +00:00
Mr 3e1607e09d Merge pull request #203 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/parser-6.11.0
ui: bump @typescript-eslint/parser from 6.10.0 to 6.11.0
2023-11-15 21:09:58 +00:00
Mr cbbc4de5a0 Merge pull request #202 from sbondCo/dependabot/npm_and_yarn/axios-1.6.1
ui: bump axios from 1.6.0 to 1.6.1
2023-11-15 21:09:32 +00:00
Mr b4f16f12e3 Merge pull request #201 from sbondCo/dependabot/npm_and_yarn/svelte-preprocess-5.1.0
ui: bump svelte-preprocess from 5.0.4 to 5.1.0
2023-11-15 21:09:14 +00:00
Mr 56bf80de7e Merge pull request #210 from sbondCo/hide-req
Hide request button when sonarr/radarr disabled
2023-11-15 21:08:35 +00:00
IRHM e2e791570e get server features again after closing sonarr/radarr modal 2023-11-15 21:06:17 +00:00
IRHM d65f1891bb RadarrModal: Update setting descriptions to be about movies not shows 2023-11-15 20:59:29 +00:00
IRHM 35b1ea951b Create features route - use to only show request btn if feature is enabled 2023-11-15 20:52:47 +00:00
IRHM d76dfbec95 SimilarContent: Only show list if there are any results 2023-11-15 20:15:55 +00:00
IRHM 095015329a fix no server found typo 2023-11-14 19:09:45 +00:00
Mr c7c1760a96 Merge pull request #208 from sbondCo/navts
Fix left positioned tooltips and add tooltips to nav icons
2023-11-14 19:06:39 +00:00
IRHM 74de1f3039 fix left tooltips 2023-11-14 19:05:23 +00:00
IRHM 0ba1cc35c5 add tooltips to nav buttons 2023-11-14 19:00:29 +00:00
dependabot[bot] cb09d71d3d server: bump golang.org/x/crypto from 0.14.0 to 0.15.0 in /server
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.15.0.
- [Commits](https://github.com/golang/crypto/compare/v0.14.0...v0.15.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-13 19:47:58 +00:00
dependabot[bot] 62bd6c8353 ui: bump @typescript-eslint/parser from 6.10.0 to 6.11.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.10.0 to 6.11.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.11.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-13 19:37:14 +00:00
dependabot[bot] 75cf586407 ui: bump axios from 1.6.0 to 1.6.1
Bumps [axios](https://github.com/axios/axios) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.6.0...v1.6.1)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-13 19:36:57 +00:00
dependabot[bot] 25f747b6bb ui: bump svelte-preprocess from 5.0.4 to 5.1.0
Bumps [svelte-preprocess](https://github.com/sveltejs/svelte-preprocess) from 5.0.4 to 5.1.0.
- [Changelog](https://github.com/sveltejs/svelte-preprocess/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte-preprocess/commits/v5.1.0)

---
updated-dependencies:
- dependency-name: svelte-preprocess
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-13 19:36:51 +00:00
Mr d3fdd3cc1e Merge pull request #198 from sbondCo/radarr-reqs
Radarr requesting
2023-11-12 20:27:13 +00:00
IRHM 9022654bdb requesting: use rootfolder defined in server settings 2023-11-12 20:25:18 +00:00
IRHM 71daab3e6c movie: add missing import 2023-11-12 20:16:58 +00:00
IRHM f4b87bdc2a requesting: use actual server name, add content name and year 2023-11-12 20:15:18 +00:00
IRHM 9e7981e80b radarr requesting 2023-11-12 20:09:55 +00:00
IRHM d0a86c4c85 add radarr settings 2023-11-12 13:55:23 +00:00
Mr 06283ca0e4 Merge pull request #197 from sbondCo/dependabot/npm_and_yarn/sveltejs/kit-1.27.5
ui: bump @sveltejs/kit from 1.27.2 to 1.27.5
2023-11-12 02:49:16 +00:00
Mr 2336cc3680 Merge pull request #190 from sbondCo/dependabot/npm_and_yarn/eslint-plugin-svelte-2.35.0
ui: bump eslint-plugin-svelte from 2.34.0 to 2.35.0
2023-11-12 02:48:48 +00:00
dependabot[bot] 312c192ccb ui: bump @sveltejs/kit from 1.27.2 to 1.27.5
Bumps [@sveltejs/kit](https://github.com/sveltejs/kit/tree/HEAD/packages/kit) from 1.27.2 to 1.27.5.
- [Release notes](https://github.com/sveltejs/kit/releases)
- [Changelog](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/kit@1.27.5/packages/kit)

---
updated-dependencies:
- dependency-name: "@sveltejs/kit"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-12 02:48:00 +00:00
Mr dbc0c015ef Merge pull request #189 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-6.10.0
ui: bump @typescript-eslint/eslint-plugin from 6.9.1 to 6.10.0
2023-11-12 02:47:24 +00:00
dependabot[bot] 5b00825b18 ui: bump @typescript-eslint/eslint-plugin from 6.9.1 to 6.10.0
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.9.1 to 6.10.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.10.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-12 02:46:54 +00:00
dependabot[bot] 2a2b6119f7 ui: bump eslint-plugin-svelte from 2.34.0 to 2.35.0
Bumps [eslint-plugin-svelte](https://github.com/sveltejs/eslint-plugin-svelte) from 2.34.0 to 2.35.0.
- [Release notes](https://github.com/sveltejs/eslint-plugin-svelte/releases)
- [Changelog](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/eslint-plugin-svelte/compare/v2.34.0...v2.35.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-svelte
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-12 02:46:50 +00:00
Mr fbd3215be3 Merge pull request #187 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/parser-6.10.0
ui: bump @typescript-eslint/parser from 6.9.1 to 6.10.0
2023-11-12 02:46:06 +00:00
dependabot[bot] b26e59664f ui: bump @typescript-eslint/parser from 6.9.1 to 6.10.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.9.1 to 6.10.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.10.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-12 02:33:00 +00:00
Mr 0a035c2c23 Merge pull request #186 from sbondCo/dependabot/npm_and_yarn/eslint-8.53.0
ui: bump eslint from 8.52.0 to 8.53.0
2023-11-12 02:32:17 +00:00
Mr 9dc63f4ed8 Merge pull request #196 from sbondCo/darktheme-poster-btn
Fix poster button colors in dark theme
2023-11-12 02:31:23 +00:00
IRHM bb8cfe1b52 PosterRating: Make on hover text readable in dark theme 2023-11-12 02:29:13 +00:00
IRHM 8bdc459bc0 fix dark theme poster status no-icon color 2023-11-12 02:20:30 +00:00
Mr 5c37f29382 Merge pull request #195 from sbondCo/allrr2
Sonarr Requesting
2023-11-12 02:08:42 +00:00
IRHM aacc4b1285 fix zindexes 2023-11-11 22:41:58 +00:00
IRHM a3a037775f RequestModal notification 2023-11-11 22:39:56 +00:00
IRHM 868ddfc510 hookup AutomaticSearch setting 2023-11-11 22:31:30 +00:00
IRHM 12eeeb91a2 sonarr season requesting 2023-11-11 22:26:17 +00:00
Mr e16cbfc49e Merge pull request #191 from sbondCo/updated-screens
readme: update and add new screenshots
2023-11-09 21:08:10 +00:00
IRHM d38d7dfd56 update and add new screenshots 2023-11-09 02:05:02 +00:00
IRHM 0fc895b667 create basic seasons list 2023-11-07 21:41:34 +00:00
IRHM 24b986572a cleanup requestcontent
a bit
2023-11-07 18:32:15 +00:00
dependabot[bot] a3aa9adc0e ui: bump eslint from 8.52.0 to 8.53.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.52.0 to 8.53.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.52.0...v8.53.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-06 19:21:42 +00:00
IRHM 3c6b6ae1a5 sonarr basic content requesting working 2023-11-05 17:08:17 +00:00
IRHM c8f8869c28 arr: reload data on modal exit 2023-11-03 03:01:30 +00:00
IRHM 53895462a5 arr: support removing a server 2023-11-03 03:01:30 +00:00
IRHM 6ce3099396 settings: add padding to bottom of page 2023-11-03 03:01:30 +00:00
IRHM 068e6a1684 arr: fix editing and add autoSearch checkbox 2023-11-03 03:01:30 +00:00
IRHM e5052e265d arr: editing server 2023-11-03 03:01:30 +00:00
IRHM 79b4fe1d95 arr: support adding new sonarr server 2023-11-03 03:01:30 +00:00
IRHM 328bbedcf0 arrModal: Show errors of save 2023-11-03 03:01:30 +00:00
IRHM 10285bffd7 Modal: Scroll when not enough space, show above nav 2023-11-03 03:01:30 +00:00
IRHM d7b1b4cf46 redo arr implementation
decided it would be harder to add multiple server support down the road than to just do it right the first time.

modal wont autosave. One endpoint to get all details needed for modal (/test).
2023-11-03 03:01:30 +00:00
IRHM 7b0045fd6c ui: profile: Use Setting component
not using all because it will break the theme setting and i dont wanna have to fix that :()
2023-11-03 03:01:30 +00:00
IRHM 0554ba2667 ui: Move settings to their own components 2023-11-03 03:01:30 +00:00
IRHM a06ad2fd3f ui: Move sonarr settings to modal and fetch quality profiles 2023-11-03 03:01:30 +00:00
IRHM 8d69043779 server: Create GetSafe on ServerConfig struct
to get safe version of config.. still manual for now until i figure out a better way (since we cant us struct tag since we do need the other properties for file)
2023-11-03 03:01:30 +00:00
IRHM 7634f80270 server: Basic flow for using radarr/sonarr setup
New `arr` package created, works how I wanted so far, want to try not have the routes be so duplicated... becuz bad
2023-11-03 03:01:30 +00:00
IRHM 6caed2fd36 config: Create sonarr/radarr settings 2023-11-03 03:01:30 +00:00
Mr ae3518cdc5 README: Update setup section to link to docs 2023-11-02 21:41:17 +00:00
IRHM d5349322ca v1.21.1 2023-11-02 00:41:39 +00:00
Mr 837db05e6e Merge pull request #185 from sbondCo/docker-user
Support changing user to run docker container with & move to alpine based images
2023-11-02 00:37:18 +00:00
IRHM d1f2255f65 workflows: Remove workflow_dispatch trigger from container-release.yml 2023-11-02 00:22:07 +00:00
IRHM fab012ae09 move to alpine base images
image is half of original size now too very nice - 500MB -> 1.2GB -> 200MB
2023-11-02 00:18:40 +00:00
IRHM a3559381bd omit dev dependencies in runner step 2023-11-01 23:48:23 +00:00
IRHM 21a2dc1bf4 1.21.1-dev 2023-11-01 22:21:02 +00:00
IRHM 6a461af848 use node:20 as base image for runner step
updated ui builder step to node:20 too
2023-11-01 22:20:05 +00:00
IRHM aed92177f3 v1.21.0 2023-11-01 04:15:47 +00:00
IRHM a52463259a 1.21.0-dev2 2023-11-01 03:56:32 +00:00
IRHM 4590c6bd56 Add SEASON_REMOVED activity 2023-11-01 03:55:50 +00:00
IRHM efb442b224 1.21.0-dev1 2023-11-01 03:22:13 +00:00
IRHM dd364aca9a SeasonsList: Fix episodes spoiler blur being cut off 2023-11-01 03:21:41 +00:00
IRHM 768d3add59 SeasonsList: Increase bottom margin on topbar 2023-11-01 03:20:05 +00:00
IRHM a18a5ee23a SeasonsList: Fix top on mobile 2023-11-01 03:17:57 +00:00
IRHM 71f294552d 1.21.0-dev 2023-11-01 02:14:23 +00:00
Mr 5d268b93be Merge pull request #183 from sbondCo/seasonslist-styl
SeasonsList: Make season buttons wrap
2023-11-01 02:12:23 +00:00
IRHM 856444bd9f SeasonsList: Make season buttons wrap
Seasons with names will take up less vertical space and look better generally.
2023-11-01 02:08:39 +00:00
Mr 14e3277e6d Merge pull request #176 from sbondCo/dependabot/npm_and_yarn/sveltejs/kit-1.27.2
ui: bump @sveltejs/kit from 1.25.2 to 1.27.2
2023-11-01 01:33:48 +00:00
dependabot[bot] 89aa4b477f ui: bump @sveltejs/kit from 1.25.2 to 1.27.2
Bumps [@sveltejs/kit](https://github.com/sveltejs/kit/tree/HEAD/packages/kit) from 1.25.2 to 1.27.2.
- [Release notes](https://github.com/sveltejs/kit/releases)
- [Changelog](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/kit@1.27.2/packages/kit)

---
updated-dependencies:
- dependency-name: "@sveltejs/kit"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 01:33:00 +00:00
Mr f4b22c76d6 Merge pull request #175 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-6.9.1
ui: bump @typescript-eslint/eslint-plugin from 6.9.0 to 6.9.1
2023-11-01 01:32:23 +00:00
Mr 83472ae329 Merge pull request #161 from sbondCo/dependabot/github_actions/actions/setup-node-4
workflow: bump actions/setup-node from 3 to 4
2023-11-01 01:27:47 +00:00
dependabot[bot] 345a465f0f ui: bump @typescript-eslint/eslint-plugin from 6.9.0 to 6.9.1
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.9.0 to 6.9.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.9.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 01:27:08 +00:00
Mr 7e7a9c886d Merge pull request #177 from sbondCo/dependabot/npm_and_yarn/axios-1.6.0
ui: bump axios from 1.5.1 to 1.6.0
2023-11-01 01:26:51 +00:00
Mr 2abde13fb3 Merge pull request #178 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/parser-6.9.1
ui: bump @typescript-eslint/parser from 6.9.0 to 6.9.1
2023-11-01 01:26:25 +00:00
Mr 57d8de9b54 Merge pull request #182 from sbondCo/seasonlist-stickiness-nav-gone-not-seen-bad-fix-this-now-pls-mr-me
Fix SeasonList being hidden below nav
2023-11-01 00:59:53 +00:00
IRHM 02ae13d8f8 SeasonsList: Make list smaller when nav shown 2023-11-01 00:50:10 +00:00
IRHM 3641105ce2 fix nav hiding seasonlist items 2023-11-01 00:45:00 +00:00
Mr 4dfd84d807 Merge pull request #180 from sbondCo/reveal-show
Add shadow to `Click To Reveal`
2023-10-31 04:18:10 +00:00
IRHM 088fda01a7 SeasonsListEpisode: Use var for shadows 2023-10-31 04:16:53 +00:00
IRHM d827ef7d61 SeasonsListEpisode: Add shadow to click to reveal message 2023-10-31 04:10:22 +00:00
Mr d117416367 Merge pull request #179 from sbondCo/watch-seasons
Watch seasons
2023-10-31 02:12:05 +00:00
IRHM 4c3ce990c9 SeasonsList: Only show status/rating button if show is on watched list 2023-10-31 02:02:51 +00:00
IRHM ba34594c2e ui: support new activity messages 2023-10-31 01:53:39 +00:00
IRHM 5aecf064ba add activity for adding watched items 2023-10-30 22:27:07 +00:00
IRHM ca052df6e0 SeasonsList: De-duplicate updating watched list item 2023-10-30 21:04:04 +00:00
IRHM b95c4852ce support setting watched season rating 2023-10-30 21:01:39 +00:00
IRHM 38ee6253da server: remove testing debug log 2023-10-30 19:48:23 +00:00
dependabot[bot] 0d46917e8d ui: bump @typescript-eslint/parser from 6.9.0 to 6.9.1
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.9.0 to 6.9.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.9.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-30 19:26:45 +00:00
dependabot[bot] b406a49c9c ui: bump axios from 1.5.1 to 1.6.0
Bumps [axios](https://github.com/axios/axios) from 1.5.1 to 1.6.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.5.1...v1.6.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-30 19:26:29 +00:00
IRHM 23b02c7e40 support deleting a watched season status 2023-10-30 02:29:09 +00:00
IRHM 0372c8dfd7 Basic update of season status working 2023-10-30 00:58:23 +00:00
IRHM 0197c5eaeb server: Create add/edit watched season endpoint 2023-10-30 00:32:56 +00:00
IRHM 7bd7f98c91 season status outline and make tooltip an arg 2023-10-29 00:43:12 +01:00
IRHM 382c0b4c48 SeasonsList: Create topbar 2023-10-28 21:21:16 +01:00
IRHM 6a46e3b7e2 PosterStatus: Add direction and width props 2023-10-28 21:20:48 +01:00
IRHM 701219b517 tooltip: Add condition opt 2023-10-28 21:20:32 +01:00
IRHM 7e5f1b6ad6 PosterStatus: Different svg padding depending on if status
so we can fit all icons
2023-10-28 20:40:45 +01:00
IRHM d20b1ca0f2 Poster: Move rating and status btns own components 2023-10-28 20:27:20 +01:00
IRHM 852ff0403e ui: Move Poster components to poster folder
gotta organize - gonna be more in a second
2023-10-28 18:38:40 +01:00
IRHM 3d52d96215 server: Create WatchedSeasons table
Each watched season will links to a watched item.
2023-10-28 18:28:17 +01:00
IRHM a3abc549b1 v1.20.1 2023-10-28 04:13:49 +01:00
IRHM 3dfb88bfb4 1.20.1-dev1 2023-10-28 04:02:25 +01:00
Mr 731ebce307 Merge pull request #172 from sbondCo/chrome-issues
Poster: Fix big scrollbars making icons small in sub menus on chromium
2023-10-28 03:01:07 +00:00
IRHM 1eacde4555 Poster: Fix big scrollbars making icons small in sub menus in chromium 2023-10-28 03:01:08 +01:00
IRHM d48e7286d8 1.20.1-dev 2023-10-27 21:48:22 +01:00
Mr 27f081a8c6 Merge pull request #162 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/parser-6.9.0
ui: bump @typescript-eslint/parser from 6.8.0 to 6.9.0
2023-10-27 20:39:21 +00:00
Mr 17d1a33867 Merge pull request #163 from sbondCo/dependabot/npm_and_yarn/vite-4.5.0
ui: bump vite from 4.4.11 to 4.5.0
2023-10-27 20:39:07 +00:00
Mr 8acc07cb94 Merge pull request #164 from sbondCo/dependabot/npm_and_yarn/svelte-4.2.2
ui: bump svelte from 4.2.1 to 4.2.2
2023-10-27 20:38:54 +00:00
dependabot[bot] 7335c83a08 ui: bump svelte from 4.2.1 to 4.2.2
Bumps [svelte](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte) from 4.2.1 to 4.2.2.
- [Release notes](https://github.com/sveltejs/svelte/releases)
- [Changelog](https://github.com/sveltejs/svelte/blob/master/packages/svelte/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte/commits/svelte@4.2.2/packages/svelte)

---
updated-dependencies:
- dependency-name: svelte
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-27 20:36:53 +00:00
dependabot[bot] 695aa5bb0b ui: bump @typescript-eslint/parser from 6.8.0 to 6.9.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.8.0 to 6.9.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.9.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-27 20:36:52 +00:00
Mr f7685f22c6 Merge pull request #165 from sbondCo/dependabot/npm_and_yarn/eslint-8.52.0
ui: bump eslint from 8.51.0 to 8.52.0
2023-10-27 20:36:24 +00:00
Mr 952ef27781 Merge pull request #166 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-6.9.0
ui: bump @typescript-eslint/eslint-plugin from 6.8.0 to 6.9.0
2023-10-27 20:36:07 +00:00
Mr e8f186fd54 Merge pull request #171 from sbondCo/search-issue
Nav: Fix search input not re-focusing after search loads on chromium
2023-10-27 20:34:55 +00:00
IRHM d0a964775e nav: fix search unfocusing on chromium 2023-10-27 21:30:19 +01:00
IRHM 866432d22e Revert "nav: fix searchbar un-focusing on chrome"
This reverts commit 5dce12c73b.
2023-10-27 21:13:51 +01:00
IRHM 5dce12c73b nav: fix searchbar un-focusing on chrome
autofocus fixes this for us now, we won't use it anywhere else.
2023-10-27 21:11:51 +01:00
IRHM 6d002b4d1a nav: add ? operator to classList usage
when chrome doesnt focus input and you press space, it will scroll down, for some reason that will fail too.
2023-10-27 20:10:08 +01:00
dependabot[bot] 5a66b51b00 ui: bump @typescript-eslint/eslint-plugin from 6.8.0 to 6.9.0
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.8.0 to 6.9.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.9.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-23 19:51:58 +00:00
dependabot[bot] 16d53be62c ui: bump eslint from 8.51.0 to 8.52.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.51.0 to 8.52.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.51.0...v8.52.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-23 19:51:24 +00:00
dependabot[bot] afe1947bd3 ui: bump vite from 4.4.11 to 4.5.0
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.4.11 to 4.5.0.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.5.0/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-23 19:50:54 +00:00
dependabot[bot] 40bd349e22 workflow: bump actions/setup-node from 3 to 4
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-23 19:23:38 +00:00
Mr faff9ff366 Merge pull request #160 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/parser-6.8.0
ui: bump @typescript-eslint/parser from 6.7.5 to 6.8.0
2023-10-16 19:37:23 +00:00
dependabot[bot] e7b0d4f3d1 ui: bump @typescript-eslint/parser from 6.7.5 to 6.8.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.7.5 to 6.8.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.8.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-16 19:36:06 +00:00
Mr a8650a47a5 Merge pull request #159 from sbondCo/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-6.8.0
ui: bump @typescript-eslint/eslint-plugin from 6.7.5 to 6.8.0
2023-10-16 19:35:04 +00:00
dependabot[bot] 1a0319f316 ui: bump @typescript-eslint/eslint-plugin from 6.7.5 to 6.8.0
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.7.5 to 6.8.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.8.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-16 19:33:36 +00:00
IRHM fc943d2eea v1.20.0 2023-10-15 19:29:36 +01:00
IRHM edc292be19 v1.20.0-dev 2023-10-15 19:18:43 +01:00
Mr 01d78695a8 Merge pull request #158 from sbondCo/similar-content
Similar Content Section
2023-10-15 14:26:34 +00:00
IRHM be14a4689c tv: fix PageError error prop 2023-10-15 15:19:21 +01:00
IRHM aea4aab78a Show similar content
had to rework content pages to allow for navigating to another show/movie, since sveltekit wont refresh the whole page when only changing a page parameter
2023-10-15 15:16:12 +01:00
Mr 0619338a97 Merge pull request #157 from sbondCo/fix-cast-text
Content: Fix `cast` header text scrolling out of view
2023-10-15 02:13:06 +00:00
IRHM 41677ea717 SeasonsList: Put max-width on season names
Some shows give seasons names, which when long, would break the episode view.
2023-10-15 02:58:49 +01:00
IRHM 6304c33436 Fix Cast header scrolling out of view
Moved styling for scroll into HorizontalList component.
2023-10-15 02:55:46 +01:00
Mr 41af9c9fe1 Merge pull request #156 from sbondCo/spoilerz
New `Hide Spoilers` Setting
2023-10-15 01:44:41 +00:00
IRHM bade703b4d SeasonsListEpisode: Add transition to blur 2023-10-15 02:40:27 +01:00
IRHM 7220684a97 SeasonsListEpisode: Support hiding spoilers
Hide episode image and name until user reveals
2023-10-15 02:34:13 +01:00
IRHM da7f62af12 SeasonsList: Move episode li out to its own component 2023-10-15 01:54:09 +01:00
IRHM 9054729069 server: Support multiple settings in userUpdate, add spoiler setting
and technically ui but wutevr
2023-10-14 22:29:21 +01:00
Mr 444105955e Merge pull request #155 from sbondCo/dependabot/github_actions/docker/build-push-action-5
workflow: bump docker/build-push-action from 4 to 5
2023-10-14 20:41:32 +00:00
Mr a23bfc5fac Merge pull request #153 from sbondCo/dependabot/github_actions/docker/login-action-3
workflow: bump docker/login-action from 2 to 3
2023-10-14 20:40:57 +00:00
Mr 0934f57fdb Merge pull request #152 from sbondCo/dependabot/github_actions/docker/metadata-action-5
workflow: bump docker/metadata-action from 4 to 5
2023-10-14 20:40:08 +00:00
dependabot[bot] 4669994b4a workflow: bump docker/login-action from 2 to 3
Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-14 20:37:06 +00:00
Mr 1135e1132a Merge pull request #154 from sbondCo/dependabot/github_actions/actions/checkout-4
workflow: bump actions/checkout from 3 to 4
2023-10-14 20:36:30 +00:00
dependabot[bot] a22c830357 workflow: bump docker/build-push-action from 4 to 5
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-14 20:29:44 +00:00
dependabot[bot] f09005d171 workflow: bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-14 20:29:41 +00:00
dependabot[bot] 459c729da1 workflow: bump docker/metadata-action from 4 to 5
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4 to 5.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Upgrade guide](https://github.com/docker/metadata-action/blob/master/UPGRADE.md)
- [Commits](https://github.com/docker/metadata-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-14 20:29:37 +00:00
Mr aacdfebdcf Create dependabot.yml config 2023-10-14 20:29:19 +00:00
144 changed files with 22504 additions and 5409 deletions
+5
View File
@@ -0,0 +1,5 @@
<!-- Make sure your code is formatted by running `npm run format` or using prettier manually. -->
### Changes made
<!-- Describe changes made here. If changes are visual a screenshot could be useful! -->
+27
View File
@@ -0,0 +1,27 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
# Web UI
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "ui"
# Server
- package-ecosystem: "gomod"
directory: "/server"
schedule:
interval: "weekly"
commit-message:
prefix: "server"
# Workflows
- package-ecosystem: "github-actions"
directory: "/" # / will look in /.github/workflows directory by default
schedule:
interval: "weekly"
commit-message:
prefix: "workflow"
+14 -4
View File
@@ -1,4 +1,7 @@
name: Development Watcharr Container Release
# Multi arch support doc/guide:
# https://docs.docker.com/build/ci/github-actions/multi-platform/
name: Development Watcharr Image Release
on:
workflow_dispatch:
@@ -16,20 +19,27 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.image }}:dev
labels: ${{ env.image }}:${{ github.sha }}
+12 -6
View File
@@ -1,7 +1,6 @@
name: Release Watcharr Containers
name: Release Watcharr Image
on:
workflow_dispatch:
push:
tags:
- v*
@@ -19,10 +18,16 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
@@ -30,15 +35,16 @@ jobs:
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.image }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+2 -2
View File
@@ -21,8 +21,8 @@ jobs:
run:
working-directory: doc
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
+2 -2
View File
@@ -16,8 +16,8 @@ jobs:
run:
working-directory: doc
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
+28
View File
@@ -0,0 +1,28 @@
name: Test PR Changes
on:
pull_request:
branches:
- "**"
tags-ignore:
- v*
jobs:
linter_check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Get dependencies
run: npm i
- name: Check for linting/formatting errors
run: npm run lint
+5
View File
@@ -40,3 +40,8 @@ vite.config.ts.timestamp-*
# Docker dev volume
container_data/
data/
# Build artifacts
server/ui
server/watcharr
+1 -1
View File
@@ -12,4 +12,4 @@
"program": "${fileDirname}"
}
]
}
}
+11 -17
View File
@@ -1,13 +1,19 @@
# Backend
FROM golang:1.21 AS server
FROM golang:1.21-alpine AS server
WORKDIR /server
COPY server/*.go server/go.* ./
COPY server/arr/*.go ./arr/
COPY server/game/*.go ./game/
RUN go mod download && GOOS=linux go build -o ./watcharr
# Required so we can build with cgo
RUN apk update && apk add --no-cache musl-dev gcc build-base
# CGO_CFLAGS: https://github.com/mattn/go-sqlite3/issues/1164#issuecomment-1635253695
RUN go mod download && GOOS=linux CGO_ENABLED=1 CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -o ./watcharr
# Frontend
FROM node:19 AS ui
FROM node:20-alpine AS ui
WORKDIR /app
COPY package*.json vite.config.ts svelte.config.js tsconfig.json ./
@@ -17,24 +23,12 @@ COPY ./static ./static
RUN npm install && npm run build
# Production
FROM debian:12.0 AS runner
RUN apt-get update && apt-get install ca-certificates -y
ENV NODE_VERSION=18.13.0
RUN apt install -y curl
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
FROM node:20-alpine AS runner
COPY --from=server /server/watcharr /
COPY --from=ui /app/build /ui
COPY --from=ui /app/package.json /app/package-lock.json /ui
RUN cd /ui && npm ci
RUN cd /ui && npm ci --omit=dev
EXPOSE 3080
+23 -33
View File
@@ -4,11 +4,15 @@
<p align="center">
<a href="https://github.com/sbondCo/Watcharr/pkgs/container/watcharr"><img src="https://img.shields.io/github/v/release/sbondCo/Watcharr?label=version&style=for-the-badge" /></a>
<a href="https://beta.watcharr.app"><img src="https://img.shields.io/website?label=DEMO&style=for-the-badge&url=https%3A%2F%2Fbeta.watcharr.app" /></a>
<a href="https://watcharr.app"><img src="https://img.shields.io/website?label=DOCS&style=for-the-badge&url=https%3A%2F%2Fwatcharr.app" /></a>
<a href="https://github.com/sbondCo/Watcharr/issues"><img src="https://img.shields.io/github/issues-raw/sbondCo/Watcharr?label=ISSUES&style=for-the-badge" /></a>
<a href="/LICENSE"><img src="https://img.shields.io/github/license/sbondCo/Watcharr?style=for-the-badge" /></a>
<a href="https://matrix.to/#/#watcharr:matrix.org"><img src="https://img.shields.io/matrix/watcharr%3Amatrix.org?style=for-the-badge&logo=matrix" /></a>
</p>
I'm your new easily self-hosted content watched list. The place you store your watched (or watching, planned, etc) movies and tv shows, rate them and track their status.
I'm your new easily self-hosted content watched list. The place you store your watched (or watching, planned, etc) **movies** and **tv shows** (and **anime**), rate them and track their status.
With [some extra configuration](https://watcharr.app/docs/server_config/game-support-igdb) I can also track your **video games**.
I am built with Go and Svelte(Kit).
@@ -25,46 +29,32 @@ Feel free to abuse this demo instance (nicely), which runs on the latest `dev` b
# Screenshots
<h3 align="center">Watched List</h3>
<p align="center">
<img src="./screenshot/homepage.png" alt="Watched List" />
| Watched Show Hover | Watched Show Status Change | Show Details |
| ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| <img src="./screenshot/homepage-poster-hover.png" alt="Watched List" /> | <img src="./screenshot/homepage-poster-change-status.png" alt="Changing Show Status" /> | <img src="./screenshot/show-details-page.png" alt="Content Details Page" /> |
| Homepage | Watched Show Hover |
| ---------------------------------------------------------- | ----------------------------------------------------------------------- |
| <img src="./screenshot/homepage.png" alt="Watched List" /> | <img src="./screenshot/homepage-poster-hover.png" alt="Watched List" /> |
| Watched Show Status Change | Movie Details |
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| <img src="./screenshot/homepage-poster-change-status.png" alt="Changing Show Status" /> | <img src="./screenshot/content-details-page.png" alt="Content Details Page" /> |
| User Profile | Discover |
| ------------------------------------------------------------------- | ---------------------------------------------------------------- |
| <img src="./screenshot/user-profile.png" alt="User Profile Page" /> | <img src="./screenshot/discover-page.png" alt="Discover Page" /> |
| Dark Homepage | Dark Content Details |
| ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| <img src="./screenshot/homepage-dark.png" alt="Dark Theme Homepage" /> | <img src="./screenshot/content-details-page-dark.png" alt="Dark Theme Content Page" /> |
</p>
# Set Up
Currently only a [docker image](https://github.com/sbondCo/Watcharr/pkgs/container/watcharr) is provided (**v1.9.1 and newer no longer require the `watcharr-ui` package, it is bundled inside the main `watcharr` package**).
**Note:** When first running, make sure only you have access. The first user created will become admin.
Here is a simple setup you can use yourself, using docker compose:
**docker-compose.yml**
```
version: "3"
services:
watcharr:
# The :latest tag is used for simplicity, it is recommended
# to use an actual version, then when updating check the releases for changelogs.
image: ghcr.io/sbondco/watcharr:latest
container_name: watcharr
ports:
- 3080:3080
volumes:
# Contains all of watcharr data (database & cache)
- ./data:/data
```
After loading up Watcharr, you will be greeted with a menu to setup the first account (which will be admin).
When logged in you can then configure the server settings from the nav face menu > settings option.
[Checkout our documentation](https://watcharr.app/docs/category/installation) for an up to date guide on setup! If you hate manuals, but love docker, this [docker-compose.yml](./docker-compose.yml) file is your friend.
# Getting Help
If something isn't working for you or you are stuck, [creating an issue](https://github.com/sbondCo/Watcharr/issues/new) is the best way to get help! Every type of issue is accepted, so don't be afraid to ask anything!
You can also [join our space on Matrix](https://matrix.to/#/#watcharr:matrix.org) for support.
+1 -1
View File
@@ -1,3 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
presets: [require.resolve("@docusaurus/core/lib/babel/preset")]
};
+1
View File
@@ -22,6 +22,7 @@ services:
volumes:
# Contains all of watcharr data (database & cache)
- ./data:/data
restart: unless-stopped
```
:::danger first account
+8
View File
@@ -0,0 +1,8 @@
{
"label": "Server Configuration",
"position": 2,
"link": {
"type": "generated-index",
"description": "Learn how to configure your server."
}
}
@@ -0,0 +1,47 @@
---
sidebar_position: 1
---
# Games Support (via IGDB/Twitch)
## Overview
Game support in Watcharr, currently, must be enabled by you.
This involves setting up a Twitch developer account (phone number needed for 2FA which is required) and entering application credentials into Watcharr, that can then be used for looking up game info via IGDB.
P.S. These steps are stolen from [igdb api docs](https://api-docs.igdb.com/#account-creation), I've tried to make it easier to follow with screenshots.
## Steps
### Setup On Twitch
1. Sign up for a [Twitch](https://dev.twitch.tv/login) account.
Click login with twitch, then create an account in the Sign Up tab.
2. Enable two factor authentication in your [account Security settings](https://www.twitch.tv/settings/security) (currently requires a phone number).
3. [Register a new Application in the Twitch Developer Console](https://dev.twitch.tv/console/apps/create).
These settings will do (name can be anything, we don't use OAuth, but a redirect url is required; localhost will do):
![Registering twitch application](./img/twitch-register-app.png)
4. [Click manage](https://dev.twitch.tv/console/apps) on your newly created application.
5. Click 'New Secret' to generate a new Client Secret.
6. Take a note of your Client ID and new Client Secret (by leaving this tab open, until we are ready to copy the values into Watcharr).
### Setup On Watcharr
1. Login to Watcharr with an Admin account and navigate to server settings.
![Navigating to server settings in Watcharr](./img/watcharr-settings-dropdown.png)
2. Scroll down and click on the Twitch service.
![Twitch service config button](./img/watcharr-twitch-service.png)
3. Enter your Client ID and Client Secret (from Twitch Application page, step 6 on twitch setup steps)
![Twitch service config](./img/watcharr-twitch-config.png)
4. Click save, and start searching for your favourite games!
![Watcharr game details page](./img/watcharr-game-details.png)
Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

+14 -5
View File
@@ -1,8 +1,9 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");
const { themes } = require("prism-react-renderer");
const lightTheme = themes.github;
const darkTheme = themes.dracula;
/** @type {import('@docusaurus/types').Config} */
const config = {
@@ -53,7 +54,10 @@ const config = {
editUrl: "https://github.com/sbondCo/Watcharr/tree/dev/doc"
},
theme: {
customCss: require.resolve("./src/css/custom.css")
customCss: [
"./node_modules/viewerjs/dist/viewer.css",
require.resolve("./src/css/custom.css")
]
}
})
]
@@ -79,6 +83,11 @@ const config = {
{
type: "docsVersionDropdown"
},
{
href: "https://beta.watcharr.app",
label: "Demo",
position: "right"
},
{
href: "https://github.com/sbondCo/Watcharr",
label: "GitHub",
@@ -87,8 +96,8 @@ const config = {
]
},
prism: {
theme: lightCodeTheme
// darkTheme: darkCodeTheme
theme: lightTheme,
darkTheme: darkTheme
},
colorMode: {
defaultMode: "light",
+4822 -2949
View File
File diff suppressed because it is too large Load Diff
+10 -9
View File
@@ -14,16 +14,17 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "2.4.3",
"@docusaurus/preset-classic": "2.4.3",
"@mdx-js/react": "^1.6.22",
"clsx": "^1.2.1",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.1.0",
"prism-react-renderer": "^2.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"viewerjs": "^1.11.6"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.4.3"
"@docusaurus/module-type-aliases": "3.1.1"
},
"browserslist": {
"production": [
@@ -38,6 +39,6 @@
]
},
"engines": {
"node": ">=16.14"
"node": ">=18.0"
}
}
+1 -1
View File
@@ -14,7 +14,7 @@
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
// By default, Docusaurus generates a sidebar from the docs folder structure
tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
tutorialSidebar: [{ type: "autogenerated", dirName: "." }]
// But you can create a sidebar manually
/*
+71
View File
@@ -0,0 +1,71 @@
import React, { useEffect } from "react";
import styles from "./styles.module.css";
import clsx from "clsx";
import Viewer from "viewerjs";
function TwoColFeat({ title, description, imgSrc }) {
return (
<div className={clsx(styles.twoCol)}>
<div>
<h2>{title}</h2>
<p>{description}</p>
</div>
<div>
<img src={imgSrc} alt="" loading="lazy" />
</div>
</div>
);
}
export function HomepageTwoColFeats() {
useEffect(() => {
const ctr = document.getElementById("homepage-two-col-feats");
console.debug("Starting image viewer", ctr);
new Viewer(ctr, {
navbar: 0,
toolbar: {
zoomIn: 2,
zoomOut: 2,
next: 2,
prev: 2
},
title: 0,
className: "twoColViewer"
});
}, []);
return (
<section id="homepage-two-col-feats" className={styles.twoColFeats}>
<TwoColFeat
title="Neat UI"
description="We just look lightweight."
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/homepage.png"
/>
<TwoColFeat
title="Easy To Use"
description="Not much to it, other than ease of use."
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/homepage-poster-change-status.png"
/>
<TwoColFeat
title="In-Depth Details"
description="About your favourite content."
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/content-details-page.png"
/>
<TwoColFeat
title="Personal Stats and Configuration"
description="Make it how you like."
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/user-profile.png"
/>
<TwoColFeat
title="Discovery"
description="Find the latest trending content."
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/discover-page.png"
/>
<TwoColFeat
title="Dark Theme"
description="For you who are still unsatisfied. ;("
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/content-details-page-dark.png"
/>
</section>
);
}
@@ -0,0 +1,53 @@
.twoColFeats {
display: flex;
align-items: center;
margin-left: auto;
margin-right: auto;
flex-flow: column;
width: 100%;
max-width: 1300px;
}
.twoCol {
display: flex;
flex-flow: row;
width: 100%;
padding: 2.5rem 5rem;
gap: 50px;
background-color: rgb(236, 236, 236);
}
.twoCol:nth-child(even) {
flex-flow: row-reverse;
background-color: transparent;
}
.twoCol > div {
width: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-flow: column;
}
.twoCol > div > img {
width: 100%;
border-radius: 12px;
box-shadow: 0px 0px 5px rgb(121, 121, 121);
cursor: pointer;
}
@media screen and (max-width: 850px) {
.twoCol,
.twoCol:nth-child(even) {
flex-flow: column;
}
.twoCol > div {
width: 100%;
}
.twoCol > div > img {
max-width: 500px;
}
}
+15 -1
View File
@@ -18,7 +18,7 @@
}
/* For readability concerns, you should choose a lighter palette in dark mode. */
[data-theme='dark'] {
[data-theme="dark"] {
--ifm-color-primary: #25c2a0;
--ifm-color-primary-dark: #21af90;
--ifm-color-primary-darker: #1fa588;
@@ -28,3 +28,17 @@
--ifm-color-primary-lightest: #4fddbf;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
}
.twoColViewer .viewer-close {
right: 10px;
top: 10px;
width: 50px;
height: 50px;
}
/* Stupid poopin fix for viewerjs because whatever is bundling the css
isn't keeping the order of this correctly. All this time wasted and it
was just opaque ;( BUT ONLY IN THE BUILD AAAAAAAAAAAAAAAAAAAAAA */
.viewer-in {
opacity: 1 !important;
}
+2
View File
@@ -7,6 +7,7 @@ import LogoCol from "@site/static/img/logo-col.png";
import styles from "./index.module.css";
import clsx from "clsx";
import { HomepageTwoColFeats } from "../components/TwoColFeat";
function HomepageHeader() {
const { siteConfig } = useDocusaurusContext();
@@ -45,6 +46,7 @@ export default function Home() {
<HomepageHeader />
<main>
<HomepageFeatures />
<HomepageTwoColFeats />
</main>
</Layout>
);
+5 -1
View File
@@ -2,9 +2,13 @@ version: "3"
services:
watcharr:
# The :latest tag is used for simplicity, it is recommended
# to use an actual version, then when updating check the releases for changelogs.
image: ghcr.io/sbondco/watcharr:latest
container_name: watcharr
ports:
- 3080:3080
volumes:
- ./container_data:/data
# Contains all of watcharr data (database & cache)
- ./data:/data
restart: unless-stopped
+4936 -404
View File
File diff suppressed because it is too large Load Diff
+20 -16
View File
@@ -1,6 +1,6 @@
{
"name": "watcharr",
"version": "1.19.1",
"version": "1.35.2",
"private": true,
"scripts": {
"dev": "vite dev",
@@ -13,25 +13,29 @@
"server": "cd ./server && MODE=DEV go run ."
},
"devDependencies": {
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/kit": "^1.25.2",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.34.0",
"prettier": "^3.0.3",
"prettier-plugin-svelte": "^3.0.3",
"svelte": "^4.2.1",
"svelte-check": "^3.5.2",
"@sveltejs/adapter-node": "^4.0.1",
"@sveltejs/kit": "^2.5.3",
"@types/papaparse": "^5.3.14",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vite-pwa/sveltekit": "^0.3.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.1",
"svelte": "^4.2.10",
"svelte-check": "^3.6.4",
"svelte-eslint-parser": "^0.33.1",
"svelte-preprocess": "^5.0.4",
"svelte-preprocess": "^5.1.3",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^4.4.11"
"typescript": "^5.3.3",
"vite": "^5.1.6"
},
"type": "module",
"dependencies": {
"axios": "^1.5.1"
"axios": "^1.6.7",
"blurhash": "^2.0.5",
"papaparse": "^5.4.1"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 430 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 KiB

After

Width:  |  Height:  |  Size: 743 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 KiB

After

Width:  |  Height:  |  Size: 752 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 KiB

After

Width:  |  Height:  |  Size: 816 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

+73 -11
View File
@@ -3,6 +3,7 @@ package main
import (
"errors"
"log/slog"
"time"
"gorm.io/gorm"
)
@@ -10,13 +11,31 @@ import (
type ActivityType string
var (
ADDED_WATCHED ActivityType = "ADDED_WATCHED"
REMOVED_WATCHED ActivityType = "REMOVED_WATCHED"
RATING_CHANGED ActivityType = "RATING_CHANGED"
STATUS_CHANGED ActivityType = "STATUS_CHANGED"
THOUGHTS_CHANGED ActivityType = "THOUGHTS_CHANGED"
THOUGHTS_REMOVED ActivityType = "THOUGHTS_REMOVED"
IMPORTED_WATCHED ActivityType = "IMPORTED_WATCHED"
ADDED_WATCHED ActivityType = "ADDED_WATCHED"
REMOVED_WATCHED ActivityType = "REMOVED_WATCHED"
RATING_CHANGED ActivityType = "RATING_CHANGED"
STATUS_CHANGED ActivityType = "STATUS_CHANGED"
THOUGHTS_CHANGED ActivityType = "THOUGHTS_CHANGED"
THOUGHTS_REMOVED ActivityType = "THOUGHTS_REMOVED"
IMPORTED_WATCHED ActivityType = "IMPORTED_WATCHED"
IMPORTED_WATCHED_JF ActivityType = "IMPORTED_WATCHED_JF"
IMPORTED_WATCHED_PLEX ActivityType = "IMPORTED_WATCHED_PLEX"
IMPORTED_RATING ActivityType = "IMPORTED_RATING" // Imported rating, but with no rating acts as original import of content to old platform (where they are importing from) activity
IMPORTED_ADDED_WATCHED ActivityType = "IMPORTED_ADDED_WATCHED" // Imported watched date, so we can save the original watch dates of content from users old platform (where they are importing from).
IMPORTED_ADDED_WATCHED_JF ActivityType = "IMPORTED_ADDED_WATCHED_JF"
IMPORTED_ADDED_WATCHED_PLEX ActivityType = "IMPORTED_ADDED_WATCHED_PLEX"
SEASON_ADDED ActivityType = "SEASON_ADDED"
SEASON_ADDED_JF ActivityType = "SEASON_ADDED_JF"
SEASON_ADDED_PLEX ActivityType = "SEASON_ADDED_PLEX"
SEASON_REMOVED ActivityType = "SEASON_REMOVED"
SEASON_RATING_CHANGED ActivityType = "SEASON_RATING_CHANGED"
SEASON_STATUS_CHANGED ActivityType = "SEASON_STATUS_CHANGED"
EPISODE_ADDED ActivityType = "EPISODE_ADDED"
EPISODE_ADDED_JF ActivityType = "EPISODE_ADDED_JF"
EPISODE_ADDED_PLEX ActivityType = "EPISODE_ADDED_PLEX"
EPISODE_REMOVED ActivityType = "EPISODE_REMOVED"
EPISODE_RATING_CHANGED ActivityType = "EPISODE_RATING_CHANGED"
EPISODE_STATUS_CHANGED ActivityType = "EPISODE_STATUS_CHANGED"
)
type Activity struct {
@@ -31,12 +50,19 @@ type Activity struct {
// Holds custom data (ex, if rating changed, this can
// hold new rating - if status changed, this will hold that).
Data string `json:"data" gorm:"not null"`
// Custom date for the activity, that the user can define.
CustomDate *time.Time `json:"customDate,omitempty"`
}
type ActivityAddRequest struct {
WatchedID uint `json:"watchedId" binding:"required"`
Type ActivityType `json:"type" binding:"required"`
Data string `json:"data" binding:"required"`
WatchedID uint `json:"watchedId" binding:"required"`
Type ActivityType `json:"type" binding:"required"`
Data string `json:"data" binding:"required"`
CustomDate *time.Time `json:"customDate,omitempty"`
}
type ActivityUpdateRequest struct {
CustomDate time.Time `json:"customDate" binding:"required"`
}
func getActivity(db *gorm.DB, userId uint, watchedId uint) ([]Activity, error) {
@@ -53,7 +79,7 @@ func addActivity(db *gorm.DB, userId uint, ar ActivityAddRequest) (Activity, err
if ar.WatchedID == 0 {
return Activity{}, errors.New("watchedId must be set to add an activity")
}
activity := Activity{UserID: userId, WatchedID: ar.WatchedID, Type: ar.Type, Data: ar.Data}
activity := Activity{UserID: userId, WatchedID: ar.WatchedID, Type: ar.Type, Data: ar.Data, CustomDate: ar.CustomDate}
res := db.Create(&activity)
if res.Error != nil {
slog.Error("Error adding activity to database", "error", res.Error.Error())
@@ -62,3 +88,39 @@ func addActivity(db *gorm.DB, userId uint, ar ActivityAddRequest) (Activity, err
slog.Debug("Adding activity", "added_activity", activity)
return activity, nil
}
func updateActivity(db *gorm.DB, userId uint, id uint, activityUpdateRequest ActivityUpdateRequest) error {
if id == 0 {
return errors.New("id must be set to update an activity")
}
if activityUpdateRequest.CustomDate.IsZero() {
return errors.New("customDate must be set to update an activity")
}
res := db.Model(&Activity{}).Where("user_id = ? AND id = ?", userId, id).Update("custom_date", activityUpdateRequest.CustomDate)
if res.Error != nil {
slog.Error("Error updating activity in database", "error", res.Error.Error())
return errors.New("failed updating activity in database")
}
if res.RowsAffected < 1 {
slog.Error("No activities were updated. This may be because the activity doesn't exist or is not owned by the calling user.")
return errors.New("failed updating activity in database")
}
slog.Debug("Updating activity", "updated_activity", id)
return nil
}
func deleteActivity(db *gorm.DB, userId uint, id uint) error {
if id == 0 {
return errors.New("an id must be provided to delete an activity")
}
res := db.Where("user_id = ?", userId).Delete(&Activity{}, id)
if res.Error != nil {
slog.Error("Error deleting activity in database", "error", res.Error.Error())
return errors.New("failed deleting activity in database")
}
if res.RowsAffected < 1 {
slog.Error("No activities were deleted. This may be because the activity doesn't exist or is not owned by the calling user.")
return errors.New("failed deleting activity from database")
}
return nil
}
+204
View File
@@ -0,0 +1,204 @@
package main
import (
"errors"
"log/slog"
"github.com/sbondCo/Watcharr/arr"
)
type ArrSettings struct {
Name string `json:"name,omitempty"`
Host string `json:"host,omitempty"`
Key string `json:"key,omitempty"`
}
type SonarrSettings struct {
ArrSettings
QualityProfile int `json:"qualityProfile,omitempty"`
RootFolder int `json:"rootFolder,omitempty"`
LanguageProfile int `json:"languageProfile,omitempty"`
AutomaticSearch bool `json:"automaticSearch"`
// TODO eventually separate profiles and root for anime content (i can see diff language profile being useful)
}
func (s *SonarrSettings) safe() SonarrSettings {
s.Key = ""
return *s
}
type RadarrSettings struct {
ArrSettings
QualityProfile int `json:"qualityProfile,omitempty"`
RootFolder int `json:"rootFolder,omitempty"`
AutomaticSearch bool `json:"automaticSearch"`
}
func (s *RadarrSettings) safe() RadarrSettings {
s.Key = ""
return *s
}
type ArrTestParams struct {
Host string `json:"host,omitempty"`
Key string `json:"key,omitempty"`
}
type SonarrTestResponse struct {
QualityProfiles []arr.QualityProfile `json:"qualityProfiles"`
RootFolders []arr.RootFolder `json:"rootFolders"`
LanguageProfiles []arr.LanguageProfile `json:"languageProfiles"`
}
type RadarrTestResponse struct {
QualityProfiles []arr.QualityProfile `json:"qualityProfiles"`
RootFolders []arr.RootFolder `json:"rootFolders"`
LanguageProfiles []arr.LanguageProfile `json:"languageProfiles"`
}
func testSonarr(p ArrTestParams) (SonarrTestResponse, error) {
sonarr := arr.New(arr.SONARR, &p.Host, &p.Key)
qps, err := sonarr.GetQualityProfiles()
if err != nil {
slog.Error("testSonarr failed to get quality profiles!", "error", err)
return SonarrTestResponse{}, errors.New("failed to get quality profiles")
}
rfs, err := sonarr.GetRootFolders()
if err != nil {
slog.Error("testSonarr failed to get root folders!", "error", err)
return SonarrTestResponse{}, errors.New("failed to get root folders")
}
lps, err := sonarr.GetLangaugeProfiles()
if err != nil {
slog.Error("testSonarr failed to get language profiles!", "error", err)
return SonarrTestResponse{}, errors.New("failed to get language profiles")
}
return SonarrTestResponse{QualityProfiles: qps, RootFolders: rfs, LanguageProfiles: lps}, nil
}
func testRadarr(p ArrTestParams) (RadarrTestResponse, error) {
radarr := arr.New(arr.RADARR, &p.Host, &p.Key)
qps, err := radarr.GetQualityProfiles()
if err != nil {
slog.Error("testRadarr failed to get quality profiles!", "error", err)
return RadarrTestResponse{}, errors.New("failed to get quality profiles")
}
rfs, err := radarr.GetRootFolders()
if err != nil {
slog.Error("testRadarr failed to get root folders!", "error", err)
return RadarrTestResponse{}, errors.New("failed to get root folders")
}
return RadarrTestResponse{QualityProfiles: qps, RootFolders: rfs}, nil
}
// TODO any way to simplify (deduplicate/reuse) these methods (and the whole file tbh) would be very good
// Add sonarr server to config
func addSonarr(s SonarrSettings) error {
for _, v := range Config.SONARR {
if v.Name == s.Name {
// Server exists with this name...
return errors.New("server with that name already exists")
}
}
Config.SONARR = append(Config.SONARR, s)
writeConfig()
return nil
}
// Edit sonarr server in config
func editSonarr(s SonarrSettings) error {
for i, v := range Config.SONARR {
if v.Name == s.Name {
Config.SONARR[i] = s
writeConfig()
return nil
}
}
return errors.New("can't edit server that does not exist")
}
func rmSonarr(name string) error {
for i, v := range Config.SONARR {
if v.Name == name {
Config.SONARR = append(Config.SONARR[:i], Config.SONARR[i+1:]...)
writeConfig()
return nil
}
}
return errors.New("can't remove a server that does not exist")
}
func getSonarr(name string) (SonarrSettings, error) {
for i, v := range Config.SONARR {
if v.Name == name {
return Config.SONARR[i], nil
}
}
return SonarrSettings{}, errors.New("server not found")
}
// Get list of sonarr servers without api keys.
// Regular users with access to adding to sonarr will request this.
func getSonarrsSafe() []SonarrSettings {
s := []SonarrSettings{}
for _, v := range Config.SONARR {
s = append(s, v.safe())
}
return s
}
// Add radarr server to config
func addRadarr(s RadarrSettings) error {
for _, v := range Config.RADARR {
if v.Name == s.Name {
// Server exists with this name...
return errors.New("server with that name already exists")
}
}
Config.RADARR = append(Config.RADARR, s)
writeConfig()
return nil
}
// Edit radarr server in config
func editRadarr(s RadarrSettings) error {
for i, v := range Config.RADARR {
if v.Name == s.Name {
Config.RADARR[i] = s
writeConfig()
return nil
}
}
return errors.New("can't edit server that does not exist")
}
func rmRadarr(name string) error {
for i, v := range Config.RADARR {
if v.Name == name {
Config.RADARR = append(Config.RADARR[:i], Config.RADARR[i+1:]...)
writeConfig()
return nil
}
}
return errors.New("can't remove a server that does not exist")
}
func getRadarr(name string) (RadarrSettings, error) {
for i, v := range Config.RADARR {
if v.Name == name {
return Config.RADARR[i], nil
}
}
return RadarrSettings{}, errors.New("server not found")
}
// Get list of radarr servers without api keys.
// Regular users with access to adding to radarr will request this.
func getRadarrsSafe() []RadarrSettings {
s := []RadarrSettings{}
for _, v := range Config.RADARR {
s = append(s, v.safe())
}
return s
}
+235
View File
@@ -0,0 +1,235 @@
// Sonarr and Radarr
package arr
import (
"bytes"
"encoding/json"
"errors"
"io"
"log/slog"
"net/http"
"net/url"
)
type ArrType string
var (
SONARR ArrType = "SONARR"
RADARR ArrType = "RADARR"
)
type Arr struct {
// Type of Arr we want to use.
// Each servars api might differ, so this will
// allow us to make those changes when needed.
Type ArrType
// Hostname to the Arr sever
Host *string
// Api key for the Arr server.
Key *string
}
type ArrRequest struct {
ServerName string `json:"serverName"`
QualityProfile int `json:"qualityProfile"` // id
RootFolder string `json:"rootFolder"` // path
AutomaticSearch bool `json:"automaticSearch"`
Title string `json:"title"` // content name
Year int `json:"year"` // content year
}
type SonarrRequest struct {
ArrRequest
TVDBID int `json:"tvdbId"`
LanguageProfile int `json:"languageProfile"` // id
SeriesType string `json:"seriesType"`
Seasons []SonarrSeasons `json:"seasons"`
}
type RadarrRequest struct {
ArrRequest
TMDBID int `json:"tmdbId"`
}
type SonarrSeasons struct {
SeasonNumber int `json:"seasonNumber"`
Monitored bool `json:"monitored"`
}
func New(t ArrType, host *string, key *string) *Arr {
return &Arr{
Type: t,
Host: host,
Key: key,
}
}
func (a *Arr) GetQualityProfiles() ([]QualityProfile, error) {
slog.Info("GetQualityProfiles", "type", a.Type, "host", *a.Host, "key", *a.Key)
var resp []QualityProfile
err := request(*a.Host, "/qualityprofile", map[string]string{"apikey": *a.Key}, &resp)
if err != nil {
slog.Error("GetQualityProfiles request failed", "service", a.Type, "error", err)
return []QualityProfile{}, errors.New("request to service failed")
}
return resp, nil
}
func (a *Arr) GetRootFolders() ([]RootFolder, error) {
slog.Info("GetRootFolders", "type", a.Type, "host", *a.Host, "key", *a.Key)
var resp []RootFolder
err := request(*a.Host, "/rootfolder", map[string]string{"apikey": *a.Key}, &resp)
if err != nil {
slog.Error("GetRootFolders request failed", "service", a.Type, "error", err)
return []RootFolder{}, errors.New("request to service failed")
}
return resp, nil
}
func (a *Arr) GetLangaugeProfiles() ([]LanguageProfile, error) {
slog.Info("GetLangaugeProfiles", "type", a.Type, "host", *a.Host, "key", *a.Key)
var resp []LanguageProfile
// languageprofile supposedly deprecated.. but new language endpoint doesnt seem to work.. note probs to switch soon
err := request(*a.Host, "/languageprofile", map[string]string{"apikey": *a.Key}, &resp)
if err != nil {
slog.Error("GetLangaugeProfiles request failed", "service", a.Type, "error", err)
return []LanguageProfile{}, errors.New("request to service failed")
}
return resp, nil
}
// TODO do title! and year?
func (a *Arr) BuildAddShowBody(r SonarrRequest) map[string]interface{} {
req := map[string]interface{}{
"title": r.Title,
"year": r.Year,
"qualityProfileId": r.QualityProfile,
"languageProfileId": r.LanguageProfile,
"seasonFolder": true,
"monitored": true,
"tvdbId": r.TVDBID,
"seriesType": r.SeriesType,
"seasons": r.Seasons,
"addOptions": map[string]interface{}{
"ignoreEpisodesWithFiles": true,
"searchForMissingEpisodes": r.AutomaticSearch,
},
"rootFolderPath": r.RootFolder,
}
return req
}
func (a *Arr) BuildAddMovieBody(r RadarrRequest) map[string]interface{} {
req := map[string]interface{}{
"title": r.Title,
"year": r.Year,
"qualityProfileId": r.QualityProfile,
"monitored": true,
"tmdbId": r.TMDBID,
"addOptions": map[string]interface{}{
"searchForMovie": r.AutomaticSearch,
},
"rootFolderPath": r.RootFolder,
}
return req
}
func (a *Arr) AddContent(b map[string]interface{}) error {
ep := "series"
if a.Type == RADARR {
ep = "movie"
}
slog.Debug("AddContent", "type", ep, "body", b)
var resp interface{}
err := requestPost(*a.Host, "/"+ep, *a.Key, b, &resp)
if err != nil {
slog.Error("AddContent request failed", "service", a.Type, "error", err)
return errors.New("request to service failed")
}
return nil
}
func request(host string, ep string, p map[string]string, resp interface{}) error {
slog.Debug("tmdbAPIRequest", "endpoint", ep, "params", p)
base, err := url.Parse(host)
if err != nil {
return errors.New("failed to parse api uri")
}
// Path params
base.Path += "/api/v3" + ep
// Query params
params := url.Values{}
for k, v := range p {
params.Add(k, v)
}
// Add params to url
base.RawQuery = params.Encode()
// Run get request
res, err := http.Get(base.String())
if err != nil {
return err
}
body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return err
}
if res.StatusCode != 200 {
slog.Error("arr non 200 status code:", "status_code", res.StatusCode)
return errors.New(string(body))
}
// slog.Info("", "body", body)
err = json.Unmarshal([]byte(body), &resp)
if err != nil {
return err
}
return nil
}
func requestPost(host string, ep string, key string, p map[string]interface{}, resp interface{}) error {
base, err := url.Parse(host)
if err != nil {
return errors.New("failed to parse api uri")
}
// Path params
base.Path += "/api/v3" + ep
var res *http.Response
// Query params
params := url.Values{}
params.Add("apikey", key)
// Add params to url
base.RawQuery = params.Encode()
jsonp, err := json.Marshal(p)
if err != nil {
return err
}
res, err = http.Post(base.String(), "application/json", bytes.NewBuffer(jsonp))
if err != nil {
return err
}
body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return err
}
if !(res.StatusCode >= 200 && res.StatusCode <= 299) {
slog.Error("arr non 2xx status code:", "status_code", res.StatusCode)
return errors.New(string(body))
}
err = json.Unmarshal([]byte(body), &resp)
if err != nil {
return err
}
return nil
}
+45
View File
@@ -0,0 +1,45 @@
package arr
type QualityProfile struct {
Name string `json:"name"`
UpgradeAllowed bool `json:"upgradeAllowed"`
Cutoff int `json:"cutoff"`
Items []struct {
Quality struct {
ID int `json:"id"`
Name string `json:"name"`
Source string `json:"source"`
Resolution int `json:"resolution"`
} `json:"quality,omitempty"`
Items []any `json:"items"`
Allowed bool `json:"allowed"`
Name string `json:"name,omitempty"`
ID int `json:"id,omitempty"`
} `json:"items"`
ID int `json:"id"`
}
type RootFolder struct {
Path string `json:"path"`
Accessible bool `json:"accessible"`
FreeSpace int64 `json:"freeSpace"`
UnmappedFolders []any `json:"unmappedFolders"`
ID int `json:"id"`
}
type LanguageProfile struct {
Name string `json:"name"`
UpgradeAllowed bool `json:"upgradeAllowed"`
Cutoff struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"cutoff"`
Languages []struct {
Language struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"language"`
Allowed bool `json:"allowed"`
} `json:"languages"`
ID int `json:"id"`
}
+179 -12
View File
@@ -14,6 +14,7 @@ import (
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
@@ -28,6 +29,7 @@ type UserType uint8
var (
// Assume watcharr user if none of these...
JELLYFIN_USER UserType = 1
PLEX_USER UserType = 2
)
// User Perms
@@ -46,6 +48,9 @@ type User struct {
GormModel
Username string `gorm:"uniqueIndex:usr_name_to_type;not null" json:"username" binding:"required"`
Password string `gorm:"not null" json:"password" binding:"required"`
AvatarID uint `json:"-"`
Avatar Image `json:"avatar"`
Bio string `json:"bio"`
// The type of user/which auth service they originate from.
// Empty if from Watcharr, or the name of the service (eg. jellyfin)
Type UserType `gorm:"uniqueIndex:usr_name_to_type;not null;default:0" json:"type"`
@@ -53,15 +58,60 @@ type User struct {
ThirdPartyID string `json:"-"`
// Auth token from third party (jellyfin)
ThirdPartyAuth string `json:"-"`
Watched []Watched
Permissions int `gorm:"default:1" json:"-"`
// Users third party integrations (minus jellyfin for now)
UserServices []UserServices `json:"-"`
Watched []Watched
Permissions int `gorm:"default:1" json:"-"`
// All user settings cols, in another struct for reusability
UserSettings
}
func (u *User) GetSafe() PublicUser {
return PublicUser{
ID: u.ID,
Username: u.Username,
Avatar: u.Avatar,
Bio: u.Bio,
}
}
// This struct uses pointer to the values, so in update user settings,
// we can tell which setting is being updated (if not nil..).
type UserSettings struct {
// Is profile private
Private bool `gorm:"default:false" json:"private"`
Private *bool `gorm:"default:false" json:"private"`
// Are watched list content thoughts public (profile must also be public is false)
PrivateThoughts *bool `gorm:"default:false" json:"privateThoughts"`
// If ui 'spoilers' should be shown
HideSpoilers *bool `gorm:"default:false" json:"hideSpoilers"`
// If user wants previously watched items to show in 'Finished' filter,
// even if the watched item state has since been changed.
// Also if user wants to show in watched stats.
IncludePreviouslyWatched *bool `gorm:"default:false" json:"includePreviouslyWatched"`
}
// Holds third party service auth tokens for users.
// Each service may use the fields in their own way.
// Unique index applied between service name and clientID
// to ensure no duplicates (no need to apply it against
// user_id, no accounts should share an integration).
//
// Plex:
// - AuthToken : Used for requests against plex.tv
// - AuthToken2 : Used for requests against home plex server.
type UserServices struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
// Service/integration name
Name string `gorm:"uniqueIndex:svc_name_to_cltid;not null;" json:"-"`
// The users id on the third party service
ClientID string `gorm:"uniqueIndex:svc_name_to_cltid;not null;" json:"-"`
AuthToken string `gorm:"not null;" json:"-"`
// Second auth token, generic name so future services can use it without extra confusion.
// Ex: We require a second auth token for use with our local server for Plex.
AuthToken2 string `json:"-"`
UserID uint `gorm:"not null;" json:"-"`
}
// We use a separate struct for registration to avoid confusion
@@ -107,6 +157,16 @@ type ArgonParams struct {
keyLength uint32
}
func GetPassArgonParams() *ArgonParams {
return &ArgonParams{
memory: 64 * 1024,
iterations: 3,
parallelism: 2,
saltLength: 16,
keyLength: 32,
}
}
type TokenClaims struct {
UserID uint `json:"userId"`
Username string `json:"username"`
@@ -114,6 +174,11 @@ type TokenClaims struct {
jwt.RegisteredClaims
}
type UserPasswordUpdateRequest struct {
OldPassword string `json:"oldPassword" binding:"required"`
NewPassword string `json:"newPassword" binding:"required"`
}
// Auth middleware
// If db is passed, extra user info from the database will be fetched.
func AuthRequired(db *gorm.DB) gin.HandlerFunc {
@@ -196,13 +261,7 @@ func register(ur *UserRegisterRequest, initialPerm int, db *gorm.DB) (AuthRespon
}
var user User = User{Username: ur.Username, Password: ur.Password}
slog.Info("A user is registering", "username", user.Username)
hash, err := hashPassword(user.Password, &ArgonParams{
memory: 64 * 1024,
iterations: 3,
parallelism: 2,
saltLength: 16,
keyLength: 32,
})
hash, err := hashPassword(user.Password, GetPassArgonParams())
if err != nil {
log.Fatal(err)
}
@@ -219,7 +278,7 @@ func register(ur *UserRegisterRequest, initialPerm int, db *gorm.DB) (AuthRespon
res := db.Create(&user)
if res.Error != nil {
// If error is because unique contraint failed.. user already exists
if strings.Contains(res.Error.Error(), "UNIQUE") {
if res.Error == gorm.ErrDuplicatedKey {
slog.Error("Registration failed", "error", res.Error.Error(), "error_pretty", "User already exists")
return AuthResponse{}, errors.New("User already exists")
}
@@ -338,7 +397,7 @@ func loginJellyfin(user *User, db *gorm.DB) (AuthResponse, error) {
}
dbUser := new(User)
dbRes := db.Where("third_party_id = ?", resp.User.ID).Take(&dbUser)
dbRes := db.Where("third_party_id = ? AND type = ?", resp.User.ID, JELLYFIN_USER).Take(&dbUser)
if dbRes.Error != nil {
if errors.Is(dbRes.Error, gorm.ErrRecordNotFound) {
// Record not found, so we should create the user
@@ -372,6 +431,79 @@ func loginJellyfin(user *User, db *gorm.DB) (AuthResponse, error) {
return AuthResponse{Token: token}, nil
}
// Login via Plex.
func loginPlex(lr *PlexLoginRequest, db *gorm.DB) (AuthResponse, error) {
if Config.PLEX_HOST == "" || Config.PLEX_MACHINE_ID == "" {
slog.Error("Request made to login via Plex, but Plex authentication is disabled")
return AuthResponse{}, errors.New("plex login not enabled")
}
slog.Debug("A Plex User Is Logging In")
account, err := fetchPlexAccountFromToken(lr.AuthToken)
if err != nil {
slog.Error("loginPlex: Could not fetch Plex account", "error", err)
return AuthResponse{}, errors.New("could not fetch plex acount")
}
if account.Username == "" || account.Id == 0 {
slog.Error("loginPlex: Username or id missing from account response:", "username", account.Username, "id", account.Id)
return AuthResponse{}, errors.New("data is missing from the plex account response")
}
dbUser := new(User)
userIdQ := db.Select("user_id").Where("name = ? AND client_id = ?", "plex", account.Id).Table("user_services")
dbRes := db.Where("type = ?", PLEX_USER).Where("id = (?)", userIdQ).Preload("UserServices").Take(&dbUser)
if dbRes.Error != nil {
if errors.Is(dbRes.Error, gorm.ErrRecordNotFound) {
slog.Debug("loginPlex: New plex user attempted login.. creating Watcharr account now.")
if err := plexUserHasAccessToPlexHost(lr.AuthToken); err != nil {
slog.Error("loginPlex: Cannot register Plex user. Failed to verify they have access to our home plex server.", "error", err)
return AuthResponse{}, errors.New("failed to verify plex access")
}
dbUser.Username = account.Username
dbUser.Type = PLEX_USER
homeAuthToken, err := getPlexHomeServerAuthToken(lr.AuthToken, lr.ClientIdentifier)
if err != nil {
slog.Error("loginPlex: Failed to get home server auth token for the new user! User will still be created, a re-login may fix this issue.", "error", err)
}
dbUser.UserServices = append(dbUser.UserServices, UserServices{
Name: "plex",
ClientID: strconv.FormatUint(account.Id, 10),
AuthToken: lr.AuthToken,
AuthToken2: homeAuthToken,
})
dbRes = db.Create(&dbUser)
if dbRes.Error != nil {
slog.Error("loginPlex: Failed to create new user in db from plex response", "error", dbRes.Error)
return AuthResponse{}, errors.New("failed to create new user from plex")
}
} else {
slog.Error("loginPlex: Failed to select user from database for login", "error", dbRes.Error)
return AuthResponse{}, errors.New("failed to locate user")
}
} else {
// If user exists.. update their access tokens in db
homeAuthToken, err := getPlexHomeServerAuthToken(lr.AuthToken, lr.ClientIdentifier)
if err != nil {
slog.Error("loginPlex: Failed to get home server auth token!", "error", err)
}
for i, v := range dbUser.UserServices {
if v.Name == "plex" {
slog.Info("loginPlex: Found plex user service.. attemping to update")
dbUser.UserServices[i].AuthToken = lr.AuthToken
if homeAuthToken != "" {
dbUser.UserServices[i].AuthToken2 = homeAuthToken
}
break
}
}
db.Save(&dbUser.UserServices)
}
token, err := signJWT(dbUser)
if err != nil {
slog.Error("loginPlex: Failed to sign new jwt", "error", err)
return AuthResponse{}, errors.New("failed to get auth token")
}
return AuthResponse{Token: token}, nil
}
func useAdminToken(req *UseAdminTokenRequest, db *gorm.DB, userId uint) error {
var dbToken Token
resp := db.Where("value = ?", req.Token).Take(&dbToken)
@@ -521,3 +653,38 @@ func hasPermission(perms int, reqPerm int) bool {
}
return (perms & reqPerm) == reqPerm
}
func userChangePassword(db *gorm.DB, pwds UserPasswordUpdateRequest, userId uint) error {
slog.Debug("userChangePassword request running", "user_id", userId)
user := new(User)
res := db.Where("id = ?", userId).Select("password").Take(&user)
if res.Error != nil {
slog.Error("userChangePassword failed - failed to retrieve user from database", "user_id", userId, "error", res.Error)
return errors.New("failed to retrieve user")
}
slog.Debug("userChangePassword user found", "user_id", userId)
match, err := compareHash(pwds.OldPassword, user.Password)
if err != nil {
slog.Error("userChangePassword failed - failed to compare passwords", "user_id", userId, "error", err)
return errors.New("failed to compare passwords")
}
if !match {
slog.Error("userChangePassword failed - current password hash doesn't match password hash in database", "user_id", userId, "error", err)
return errors.New("current password provided doesn't match password in database")
}
slog.Debug("userChangePassword hash for current password matches hash in the database", "user_id", userId)
slog.Debug("userChangePassword hashing new password", "user_id", userId)
hash, err := hashPassword(pwds.NewPassword, GetPassArgonParams())
if err != nil {
slog.Error("userChangePassword failed - failed to hash new password", "user_id", userId, "error", err)
return errors.New("failed to hash new password")
}
slog.Debug("userChangePassword new password hashed", "user_id", userId)
if err := db.Model(&User{}).Where("id = ?", userId).Update("password", hash).Error; err != nil {
slog.Error("userChangePassword failed - failed to update password in database", "user_id", userId, "error", err)
return errors.New("failed to update password")
} else {
slog.Debug("userChangePassword password updated", "user_id", userId)
}
return nil
}
+158 -10
View File
@@ -6,8 +6,14 @@ import (
"log"
"log/slog"
"os"
"time"
"github.com/sbondCo/Watcharr/game"
"gorm.io/gorm"
)
var DataPath = "./data"
type ServerConfig struct {
// Used to sign JWT tokens. Make sure to make
// it strong, just like a very long, complicated password.
@@ -19,12 +25,25 @@ type ServerConfig struct {
// Enable/disable signup functionality.
// Set to `false` to disable registering an account.
SIGNUP_ENABLED bool `json:",omitempty"`
SIGNUP_ENABLED bool
// Optional: Provide your own TMDB API Key.
// If unprovided, the default Watcharr API key will be used.
TMDB_KEY string `json:",omitempty"`
// Optional: Point to Plex install to enable plex features.
PLEX_HOST string `json:",omitempty"`
// Optional: Machine identifier of your Plex server.
// This is used to ensure only users of your Plex server
// can use this Watcharr instance.
// Will be fetched automatically when PLEX_HOST is provided via web ui.
PLEX_MACHINE_ID string `json:",omitempty"`
SONARR []SonarrSettings `json:",omitempty"`
RADARR []RadarrSettings `json:",omitempty"`
TWITCH game.IGDB `json:",omitempty"`
// Enable/disable debug logging. Useful for when trying
// to figure out exactly what the server is doing at a point
// of failure.
@@ -32,12 +51,32 @@ type ServerConfig struct {
DEBUG bool `json:",omitempty"`
}
var (
// Our server config.. set defaults here, then `readConfig`
// will overwrite if provided in watcharr.json cfg file.
Config = ServerConfig{
SIGNUP_ENABLED: true,
// ServerConfig, but with JWT_SECRET removed from json.
// Used for returning to user from get config api request.
//
// Technically only admins will have access to that api route,
// but I feel more comfortable removing it anyways (+ this is
// not editable on frontend, so not needed).
func (c *ServerConfig) GetSafe() ServerConfig {
return ServerConfig{
SIGNUP_ENABLED: c.SIGNUP_ENABLED,
JELLYFIN_HOST: c.JELLYFIN_HOST,
TMDB_KEY: c.TMDB_KEY,
PLEX_HOST: c.PLEX_HOST,
PLEX_MACHINE_ID: c.PLEX_MACHINE_ID,
DEBUG: c.DEBUG,
SONARR: c.SONARR, // Dont act safe, this contains sonarr api key, needed for config
RADARR: c.RADARR, // Dont act safe, this contains radarr api key, needed for config
TWITCH: game.IGDB{
ClientID: c.TWITCH.ClientID,
ClientSecret: c.TWITCH.ClientSecret,
}, // Dont act safe, this contains twitch secrets, needed for config
}
}
var (
// Our server config.. `readConfig` will overwrite from watcharr.json cfg file.
Config = ServerConfig{}
)
// Read config file
@@ -71,19 +110,22 @@ func initFromConfig() error {
}
// Generate new barebones watcharr.json config file.
// Currently only JWT_SECRET is required, so this method
// generates a secret.
// Generates a JWT_SECRET and set default config.
func generateConfig() error {
key, err := generateString(64)
if err != nil {
return err
}
cfg := ServerConfig{JWT_SECRET: key}
cfg := ServerConfig{
JWT_SECRET: key,
// Other defaults..
SIGNUP_ENABLED: true,
}
barej, err := json.MarshalIndent(cfg, "", "\t")
if err != nil {
return err
}
Config.JWT_SECRET = cfg.JWT_SECRET
Config = cfg
return os.WriteFile("./data/watcharr.json", barej, 0755)
}
@@ -116,3 +158,109 @@ func writeConfig() error {
}
return os.WriteFile("./data/watcharr.json", barej, 0755)
}
type ServerFeatures struct {
Sonarr bool `json:"sonarr"`
Radarr bool `json:"radarr"`
Games bool `json:"games"`
}
// Get enabled server functionality from Config.
// Mainly so the frontend can store this once and know
// which btns should be shown, etc.
func getEnabledFeatures(userPerms int) ServerFeatures {
var f ServerFeatures
if Config.TWITCH.ClientID != nil && Config.TWITCH.ClientSecret != nil {
f.Games = true
}
// https://github.com/sbondCo/Watcharr/issues/211
// Currently requesting permissions have not been setup, only admins for now.
if !hasPermission(userPerms, PERM_ADMIN) {
return f
}
if len(Config.SONARR) > 0 {
f.Sonarr = true
}
if len(Config.RADARR) > 0 {
f.Radarr = true
}
return f
}
func saveTwitchConfig(c game.IGDB) error {
// If existing client id and secret are same.. just return here
if (Config.TWITCH.ClientID != nil && c.ClientID != nil && Config.TWITCH.ClientSecret != nil && c.ClientSecret != nil) &&
*Config.TWITCH.ClientID == *c.ClientID && *Config.TWITCH.ClientSecret == *c.ClientSecret {
slog.Info("saveTwitchConfig: New ClientID and ClientSecret match old ClientID and ClientSecret.. ignoring request to update.")
return nil
}
// Update our config
Config.TWITCH.ClientID = c.ClientID
Config.TWITCH.ClientSecret = c.ClientSecret
Config.TWITCH.AccessToken = ""
Config.TWITCH.AccessTokenExpires = time.Time{}
// Try to init again
err := Config.TWITCH.Init()
if err != nil {
slog.Error("saveTwitchConfig failed to initialize TWITCH", "error", err)
return errors.New("initialization with credentials failed")
}
err = writeConfig()
if err != nil {
slog.Error("saveTwitchConfig failed to write config", "error", err)
return errors.New("failed to save config")
}
return nil
}
type ServerStats struct {
Users int64 `json:"users"`
PrivateUsers int64 `json:"privateUsers"`
WatchedMovies int64 `json:"watchedMovies"`
WatchedShows int64 `json:"watchedShows"`
WatchedSeasons int64 `json:"watchedSeasons"`
MostWatchedMovie Content `json:"mostWatchedMovie"`
MostWatchedShow Content `json:"mostWatchedShow"`
Activities int64 `json:"activities"`
}
// Collect and return server stats
// I cant sql so this the best yall gettin
func getServerStats(db *gorm.DB) ServerStats {
stats := ServerStats{}
resp := db.Model(&User{}).Count(&stats.Users).Where("private = 1").Count(&stats.PrivateUsers)
if resp.Error != nil {
slog.Error("getServerStats - Users query failed", "error", resp.Error)
}
resp = db.Model(&WatchedSeason{}).Count(&stats.WatchedSeasons)
if resp.Error != nil {
slog.Error("getServerStats - WatchedSeasons query failed", "error", resp.Error)
}
resp = db.Model(&Activity{}).Count(&stats.Activities)
if resp.Error != nil {
slog.Error("getServerStats - Activities query failed", "error", resp.Error)
}
resp = db.Joins("JOIN contents ON contents.id = watcheds.content_id AND contents.type = ?", "tv").Find(&Watched{}).Count(&stats.WatchedShows)
if resp.Error != nil {
slog.Error("getServerStats - WatchedShows query failed", "error", resp.Error)
}
resp = db.Joins("JOIN contents ON contents.id = watcheds.content_id AND contents.type = ?", "movie").Find(&Watched{}).Count(&stats.WatchedMovies)
if resp.Error != nil {
slog.Error("getServerStats - WatchedMovies query failed", "error", resp.Error)
}
var w Watched
resp = db.Model(&Watched{}).Select("content_id, COUNT(*) AS mag").Joins("JOIN contents ON contents.type = ? AND contents.id = watcheds.content_id", "tv").Group("content_id").Order("mag DESC").Preload("Content").First(&w)
if resp.Error != nil {
slog.Error("getServerStats - MostWatchedShow query failed", "error", resp.Error)
} else {
stats.MostWatchedShow = *w.Content
}
resp = db.Model(&Watched{}).Select("content_id, COUNT(*) AS mag").Joins("JOIN contents ON contents.type = ? AND contents.id = watcheds.content_id", "movie").Group("content_id").Order("mag DESC").Preload("Content").First(&w)
if resp.Error != nil {
slog.Error("getServerStats - MostWatchedMovie query failed", "error", resp.Error)
} else {
stats.MostWatchedMovie = *w.Content
}
return stats
}
+143 -5
View File
@@ -3,7 +3,11 @@ package main
import (
"errors"
"log/slog"
"path"
"time"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
type ContentType string
@@ -34,6 +38,138 @@ type Content struct {
NumberOfSeasons uint32 `json:"numberOfSeasons"`
}
// onlyUpdate - If we should only update existing row if exists, or false to create/update if not exist.
func saveContent(db *gorm.DB, c *Content, onlyUpdate bool) error {
slog.Info("Saving content to db", "id", c.TmdbID, "title", c.Title)
if c.TmdbID == 0 || c.Title == "" || c.Type == "" {
slog.Error("saveContent: content missing id, title or type!", "id", c.TmdbID, "title", c.Title, "type", c.Type)
return errors.New("content missing id or title")
}
var res *gorm.DB
if onlyUpdate {
// We only want to update an existing row, if it exists.
res = db.Model(&Content{}).Where("type = ? AND tmdb_id = ?", c.Type, c.TmdbID).Updates(c)
if res.Error != nil {
slog.Error("saveContent: Error updating content in database", "error", res.Error.Error())
return errors.New("failed to update cached content in database")
}
} else {
// On conflict, update existing row with details incase any were updated/missing.
res = db.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "tmdb_id"}, {Name: "type"}},
DoUpdates: clause.AssignmentColumns([]string{
"title",
"poster_path",
"overview",
"release_date",
"popularity",
"vote_average",
"vote_count",
"imdb_id",
"status",
"budget",
"revenue",
"runtime",
"number_of_episodes",
"number_of_seasons",
}),
}).Create(&c)
if res.Error != nil {
// Error if anything but unique contraint error
if res.Error != gorm.ErrDuplicatedKey {
slog.Error("saveContent: Error creating content in database", "error", res.Error.Error())
return errors.New("failed to cache content in database")
}
}
}
// If row created, download the image
if res.RowsAffected > 0 {
slog.Debug("saveContent: Downloading poster.")
err := download("https://image.tmdb.org/t/p/w500"+c.PosterPath, path.Join("./data/img", c.PosterPath))
if err != nil {
slog.Error("saveContent: Failed to download content image!", "error", err.Error())
}
}
return nil
}
func cacheContentTv(db *gorm.DB, content TMDBShowDetails, onlyUpdate bool) (Content, error) {
slog.Debug("cacheContentTv", "content", content)
var (
releaseDate time.Time
runtime uint32
)
var dateFormat = "2006-01-02"
releaseDate, err := time.Parse(dateFormat, content.FirstAirDate)
if err != nil {
slog.Error("Failed to parse tv release date", "error", err)
}
if len(content.EpisodeRunTime) > 0 {
runtime = uint32(content.EpisodeRunTime[0])
}
c := Content{
TmdbID: content.ID,
Title: content.Name,
Overview: content.Overview,
PosterPath: content.PosterPath,
Type: SHOW,
ReleaseDate: &releaseDate,
Popularity: content.Popularity,
VoteAverage: content.VoteAverage,
VoteCount: content.VoteCount,
Status: content.Status,
Runtime: runtime,
NumberOfEpisodes: content.NumberOfEpisodes,
NumberOfSeasons: content.NumberOfSeasons,
}
err = saveContent(db, &c, onlyUpdate)
if err != nil {
slog.Error("cacheContentTv: Failed to save content!", "error", err)
return Content{}, errors.New("failed to save content")
}
return c, nil
}
func cacheContentMovie(db *gorm.DB, content TMDBMovieDetails, onlyUpdate bool) (Content, error) {
var (
releaseDate time.Time
)
var dateFormat = "2006-01-02"
// Get details from movie/show response and fill out needed vars
releaseDate, err := time.Parse(dateFormat, content.ReleaseDate)
if err != nil {
slog.Error("Failed to parse movie release date", "error", err)
}
c := Content{
TmdbID: content.ID,
Title: content.Title,
Overview: content.Overview,
PosterPath: content.PosterPath,
Type: MOVIE,
ReleaseDate: &releaseDate,
Popularity: content.Popularity,
VoteAverage: content.VoteAverage,
VoteCount: content.VoteCount,
ImdbID: content.ImdbID,
Status: content.Status,
Budget: content.Budget,
Revenue: content.Revenue,
Runtime: content.Runtime,
}
err = saveContent(db, &c, onlyUpdate)
if err != nil {
slog.Error("cacheContentMovie: Failed to save content!", "error", err)
return Content{}, errors.New("failed to save content")
}
return c, nil
}
// Getting only region needed from api is not a feature yet
// https://trello.com/c/75tR4cpF/106-add-watch-provider-region-filtering
// When it is, this can be removed for that instead.
@@ -68,7 +204,7 @@ func searchContent(query string) (TMDBSearchMultiResponse, error) {
return *resp, nil
}
func movieDetails(id string, country string, rParams map[string]string) (TMDBMovieDetails, error) {
func movieDetails(db *gorm.DB, id string, country string, rParams map[string]string) (TMDBMovieDetails, error) {
resp := new(TMDBMovieDetails)
err := tmdbRequest("/movie/"+id, rParams, &resp)
if err != nil {
@@ -76,6 +212,7 @@ func movieDetails(id string, country string, rParams map[string]string) (TMDBMov
return TMDBMovieDetails{}, errors.New("failed to complete movie details request")
}
transformProviders(&resp.WatchProviders, country)
go cacheContentMovie(db, *resp, true)
return *resp, nil
}
@@ -89,7 +226,7 @@ func movieCredits(id string) (TMDBContentCredits, error) {
return *resp, nil
}
func tvDetails(id string, country string, rParams map[string]string) (TMDBShowDetails, error) {
func tvDetails(db *gorm.DB, id string, country string, rParams map[string]string) (TMDBShowDetails, error) {
resp := new(TMDBShowDetails)
err := tmdbRequest("/tv/"+id, rParams, &resp)
if err != nil {
@@ -97,6 +234,7 @@ func tvDetails(id string, country string, rParams map[string]string) (TMDBShowDe
return TMDBShowDetails{}, errors.New("failed to complete tv details request")
}
transformProviders(&resp.WatchProviders, country)
go cacheContentTv(db, *resp, true)
return *resp, nil
}
@@ -104,7 +242,7 @@ func tvCredits(id string) (TMDBContentCredits, error) {
resp := new(TMDBContentCredits)
err := tmdbRequest("/tv/"+id+"/credits", map[string]string{}, &resp)
if err != nil {
slog.Error("Failed to complete tv cast request!", err.Error())
slog.Error("Failed to complete tv cast request!", "error", err.Error())
return TMDBContentCredits{}, errors.New("failed to complete tv cast request")
}
return *resp, nil
@@ -142,7 +280,7 @@ func personCredits(id string) (TMDBPersonCombinedCredits, error) {
func discoverMovies() (TMDBDiscoverMovies, error) {
resp := new(TMDBDiscoverMovies)
err := tmdbRequest("/discover/movie/", map[string]string{"page": "1"}, &resp)
err := tmdbRequest("/discover/movie", map[string]string{"page": "1"}, &resp)
if err != nil {
slog.Error("Failed to complete discover movies request!", "error", err.Error())
return TMDBDiscoverMovies{}, errors.New("failed to complete discover movies request")
@@ -152,7 +290,7 @@ func discoverMovies() (TMDBDiscoverMovies, error) {
func discoverTv() (TMDBDiscoverShows, error) {
resp := new(TMDBDiscoverShows)
err := tmdbRequest("/discover/tv/", map[string]string{"page": "1"}, &resp)
err := tmdbRequest("/discover/tv", map[string]string{"page": "1"}, &resp)
if err != nil {
slog.Error("Failed to complete discover tv request!", "error", err.Error())
return TMDBDiscoverShows{}, errors.New("failed to complete discover tv request")
+158
View File
@@ -0,0 +1,158 @@
package main
import (
"errors"
"log/slog"
"time"
"gorm.io/gorm"
)
// Database struct, only internal.
type Follow struct {
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"-"`
UserID uint `gorm:"primaryKey:usr_id_to_followed_id;not null;check:user_id != followed_user_id" json:"-"`
User User `json:"-"`
FollowedUserID uint `gorm:"primaryKey:usr_id_to_followed_id;not null" json:"-"`
FollowedUser User `json:"-"`
}
// For end users to see.
type FollowPublic struct {
CreatedAt time.Time `json:"createdAt"`
FollowedUser PublicUser `json:"followedUser"`
}
type FollowThoughts struct {
FollowedUser PublicUser `json:"followedUser"`
Thoughts string `json:"thoughts"`
Status WatchedStatus `json:"status"`
Rating int8 `json:"rating"`
}
func followUser(db *gorm.DB, currentUserId uint, toFollowUserId uint) (FollowPublic, error) {
f := Follow{UserID: currentUserId, FollowedUserID: toFollowUserId}
res := db.Model(&Follow{}).Create(&f)
if res.Error != nil {
slog.Error("followUser: Error on inserting follow.", "error", res.Error)
err := "failed to insert follow"
if res.Error == gorm.ErrDuplicatedKey {
err = "already followed"
}
return FollowPublic{}, errors.New(err)
}
// Now get the row with preloaded followed user
var nf Follow
res = db.Where("user_id = ? AND followed_user_id = ?", currentUserId, toFollowUserId).Preload("FollowedUser", "private = ?", 0).Take(&nf)
if res.Error != nil {
slog.Error("followUser: Couldn't fetch newly followed user.", "error", res.Error)
return FollowPublic{}, errors.New("followed, but failed to fetch followed user")
}
return FollowPublic{CreatedAt: nf.CreatedAt, FollowedUser: nf.FollowedUser.GetSafe()}, nil
}
func unfollowUser(db *gorm.DB, currentUserId uint, toFollowUserId uint) (bool, error) {
f := Follow{UserID: currentUserId, FollowedUserID: toFollowUserId}
res := db.Delete(&f)
if res.Error != nil {
slog.Error("unfollowUser: Error deleting follow.", "error", res.Error)
err := "failed to remove follow"
if res.Error == gorm.ErrRecordNotFound {
err = "not following"
}
return false, errors.New(err)
}
return true, nil
}
// Get current users follows
func getFollows(db *gorm.DB, userId uint) ([]FollowPublic, error) {
var follows []Follow
res := db.Where("user_id = ?", userId).Preload("FollowedUser", "private = ?", 0).Find(&follows)
if res.Error != nil {
slog.Error("getFollows: Error finding follows.", "error", res.Error)
return []FollowPublic{}, errors.New("failed to find follows")
}
fpub := []FollowPublic{}
for _, v := range follows {
// Skip followed users without an ID..
// this will be because they have made
// their account private after we followed them.
if v.FollowedUser.ID == 0 {
continue
}
fpub = append(fpub, FollowPublic{CreatedAt: v.CreatedAt, FollowedUser: v.FollowedUser.GetSafe()})
}
return fpub, nil
}
// Get followed profile thoughts, rating, etc on specific content.
func getFollowsThoughts(db *gorm.DB, userId uint, mediaType string, mediaId string) ([]FollowThoughts, error) {
var follows []Follow
res := db.Where("user_id = ?", userId).Preload("FollowedUser", "private = ? AND private_thoughts = ?", 0, 0).Find(&follows)
if res.Error != nil {
slog.Error("getFollows: Error finding follows.", "error", res.Error)
return []FollowThoughts{}, errors.New("failed to find follows")
}
slog.Info("getFollowsThoughts")
var followIds []uint
for _, v := range follows {
// Skip empty followedUsers.. they are private.
if v.FollowedUser.ID == 0 {
continue
}
followIds = append(followIds, v.FollowedUser.ID)
}
var contentOrGameId int
if mediaType == "game" {
// Get our content id from type and tmdbId
var content Game
res = db.Where("igdb_id = ?", mediaId).Select("id").Find(&content)
if res.Error != nil {
slog.Error("getFollows: Error finding content from db.", "error", res.Error)
return []FollowThoughts{}, errors.New("failed to find content")
}
contentOrGameId = content.ID
} else if mediaType == "movie" || mediaType == "tv" {
// Get our content id from type and tmdbId
var content Content
res = db.Where("type = ? AND tmdb_id = ?", mediaType, mediaId).Select("id").Find(&content)
if res.Error != nil {
slog.Error("getFollows: Error finding content from db.", "error", res.Error)
return []FollowThoughts{}, errors.New("failed to find content")
}
contentOrGameId = content.ID
} else {
slog.Error("getFollows: Unrecognized media type (movie, tv or game supported).", "media_type", mediaType)
return []FollowThoughts{}, errors.New("unrecognized media type")
}
// Get list of followeds watcheds for this content
var fw []Watched
if mediaType == "game" {
res = db.Where("game_id = ? AND user_id IN ?", contentOrGameId, followIds).Find(&fw)
} else {
res = db.Where("content_id = ? AND user_id IN ?", contentOrGameId, followIds).Find(&fw)
}
if res.Error != nil {
slog.Error("getFollows: Error finding followed watcheds from db.", "error", res.Error)
return []FollowThoughts{}, errors.New("failed to find followed watcheds")
}
// Create followThoughts array by combining follows and fw(atcheds)
ft := []FollowThoughts{}
for _, v := range fw {
var fu PublicUser
for _, f := range follows {
if f.FollowedUser.ID == v.UserID {
fu = f.FollowedUser.GetSafe()
break
}
}
// If we didn't find a related followedUser.. skip this watched entry
if fu.ID == 0 {
continue
}
ft = append(ft, FollowThoughts{FollowedUser: fu, Thoughts: v.Thoughts, Status: v.Status, Rating: v.Rating})
}
return ft, nil
}
+276
View File
@@ -0,0 +1,276 @@
package game
import (
"bytes"
"context"
"encoding/json"
"errors"
"io"
"log/slog"
"net/http"
"net/url"
"time"
)
const (
igdbHost = "https://api.igdb.com/v4"
tokenGrantType = "client_credentials"
)
var tokenRefreshJobCancel context.CancelFunc
type IGDB struct {
ClientID *string `json:"clientId,omitempty"`
ClientSecret *string `json:"clientSecret,omitempty"`
AccessToken string `json:"accessToken,omitempty"`
AccessTokenExpires time.Time `json:"accessTokenExpires,omitempty"`
onTokenRefreshed *func()
}
func (i *IGDB) req(host string, ep string, p map[string]string, b string, resp interface{}) error {
// if using igdb host and we have no access token, error before running req
if host == igdbHost && (i.ClientID == nil || i.AccessToken == "") {
return errors.New("using igdbHost without a clientID or accessToken")
}
base, err := url.Parse(host)
if err != nil {
return errors.New("failed to parse api uri")
}
// Path params
base.Path += ep
// Query params
params := url.Values{}
for k, v := range p {
params.Add(k, v)
}
// Add params to url
base.RawQuery = params.Encode()
slog.Info("req", "base", base.String())
req, err := http.NewRequest("POST", base.String(), bytes.NewBuffer([]byte(b)))
if err != nil {
return err
}
// Add igdb auth headers
if host == igdbHost {
req.Header.Add("Client-ID", *i.ClientID)
req.Header.Add("Authorization", "Bearer "+i.AccessToken)
}
res, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return err
}
if !(res.StatusCode >= 200 && res.StatusCode <= 299) {
slog.Error("game non 2xx status code:", "status_code", res.StatusCode)
return errors.New(string(body))
}
err = json.Unmarshal([]byte(body), &resp)
if err != nil {
return err
}
return nil
}
func (i *IGDB) getNewAccessToken() (TwitchTokenResponse, error) {
var resp TwitchTokenResponse
err := i.req(
"https://id.twitch.tv/oauth2",
"/token",
map[string]string{"client_id": *i.ClientID, "client_secret": *i.ClientSecret, "grant_type": tokenGrantType},
"",
&resp,
)
if err != nil {
slog.Error("IGDB init token request failed", "error", err)
return TwitchTokenResponse{}, errors.New("token request failed, check client id and secret")
}
return resp, nil
}
func (i *IGDB) refreshToken(ctx context.Context) {
var exp <-chan time.Time
if i.AccessToken != "" && !i.AccessTokenExpires.IsZero() && i.AccessTokenExpires.Compare(time.Now()) == 1 {
// Stored token not expired.. set exp time to token exp time - 1h.
exp = time.After(i.AccessTokenExpires.Sub(time.Now().Add(60 * time.Second)))
} else {
// Token expired.. exp now..
exp = time.After(100 * time.Millisecond)
}
slog.Info("refreshToken running")
for {
select {
case <-exp:
slog.Info("IGDB refreshToken: Token expired (or is near expiry date)")
r, err := i.getNewAccessToken()
if err != nil {
slog.Error("IGDB refreshToken: Error refreshing token (retrying in 60s):", err)
exp = time.After(60 * time.Second)
} else {
slog.Info("IGDB refreshToken: Token successfully refreshed")
i.AccessToken = r.AccessToken
i.AccessTokenExpires = time.Now().Add(time.Duration(r.ExpiresIn) * time.Second)
exp = time.After(i.AccessTokenExpires.Sub(time.Now().Add(60 * time.Second)))
// Call token refresh callback if set
if i.onTokenRefreshed != nil {
(*i.onTokenRefreshed)()
}
}
case <-ctx.Done():
slog.Info("refreshToken cancelled")
return
}
}
}
func (i *IGDB) OnTokenRefreshed(tokenRefreshed func()) {
i.onTokenRefreshed = &tokenRefreshed
}
// Get token and stuff
func (i *IGDB) Init() error {
// Cancel existing refresh job if we have a cancel func for its context
if tokenRefreshJobCancel != nil {
slog.Debug("IGDB init: Refresh job running.. cancelling it.")
tokenRefreshJobCancel()
tokenRefreshJobCancel = nil
}
// Stop here if we have no client id or secret.
if i.ClientID == nil || i.ClientSecret == nil {
slog.Error("IGDB init client id and or secret not provided")
return errors.New("client id and or secret not provided")
}
slog.Debug("IGDB init running.")
ctx, cancel := context.WithCancel(context.Background())
tokenRefreshJobCancel = cancel
// Get and set first token if needed
go i.refreshToken(ctx)
return nil
}
func (i *IGDB) Search(q string) (GameSearchResponse, error) {
slog.Debug("IGDB Search called", "query", q)
var resp GameSearchResponse
err := i.req(
igdbHost,
"/games",
map[string]string{},
"fields name, cover.image_id, version_title, summary, first_release_date; search \""+q+"\";",
&resp,
)
if err != nil {
slog.Error("IGDB Search request failed!", "error", err)
return GameSearchResponse{}, errors.New("request failed")
}
return resp, nil
}
func (i *IGDB) GameDetails(id string) (GameDetailsResponse, error) {
slog.Debug("IGDB GameDetails called", "id", id)
var resp []GameDetailsResponse
err := i.req(
igdbHost,
"/games",
map[string]string{},
`fields
name,
cover.image_id,
version_title,
summary,
storyline,
first_release_date,
artworks.width,
artworks.height,
artworks.image_id,
category,
platforms.name,
game_modes.name,
genres.id,
genres.name,
involved_companies.developer,
involved_companies.publisher,
involved_companies.porting,
involved_companies.supporting,
involved_companies.company.name,
involved_companies.company.description,
involved_companies.company.slug,
involved_companies.company.websites.category,
involved_companies.company.websites.trusted,
involved_companies.company.websites.url,
rating,
rating_count,
status,
url,
websites.trusted,
websites.category,
websites.url,
videos.name,
videos.video_id,
similar_games.id,
similar_games.name,
similar_games.summary,
similar_games.cover.image_id,
similar_games.first_release_date;
where id = `+id+";",
&resp,
)
if err != nil {
slog.Error("IGDB GameDetails request failed!", "error", err)
return GameDetailsResponse{}, errors.New("request failed")
}
if len(resp) > 0 {
return resp[0], nil
}
return GameDetailsResponse{}, errors.New("no game details recieved")
}
// Basic game details for when we are using them only to update our cache.
// In these cases, it's a waste to ask for everything, when we don't need it.
func (i *IGDB) GameDetailsBasic(id string) (GameDetailsBasicResponse, error) {
slog.Debug("IGDB GameDetails called", "id", id)
var resp []GameDetailsBasicResponse
err := i.req(
igdbHost,
"/games",
map[string]string{},
`fields
name,
cover.image_id,
summary,
storyline,
first_release_date,
category,
platforms.name,
game_modes.name,
genres.name,
rating,
rating_count,
status;
where id = `+id+";",
&resp,
)
if err != nil {
slog.Error("IGDB GameDetails request failed!", "error", err)
return GameDetailsBasicResponse{}, errors.New("request failed")
}
if len(resp) > 0 {
return resp[0], nil
}
return GameDetailsBasicResponse{}, errors.New("no game details recieved")
}
+139
View File
@@ -0,0 +1,139 @@
package game
import (
"encoding/json"
"time"
)
type TwitchTokenResponse struct {
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
TokenType string `json:"token_type"`
}
// So we can unmarshall the unix timestamps returned from igdb into time.Time.
type UnixTime struct {
time.Time
}
func (u *UnixTime) UnmarshalJSON(b []byte) error {
var timestamp int64
err := json.Unmarshal(b, &timestamp)
if err != nil {
return err
}
u.Time = time.Unix(timestamp, 0)
return nil
}
// Only the fields we request included in each struct
type GameSearchResponse []struct {
ID int `json:"id"`
Cover struct {
ID int `json:"id"`
ImageID string `json:"image_id"`
} `json:"cover"`
FirstReleaseDate UnixTime `json:"first_release_date"`
Name string `json:"name"`
Summary string `json:"summary,omitempty"`
VersionTitle string `json:"version_title,omitempty"`
}
type GameDetailsResponse struct {
ID int `json:"id"`
Artworks []struct {
Width int `json:"width"`
Height int `json:"height"`
ImageID string `json:"image_id"`
} `json:"artworks"`
Category int `json:"category"`
Cover struct {
ID int `json:"id"`
ImageID string `json:"image_id"`
} `json:"cover"`
FirstReleaseDate UnixTime `json:"first_release_date"`
GameModes []struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"game_modes"`
Genres []struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"genres"`
InvolvedCompanies []struct {
ID int `json:"id"`
Company struct {
ID int `json:"id"`
Description string `json:"description"`
Name string `json:"name"`
Slug string `json:"slug"`
Websites []struct {
ID int `json:"id"`
Category int `json:"category"`
Trusted bool `json:"trusted"`
URL string `json:"url"`
} `json:"websites"`
} `json:"company"`
Developer bool `json:"developer"`
Porting bool `json:"porting"`
Publisher bool `json:"publisher"`
Supporting bool `json:"supporting"`
} `json:"involved_companies"`
Name string `json:"name"`
Platforms []struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"platforms"`
Rating float64 `json:"rating"`
RatingCount int `json:"rating_count"`
Summary string `json:"summary"`
Storyline string `json:"storyline"`
Status int `json:"status"`
URL string `json:"url"`
Videos []struct {
ID int `json:"id"`
Name string `json:"name"`
VideoID string `json:"video_id"`
} `json:"videos"`
Websites []struct {
ID int `json:"id"`
Category int `json:"category"`
Trusted bool `json:"trusted"`
URL string `json:"url"`
} `json:"websites"`
SimilarGame []struct {
ID int `json:"id"`
Name string `json:"name"`
Summary string `json:"summary"`
FirstReleaseDate UnixTime `json:"first_release_date"`
Cover struct {
ID int `json:"id"`
ImageID string `json:"image_id"`
} `json:"cover"`
} `json:"similar_games"`
}
type GameDetailsBasicResponse struct {
ID int `json:"id"`
Category int `json:"category"`
Cover struct {
ImageID string `json:"image_id"`
} `json:"cover"`
FirstReleaseDate UnixTime `json:"first_release_date"`
GameModes []struct {
Name string `json:"name"`
} `json:"game_modes"`
Genres []struct {
Name string `json:"name"`
} `json:"genres"`
Name string `json:"name"`
Platforms []struct {
Name string `json:"name"`
} `json:"platforms"`
Rating float64 `json:"rating"`
RatingCount int `json:"rating_count"`
Summary string `json:"summary"`
Storyline string `json:"storyline"`
Status int `json:"status"`
}
+212
View File
@@ -0,0 +1,212 @@
package main
import (
"encoding/json"
"errors"
"log/slog"
"strconv"
"time"
"github.com/sbondCo/Watcharr/game"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
// For storing cached games, so we can serve the basic local data for watched list to work
type Game struct {
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
UpdatedAt time.Time `json:"updatedAt"`
IgdbID int `json:"igdbId" gorm:"uniqueIndex;not null"`
Name string `json:"name"`
CoverID string `json:"coverId"`
Summary string `json:"summary"`
Storyline string `json:"storyline"`
// First release date
ReleaseDate *time.Time `json:"releaseDate,omitempty"`
Rating float64 `json:"rating"`
RatingCount int `json:"ratingCount"`
Status int `json:"status"`
Category int `json:"category"`
// Arrays turned to strings that may be useful
GameModes string `json:"gameModes"`
Genres string `json:"genres"`
Platforms string `json:"platforms"`
// Id to poster image row (cached game cover)
PosterID *uint `json:"-"`
Poster *Image `json:"poster,omitempty"`
}
type PlayedAddRequest struct {
Status WatchedStatus `json:"status"`
Rating int8 `json:"rating" binding:"max=10"`
IgdbID int `json:"igdbId" binding:"required"`
}
// Cache(save) game to our table
func saveGame(db *gorm.DB, c *Game, onlyUpdate bool) error {
slog.Info("Saving game to db", "id", c.IgdbID, "name", c.Name)
if c.IgdbID == 0 || c.Name == "" {
slog.Error("saveGame: content missing id or name!", "id", c.IgdbID, "name", c.Name)
return errors.New("game missing id or title")
}
if c.CoverID != "" {
p, err := downloadAndInsertImage(db, "https://images.igdb.com/igdb/image/upload/t_cover_big/"+c.CoverID+".png", "games")
if err != nil {
slog.Error("saveGame: Failed to cache game cover.", "error", err)
} else {
slog.Debug("saveGame: Cached game cover", "p", p)
c.PosterID = &p.ID
}
}
var res *gorm.DB
if onlyUpdate {
// We only want to update an existing row, if it exists.
res = db.Model(&Game{}).Where("igdb_id = ?", c.IgdbID).Updates(c)
if res.Error != nil {
slog.Error("saveGame: Error updating game in database", "error", res.Error.Error())
return errors.New("failed to update cached game in database")
}
} else {
// On conflict, update existing row with details incase any were updated/missing.
res = db.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "igdb_id"}},
DoUpdates: clause.AssignmentColumns([]string{
"name",
"cover_id",
"summary",
"storyline",
"release_date",
"rating",
"rating_count",
"status",
"game_modes",
"genres",
}),
}).Create(&c)
if res.Error != nil {
// Error if anything but unique contraint error
if res.Error != gorm.ErrDuplicatedKey {
slog.Error("saveGame: Error creating game in database", "error", res.Error.Error())
return errors.New("failed to cache game in database")
}
}
}
return nil
}
func cacheGame(db *gorm.DB, g game.GameDetailsBasicResponse, onlyUpdate bool) (Game, error) {
slog.Debug("cacheGame", "game_details", g)
var (
gameModes string
genres string
platforms string
)
if len(g.GameModes) > 0 {
for _, v := range g.GameModes {
gameModes += v.Name + "|"
}
}
if len(g.Genres) > 0 {
for _, v := range g.Genres {
genres += v.Name + "|"
}
}
if len(g.Platforms) > 0 {
for _, v := range g.Platforms {
platforms += v.Name + "|"
}
}
c := Game{
IgdbID: g.ID,
Name: g.Name,
CoverID: g.Cover.ImageID,
Summary: g.Summary,
Storyline: g.Storyline,
ReleaseDate: &g.FirstReleaseDate.Time,
Rating: (g.Rating),
RatingCount: g.RatingCount,
Status: g.Status,
Category: g.Category,
GameModes: gameModes,
Genres: genres,
Platforms: platforms,
}
err := saveGame(db, &c, onlyUpdate)
if err != nil {
slog.Error("cacheGame: Failed to save game!", "error", err)
return Game{}, errors.New("failed to save game")
}
return c, nil
}
// For adding/updating played games, we will reuse methods defined in watched.go where easily possible.
func addPlayed(db *gorm.DB, igdb *game.IGDB, userId uint, ar PlayedAddRequest, at ActivityType) (Watched, error) {
slog.Debug("Adding played item", "userId", userId, "igdbId", ar.IgdbID)
var game Game
db.Where("igdb_id = ?", ar.IgdbID).Find(&game)
// Create game if not found from our db
if game == (Game{}) {
slog.Debug("Game not in db, fetching...")
resp, err := igdb.GameDetailsBasic(strconv.Itoa(ar.IgdbID))
if err != nil {
slog.Error("addPlayed content tmdb api request failed", "error", err)
return Watched{}, errors.New("failed to find requested games")
}
game, err = cacheGame(db, resp, false)
if err != nil {
slog.Error("addPlayed failed to cache game", "igdb_id", ar.IgdbID, "err", err)
return Watched{}, errors.New("failed to cache content")
}
}
// Error if content has no id
if game.ID == 0 {
return Watched{}, errors.New("failed to find game by id")
}
// Create watched entry in db
if ar.Status == "" {
ar.Status = FINISHED
}
watched := Watched{Status: ar.Status, Rating: ar.Rating, UserID: userId, GameID: &game.ID}
res := db.Create(&watched)
if res.Error != nil {
if res.Error == gorm.ErrDuplicatedKey {
res = db.Model(&Watched{}).Unscoped().Preload("Activity").Where("user_id = ? AND content_id = ?", userId, watched.ContentID).Take(&watched)
if res.Error != nil {
return Watched{}, errors.New("content already on watched list. errored checking for soft deleted record")
}
if watched.DeletedAt.Time.IsZero() {
return Watched{}, errors.New("content already on watched list")
} else {
slog.Info("addPlayed: Watched list item for this content exists as soft deleted record.. attempting to restore")
res = db.Model(&Watched{}).Unscoped().Where("user_id = ? AND content_id = ?", userId, watched.ContentID).Updates(map[string]interface{}{"status": ar.Status, "rating": ar.Rating, "deleted_at": nil})
watched.Status = ar.Status
watched.Rating = ar.Rating
if res.Error != nil {
slog.Error("addPlayed: Failed to restore soft deleted watch list item", "error", res.Error)
return Watched{}, errors.New("content already on watched list. errored removing soft delete timestamp")
}
}
} else {
slog.Error("Error adding watched content to database", "error", res.Error.Error())
return Watched{}, errors.New("failed adding content to database")
}
}
slog.Debug("Added watched list item", "item", watched)
var activity Activity
activityJson, err := json.Marshal(map[string]interface{}{"status": ar.Status, "rating": ar.Rating})
if err != nil {
slog.Error("Failed to marshal json for data in ADD_WATCHED activity request, adding without data", "error", err.Error())
activity, _ = addActivity(db, userId, ActivityAddRequest{WatchedID: watched.ID, Type: at})
} else {
activity, _ = addActivity(db, userId, ActivityAddRequest{WatchedID: watched.ID, Type: at, Data: string(activityJson)})
}
watched.Activity = append(watched.Activity, activity)
watched.Game = &game
return watched, nil
}
+21 -45
View File
@@ -3,74 +3,50 @@ module github.com/sbondCo/Watcharr
go 1.21
require (
github.com/buckket/go-blurhash v1.1.0
github.com/gin-contrib/cache v1.2.0
github.com/gin-contrib/cors v1.4.0
github.com/gin-contrib/cors v1.7.0
github.com/gin-gonic/gin v1.9.1
github.com/golang-jwt/jwt/v5 v5.0.0
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/joho/godotenv v1.5.1
github.com/lib/pq v1.10.9
github.com/uptrace/bun v1.1.16
github.com/uptrace/bun/dialect/sqlitedialect v1.1.16
github.com/uptrace/bun/driver/sqliteshim v1.1.16
golang.org/x/crypto v0.14.0
golang.org/x/crypto v0.21.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gorm.io/driver/sqlite v1.5.4
gorm.io/gorm v1.25.5
gorm.io/driver/sqlite v1.5.5
gorm.io/gorm v1.25.7
)
require (
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 // indirect
github.com/bytedance/sonic v1.10.2 // indirect
github.com/bytedance/sonic v1.11.2 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
github.com/go-playground/validator/v10 v10.19.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gomodule/redigo v1.8.9 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/knz/go-libedit v1.10.1 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/memcachier/mc/v3 v3.0.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/robfig/go-cache v0.0.0-20130306151617-9fc39e0dbf62 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.0 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/arch v0.5.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/uint128 v1.3.0 // indirect
modernc.org/cc/v3 v3.41.0 // indirect
modernc.org/cc/v4 v4.2.1 // indirect
modernc.org/ccgo/v3 v3.16.15 // indirect
modernc.org/ccgo/v4 v4.0.0-20230612200659-63de3e82e68d // indirect
modernc.org/gc/v2 v2.1.2-0.20220923113132-f3b5abcf8083 // indirect
modernc.org/libc v1.24.1 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/sqlite v1.26.0 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
)
+49 -285
View File
@@ -1,362 +1,126 @@
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d h1:pVrfxiGfwelyab6n21ZBkbkmbevaf+WvMIiR7sr97hw=
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 h1:N7oVaKyGp8bttX0bfZGmcGkjz7DLQXhAn3DNd3T0ous=
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874/go.mod h1:r5xuitiExdLAJ09PR7vBVENGvp4ZuTBeWTGtxuX3K+c=
github.com/buckket/go-blurhash v1.1.0 h1:X5M6r0LIvwdvKiUtiNcRL2YlmOfMzYobI3VCKCZc9Do=
github.com/buckket/go-blurhash v1.1.0/go.mod h1:aT2iqo5W9vu9GpyoLErKfTHwgODsZp3bQfXjXJUxNb8=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA=
github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
github.com/bytedance/sonic v1.8.3 h1:pf6fGl5eqWYKkx1RcD4qpuX+BIUaduv/wTm5ekWJ80M=
github.com/bytedance/sonic v1.8.3/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk=
github.com/bytedance/sonic v1.10.0/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/bytedance/sonic v1.11.2 h1:ywfwo0a/3j9HR8wsYGWsIWl2mvRsI950HyoxiBERw5A=
github.com/bytedance/sonic v1.11.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0=
github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gin-contrib/cache v1.2.0 h1:WA+AJR4kmHDTaLLShCHo/IeWVmmGRZ3Lsr3JQ46tFlE=
github.com/gin-contrib/cache v1.2.0/go.mod h1:2KkFL8PSnPF3Tt5E2Jpc3HWuBAUKqGZnClCFMm0tXQI=
github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g=
github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs=
github.com/gin-contrib/cors v1.7.0 h1:wZX2wuZ0o7rV2/1i7gb4Jn+gW7HBqaP91fizJkBUJOA=
github.com/gin-contrib/cors v1.7.0/go.mod h1:cI+h6iOAyxKRtUtC6iF/Si1KSFvGm/gK+kshxlCi8ro=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8=
github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU=
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
github.com/go-playground/validator/v10 v10.15.0 h1:nDU5XeOKtB3GEa+uB7GNYwhVKsgjAR7VgKoNB6ryXfw=
github.com/go-playground/validator/v10 v10.15.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-playground/validator/v10 v10.15.5 h1:LEBecTWb/1j5TNY1YYG2RcOUN3R7NLylN+x8TTueE24=
github.com/go-playground/validator/v10 v10.15.5/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4=
github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 h1:tDQ1LjKga657layZ4JLsRdxgvupebc0xuPwRNuTfUgs=
github.com/golang-jwt/jwt/v5 v5.0.0-rc.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE=
github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1 h1:0pHpWtx9vcvC0xGZqEQlQdfSQs7WRlAjuPvk3fOZDCo=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/leodido/go-urn v1.2.2 h1:7z68G0FCGvDk646jz1AelTYNYWrTNm0bEcFAo147wt4=
github.com/leodido/go-urn v1.2.2/go.mod h1:kUaIbLZWttglzwNuG0pgsh5vuV6u2YcGBYz1hIPjtOQ=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/memcachier/mc/v3 v3.0.3 h1:qii+lDiPKi36O4Xg+HVKwHu6Oq+Gt17b+uEiA0Drwv4=
github.com/memcachier/mc/v3 v3.0.3/go.mod h1:GzjocBahcXPxt2cmqzknrgqCOmMxiSzhVKPOe90Tpug=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us=
github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0=
github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/robfig/go-cache v0.0.0-20130306151617-9fc39e0dbf62 h1:pyecQtsPmlkCsMkYhT5iZ+sUXuwee+OvfuJjinEA3ko=
github.com/robfig/go-cache v0.0.0-20130306151617-9fc39e0dbf62/go.mod h1:65XQgovT59RWatovFwnwocoUxiI/eENTnOY5GK3STuY=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef/go.mod h1:8AEUvGVi2uQ5b24BIhcr0GCcpd/RNAFWaN2CJFrWIIQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
github.com/ugorji/go/codec v1.2.9 h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU=
github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/ugorji/go/codec v1.2.10 h1:eimT6Lsr+2lzmSZxPhLFoOWFmQqwk0fllJJ5hEbTXtQ=
github.com/ugorji/go/codec v1.2.10/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/uptrace/bun v1.1.12 h1:sOjDVHxNTuM6dNGaba0wUuz7KvDE1BmNu9Gqs2gJSXQ=
github.com/uptrace/bun v1.1.12/go.mod h1:NPG6JGULBeQ9IU6yHp7YGELRa5Agmd7ATZdz4tGZ6z0=
github.com/uptrace/bun v1.1.14 h1:S5vvNnjEynJ0CvnrBOD7MIRW7q/WbtvFXrdfy0lddAM=
github.com/uptrace/bun v1.1.14/go.mod h1:RHk6DrIisO62dv10pUOJCz5MphXThuOTpVNYEYv7NI8=
github.com/uptrace/bun v1.1.16 h1:cn9cgEMFwcyYRsQLfxCRMUxyK1WaHwOVrR3TvzEFZ/A=
github.com/uptrace/bun v1.1.16/go.mod h1:7HnsMRRvpLFUcquJxp22JO8PsWKpFQO/gNXqqsuGWg8=
github.com/uptrace/bun/dialect/sqlitedialect v1.1.12 h1:Ud31nqZmebcQpl151nb108+vtcpxJ7kfXmbPYbALBiI=
github.com/uptrace/bun/dialect/sqlitedialect v1.1.12/go.mod h1:Pwg7s31BdF3PMBlWTnYkEn2I9ASsvatt1Ln/AERCTV4=
github.com/uptrace/bun/dialect/sqlitedialect v1.1.14 h1:SlwXLxr+N1kEo8Q0cheRlnIZLZlWniEB1OI+jkiLgWE=
github.com/uptrace/bun/dialect/sqlitedialect v1.1.14/go.mod h1:9RTEj1l4bB9a4l1Mnc9y4COTwWlFYe1dh6fyxq1rR7A=
github.com/uptrace/bun/dialect/sqlitedialect v1.1.16 h1:gbc9BP/e4sNOB9VBj+Si46dpOz2oktmZPidkda92GYY=
github.com/uptrace/bun/dialect/sqlitedialect v1.1.16/go.mod h1:YNezpK7fIn5Wa2WGmTCZ/nEyiswcXmuT4iNWADeL1x4=
github.com/uptrace/bun/driver/sqliteshim v1.1.12 h1:GMbSa7Pjjk4kjF8XURz5uMLe2PbN98e6t00sp0rx2Eo=
github.com/uptrace/bun/driver/sqliteshim v1.1.12/go.mod h1:u67g2ewzoMDCCAqjliHAM/BJjEXfoExXlFXhx3TnXRs=
github.com/uptrace/bun/driver/sqliteshim v1.1.14 h1:DFPUJ6KjDP2myjq15gtYYNngmAFMww1Y2UFZv4tbUw8=
github.com/uptrace/bun/driver/sqliteshim v1.1.14/go.mod h1:5BFN7V6Sm37Tn7UE4FWNm/F6V3iJPUzAJ7QyRwA5b1k=
github.com/uptrace/bun/driver/sqliteshim v1.1.16 h1:dhXrdXQegGSM+Jk07s9p1Y575DMhCKl7wBkss8kgM+8=
github.com/uptrace/bun/driver/sqliteshim v1.1.16/go.mod h1:7fJaPqaiSvnWytQcMwVv1ZcjUJh7tGDonO/zq3O6RRI=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/msgpack/v5 v5.4.0 h1:hRM0digJwyR6vll33NNAwCFguy5JuBD6jxDmQP3l608=
github.com/vmihailenco/msgpack/v5 v5.4.0/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc=
golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.5.0 h1:jpGode6huXQxcskEIpOCvrU+tzo81b6+oFLUYXWtH/Y=
golang.org/x/arch v0.5.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/sqlite v1.4.4 h1:gIufGoR0dQzjkyqDyYSCvsYR6fba1Gw5YKDqKeChxFc=
gorm.io/driver/sqlite v1.4.4/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
gorm.io/driver/sqlite v1.5.1 h1:hYyrLkAWE71bcarJDPdZNTLWtr8XrSjOWyjUYI6xdL4=
gorm.io/driver/sqlite v1.5.1/go.mod h1:7MZZ2Z8bqyfSQA1gYEV6MagQWj3cpUkJj9Z+d1HEMEQ=
gorm.io/driver/sqlite v1.5.2 h1:TpQ+/dqCY4uCigCFyrfnrJnrW9zjpelWVoEVNy5qJkc=
gorm.io/driver/sqlite v1.5.2/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4=
gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0=
gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4=
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.6 h1:wy98aq9oFEetsc4CAbKD2SoBCdMzsbSIvSUUFJuHi5s=
gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.0 h1:+KtYtb2roDz14EQe4bla8CbQlmb9dN3VejSai3lprfU=
gorm.io/gorm v1.25.0/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.1 h1:nsSALe5Pr+cM3V1qwwQ7rOkw+6UeLrX5O4v3llhHa64=
gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.3 h1:zi4rHZj1anhZS2EuEODMhDisGy+Daq9jtPrNGgbQYD8=
gorm.io/gorm v1.25.3/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
lukechampine.com/uint128 v1.3.0 h1:cDdUVfRwDUDovz610ABgFD17nXD4/uDgVHl2sC3+sbo=
lukechampine.com/uint128 v1.3.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw=
modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0=
modernc.org/cc/v3 v3.41.0 h1:QoR1Sn3YWlmA1T4vLaKZfawdVtSiGx8H+cEojbC7v1Q=
modernc.org/cc/v3 v3.41.0/go.mod h1:Ni4zjJYJ04CDOhG7dn640WGfwBzfE0ecX8TyMB0Fv0Y=
modernc.org/cc/v4 v4.2.1 h1:xwwaXFwiPaVZpGRMd19NPLsaiNyNBO8oChey4501g1M=
modernc.org/cc/v4 v4.2.1/go.mod h1:0O8vuqhQfwBy+piyfEjzWIUGV4I3TPsXSf0W05+lgN8=
modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw=
modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY=
modernc.org/ccgo/v3 v3.16.15 h1:KbDR3ZAVU+wiLyMESPtbtE/Add4elztFyfsWoNTgxS0=
modernc.org/ccgo/v3 v3.16.15/go.mod h1:yT7B+/E2m43tmMOT51GMoM98/MtHIcQQSleGnddkUNI=
modernc.org/ccgo/v4 v4.0.0-20230612200659-63de3e82e68d h1:3yB/pQNL5kVPDifGFqoZjeRxf8m0+Us15rB7ertNASQ=
modernc.org/ccgo/v4 v4.0.0-20230612200659-63de3e82e68d/go.mod h1:austqj6cmEDRfewsUvmGmyIgsI/Nq87oTXlfTgY85Fc=
modernc.org/fileutil v1.0.0/go.mod h1:JHsWpkrk/CnVV1H/eGlFf85BEpfkrp56ro8nojIq9Q8=
modernc.org/gc/v2 v2.1.2-0.20220923113132-f3b5abcf8083 h1:rGoLVwiOxdeVkGYMOF/8Pw7xpDd3OqScJU/tqHgvY1c=
modernc.org/gc/v2 v2.1.2-0.20220923113132-f3b5abcf8083/go.mod h1:Zt5HLUW0j+l02wj99UsPs+1DOFwwsGnqfcw+BGyyP/A=
modernc.org/lex v1.1.0/go.mod h1:+ojes+j0JYCaqwKYCBjcUavscJHmWFKvViUTMU4VjLA=
modernc.org/lexer v1.0.0/go.mod h1:F/Dld0YKYdZCLQ7bD0USbWL4YKCyTDRDHiDTOs0q0vk=
modernc.org/libc v1.22.2 h1:4U7v51GyhlWqQmwCHj28Rdq2Yzwk55ovjFrdPjs8Hb0=
modernc.org/libc v1.22.2/go.mod h1:uvQavJ1pZ0hIoC/jfqNoMLURIMhKzINIWypNM17puug=
modernc.org/libc v1.22.3 h1:D/g6O5ftAfavceqlLOFwaZuA5KYafKwmr30A6iSqoyY=
modernc.org/libc v1.22.3/go.mod h1:MQrloYP209xa2zHome2a8HLiLm6k0UT8CoHpV74tOFw=
modernc.org/libc v1.22.6 h1:cbXU8R+A6aOjRuhsFh3nbDWXO/Hs4ClJRXYB11KmPDo=
modernc.org/libc v1.22.6/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY=
modernc.org/libc v1.24.1 h1:uvJSeCKL/AgzBo2yYIPPTy82v21KgGnizcGYfBHaNuM=
modernc.org/libc v1.24.1/go.mod h1:FmfO1RLrU3MHJfyi9eYYmZBfi/R+tqZ6+hQ3yQQUkak=
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds=
modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E=
modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E=
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/scannertest v1.0.0/go.mod h1:9qnOCV+wSvq1o9hcOPNwRorND4qpZdtmTvmcdKyN3iE=
modernc.org/sqlite v1.20.4 h1:J8+m2trkN+KKoE7jglyHYYYiaq5xmz2HoHJIiBlRzbE=
modernc.org/sqlite v1.20.4/go.mod h1:zKcGyrICaxNTMEHSr1HQ2GUraP0j+845GYw37+EyT6A=
modernc.org/sqlite v1.21.0 h1:4aP4MdUf15i3R3M2mx6Q90WHKz3nZLoz96zlB6tNdow=
modernc.org/sqlite v1.21.0/go.mod h1:XwQ0wZPIh1iKb5mkvCJ3szzbhk+tykC8ZWqTRTgYRwI=
modernc.org/sqlite v1.22.1 h1:P2+Dhp5FR1RlVRkQ3dDfCiv3Ok8XPxqpe70IjYVA9oE=
modernc.org/sqlite v1.22.1/go.mod h1:OrDj17Mggn6MhE+iPbBNf7RGKODDE9NFT0f3EwDzJqk=
modernc.org/sqlite v1.26.0 h1:SocQdLRSYlA8W99V8YH0NES75thx19d9sB/aFc4R8Lw=
modernc.org/sqlite v1.26.0/go.mod h1:FL3pVXie73rg3Rii6V/u5BoHlSoyeZeIgKZEgHARyCU=
modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY=
modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E=
gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE=
gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A=
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
+201
View File
@@ -0,0 +1,201 @@
package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"image"
_ "image/jpeg"
_ "image/png"
"io"
"log"
"log/slog"
"mime/multipart"
"net/http"
"os"
"path"
"path/filepath"
"time"
"github.com/buckket/go-blurhash"
"gorm.io/gorm"
)
// For user uploaded images
type Image struct {
ID uint `gorm:"primarykey" json:"-"`
CreatedAt time.Time `json:"createdAt"`
Hash string `gorm:"uniqueIndex;not null" json:"-"`
BlurHash string `json:"blurHash"`
// Path constructable from hash alone, but I can't decide
// if I should have this or not so I figure it's easier
// to remove it later than to add it later....... -_-
Path string `gorm:"not null" json:"path"`
}
// Insert an image into database
func insertImage(db *gorm.DB, hash string, path string, f io.Reader) (Image, error) {
bh, _ := getBlurHash(f)
img := Image{
Hash: hash,
Path: path,
BlurHash: bh,
}
r := db.Where(Image{Hash: hash}).FirstOrCreate(&img)
if r.Error != nil {
slog.Error("insertImage firstOrCreate failed!", "error", r.Error)
return Image{}, errors.New("failed to select or create image")
}
return img, nil
}
func getBlurHash(img io.Reader) (string, error) {
i, _, err := image.Decode(img)
if err != nil {
// Handle errors
slog.Error("getBlurHash decoding image failed", "error", err)
return "", errors.New("decoding image failed")
}
bh, _ := blurhash.Encode(6, 5, i)
if err != nil {
// Handle errors
slog.Error("getBlurHash generation failed", "error", err)
return "", errors.New("blur hash generation failed")
}
slog.Debug("getBlurHash", "hash", bh)
return bh, nil
}
func cleanupImages(db *gorm.DB) {
slog.Info("cleanupImages running")
var unusedImgs []Image
// Select images that are not referenced by at least one other row.
// Currently only used for user avatars, add new tables when used.
db.Raw(`SELECT *
FROM images
WHERE NOT EXISTS (
SELECT 1
FROM users
WHERE users.avatar_id = images.id
);`).Scan(&unusedImgs)
slog.Info("cleanupImages: scanned for unused images", "amount", len(unusedImgs))
if len(unusedImgs) > 0 {
for _, v := range unusedImgs {
slog.Debug("cleanupImages: removing an image", "id", v.ID, "path", v.Path)
err := db.Transaction(func(tx *gorm.DB) error {
// Try to delete image from db
if err := tx.Where("id = ?", v.ID).Delete(&Image{}).Error; err != nil {
return err
}
// hope its ok to do this sorta thing here :skull:
if err := os.Remove(path.Join(DataPath, v.Path)); err != nil {
return err
}
// commit transaction if no errors
return nil
})
if err != nil {
slog.Error("cleanupImages: failed to remove image - db row and file kept", "img", v, "error", err)
} else {
slog.Debug("cleanupImages: successfully removed unused image.", "id", v.ID)
}
}
}
}
func isValidImageType(f multipart.File) error {
// Read first 512 bytes, since that is all `DetectContentType` will evaluate on.
// Reading whole file is a waste.
buff := make([]byte, 512)
if _, err := f.Read(buff); err != nil {
slog.Error("isValidImageType: failed to read file into buffer", "error", err)
return errors.New("failed to verify if image is valid")
}
t := http.DetectContentType(buff)
slog.Debug("isValidImageType", "type", t)
if t != "image/png" && t != "image/jpeg" && t != "image/webp" && t != "image/gif" {
slog.Debug("isValidImageType: rejecting file as not valid (supported) image type")
return errors.New("invalid file type")
}
return nil
}
func downloadAndInsertImage(db *gorm.DB, url string, imgSubPath string) (Image, error) {
slog.Debug("Attempting to download image", "url", url)
// Get the data
resp, err := http.Get(url)
if err != nil {
return Image{}, err
}
defer resp.Body.Close()
// Check server response
if resp.StatusCode != http.StatusOK {
return Image{}, fmt.Errorf("bad status: %s", resp.Status)
}
// Read body into byte array, then create new reader
// So we have the ability to seek.
b, err := io.ReadAll(resp.Body)
if err != nil {
slog.Error("downloadAndInsertImage failed to read response into byte array", "error", err)
return Image{}, err
}
br := bytes.NewReader(b)
h := sha256.New()
if _, err := io.Copy(h, br); err != nil {
log.Fatal(err) // TODO nu le fatal
}
hs := hex.EncodeToString(h.Sum(nil))
// Seek back for file
_, err = br.Seek(0, 0)
if err != nil {
slog.Error("downloadAndInsertImage seeking back to start of br failed", "error", err)
return Image{}, err
}
outp := path.Join("img/", imgSubPath, hs[0:1], hs+filepath.Ext(resp.Request.URL.Path))
dataOutP := path.Join(DataPath, outp)
// Create the file
out, err := os.Create(dataOutP)
if err != nil {
if os.IsNotExist(err) {
err = os.MkdirAll(path.Dir(dataOutP), 0764)
if err != nil {
return Image{}, err
}
// If dirs made, try making file again
out, err = os.Create(dataOutP)
if err != nil {
return Image{}, err
}
} else {
return Image{}, err
}
}
defer out.Close()
_, err = io.Copy(out, br)
if err != nil {
return Image{}, err
}
// Seek back for insertImage
_, err = br.Seek(0, 0)
if err != nil {
slog.Error("downloadAndInsertImage seeking back to start of br failed", "error", err)
return Image{}, err
}
img, err := insertImage(db, hs, outp, br)
if err != nil {
return Image{}, err
}
return img, nil
}
+57 -11
View File
@@ -1,10 +1,12 @@
package main
import (
"encoding/json"
"errors"
"log/slog"
"strconv"
"strings"
"time"
"gorm.io/gorm"
)
@@ -25,9 +27,14 @@ var (
)
type ImportRequest struct {
Name string `json:"name"`
TmdbID int `json:"tmdbId"`
Type ContentType `json:"type"`
Name string `json:"name"`
TmdbID int `json:"tmdbId"`
Type ContentType `json:"type"`
Rating int8 `json:"rating"`
RatingCustomDate *time.Time `json:"ratingCustomDate"`
Status WatchedStatus `json:"status"`
Thoughts string `json:"thoughts"`
DatesWatched []time.Time `json:"datesWatched"`
}
type ImportResponse struct {
@@ -45,19 +52,19 @@ func importContent(db *gorm.DB, userId uint, ar ImportRequest) (ImportResponse,
if ar.TmdbID != 0 && (ar.Type == MOVIE || ar.Type == SHOW) {
tid := strconv.Itoa(ar.TmdbID)
if ar.Type == MOVIE {
cr, err := movieDetails(tid, "", map[string]string{})
cr, err := movieDetails(db, tid, "", map[string]string{})
if err != nil {
return ImportResponse{}, errors.New("movie details request failed")
}
slog.Debug("import: by tmdbid of movie", "cr", cr)
return successfulImport(db, userId, cr.ID, MOVIE)
return successfulImport(db, userId, cr.ID, MOVIE, ar)
} else if ar.Type == SHOW {
cr, err := tvDetails(tid, "", map[string]string{})
cr, err := tvDetails(db, tid, "", map[string]string{})
if err != nil {
return ImportResponse{}, errors.New("tv details request failed")
}
slog.Debug("import: by tmdbid of tv", "cr", cr)
return successfulImport(db, userId, cr.ID, SHOW)
return successfulImport(db, userId, cr.ID, SHOW, ar)
}
}
sr, err := searchContent(ar.Name)
@@ -101,20 +108,36 @@ func importContent(db *gorm.DB, userId uint, ar ImportRequest) (ImportResponse,
// If one perfect match found, import it
if perfectMatch.ID != 0 {
slog.Debug("import: importing from perfect match")
return successfulImport(db, userId, perfectMatch.ID, ContentType(perfectMatch.MediaType))
return successfulImport(db, userId, perfectMatch.ID, ContentType(perfectMatch.MediaType), ar)
}
return ImportResponse{Type: IMPORT_MULTI, Results: pMatches}, nil
} else {
slog.Debug("import: success.. only found one result")
return successfulImport(db, userId, pMatches[0].ID, ContentType(pMatches[0].MediaType))
return successfulImport(db, userId, pMatches[0].ID, ContentType(pMatches[0].MediaType), ar)
}
}
func successfulImport(db *gorm.DB, userId uint, contentId int, contentType ContentType) (ImportResponse, error) {
func successfulImport(db *gorm.DB, userId uint, contentId int, contentType ContentType, ar ImportRequest) (ImportResponse, error) {
status := FINISHED
if ar.Status != "" {
status = ar.Status
}
// Get the latest date from DatesWatched if we have any.
var wDate time.Time
if len(ar.DatesWatched) > 0 {
for _, dw := range ar.DatesWatched {
if dw.After(wDate) {
wDate = dw
}
}
}
w, err := addWatched(db, userId, WatchedAddRequest{
Status: FINISHED,
Status: status,
ContentID: contentId,
ContentType: contentType,
Rating: ar.Rating,
Thoughts: ar.Thoughts,
WatchedDate: wDate,
}, IMPORTED_WATCHED)
if err != nil {
if err.Error() == "content already on watched list" {
@@ -124,5 +147,28 @@ func successfulImport(db *gorm.DB, userId uint, contentId int, contentType Conte
slog.Error("successfulImport: Failed to add content as watched", "error", err)
return ImportResponse{Type: IMPORT_FAILED}, nil
}
// Add activity of the original time the show was added to the users watchlist on whichever platform they are coming from.
if ar.RatingCustomDate != nil {
var addedActivity Activity
if len(w.Activity) > 0 {
activityJson, _ := json.Marshal(map[string]interface{}{"rating": ar.Rating, "linkedActivity": w.Activity[0].ID})
addedActivity, _ = addActivity(db, userId, ActivityAddRequest{WatchedID: w.ID, Type: IMPORTED_RATING, Data: string(activityJson), CustomDate: ar.RatingCustomDate})
} else {
addedActivity, _ = addActivity(db, userId, ActivityAddRequest{WatchedID: w.ID, Type: IMPORTED_RATING, Data: strconv.Itoa(int(ar.Rating)), CustomDate: ar.RatingCustomDate})
}
w.Activity = append(w.Activity, addedActivity)
}
// Add all dates watched as activity, if any
if len(ar.DatesWatched) > 0 {
for _, v := range ar.DatesWatched {
customDate := v
addedActivity, err := addActivity(db, userId, ActivityAddRequest{WatchedID: w.ID, Type: IMPORTED_ADDED_WATCHED, CustomDate: &customDate})
if err == nil {
w.Activity = append(w.Activity, addedActivity)
} else {
slog.Error("successfulImport: Failed to add dateswatched activity.", "date", v, "error", err)
}
}
}
return ImportResponse{Type: IMPORT_SUCCESS, WatchedEntry: w}, nil
}
+45 -12
View File
@@ -8,6 +8,9 @@ import (
"log/slog"
"net/http"
"net/url"
"time"
"github.com/gin-gonic/gin"
)
type JellyfinItemSearchResponse struct {
@@ -15,12 +18,27 @@ type JellyfinItemSearchResponse struct {
}
type JellyfinItems struct {
Name string `json:"Name"`
Type string `json:"Type"`
ServerID string `json:"ServerId"`
Id string `json:"Id"`
ProviderIds struct {
Tmdb string `json:"Tmdb"`
} `json:"ProviderIds"`
UserData struct {
Rating float64 `json:"Rating"`
PlayedPercentage float64 `json:"PlayedPercentage"`
UnplayedItemCount int64 `json:"UnplayedItemCount"`
PlaybackPositionTicks int64 `json:"PlaybackPositionTicks"`
PlayCount int64 `json:"PlayCount"`
IsFavorite bool `json:"IsFavorite"`
Likes bool `json:"Likes"`
LastPlayedDate time.Time `json:"LastPlayedDate"`
Played bool `json:"Played"`
Key string `json:"Key"`
ItemId string `json:"ItemId"`
} `json:"UserData"`
RecursiveItemCount int64 `json:"RecursiveItemCount"`
}
type JFContentFindResponse struct {
@@ -28,6 +46,33 @@ type JFContentFindResponse struct {
Url string `json:"url"`
}
// Jellyfin access middleware, ensures user is a jellyfin user.
// To be ran after AuthRequired middleware with extra data.
func JellyfinAccessRequired() gin.HandlerFunc {
return func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
slog.Debug("JellyfinAccessRequired middleware hit", "user_id", userId)
userType := c.MustGet("userType").(UserType)
userThirdPartyId := c.MustGet("userThirdPartyId").(string)
userThirdPartyAuth := c.MustGet("userThirdPartyAuth").(string)
if Config.JELLYFIN_HOST == "" {
slog.Error("JellyfinAccessRequired: Request made to login via Jellyfin, but JELLYFIN_HOST has not been configured.")
c.AbortWithStatus(401)
return
}
if userType != JELLYFIN_USER || userThirdPartyId == "" {
slog.Error("JellyfinAccessRequired: User is not a jellyfin user..", "user_type", userType, "user_third_party_id", userThirdPartyId)
c.AbortWithStatus(401)
return
}
if userThirdPartyAuth == "" {
slog.Error("JellyfinAccessRequired: User has no thirdPartyAuth token..")
c.AbortWithStatus(401)
return
}
}
}
func jellyfinAPIRequest(method string, ep string, p map[string]string, username string, userToken string, resp interface{}) error {
if Config.JELLYFIN_HOST == "" {
slog.Error("jellyfinAPIRequest: JELLYFIN_HOST not configured.")
@@ -97,18 +142,6 @@ func jellyfinContentFind(
contentName string,
contentTmdbId string,
) (JFContentFindResponse, error) {
if Config.JELLYFIN_HOST == "" {
slog.Error("Request made to login via Jellyfin, but JELLYFIN_HOST has not been configured.")
return JFContentFindResponse{}, errors.New("jellyfin login not enabled")
}
if userType != JELLYFIN_USER || userThirdPartyId == "" {
slog.Error("User is not a jellyfin user..", "user_type", userType, "user_third_party_id", userThirdPartyId)
return JFContentFindResponse{}, errors.New("not jellyfin user")
}
if userThirdPartyAuth == "" {
slog.Error("User has no thirdPartyAuth token..")
return JFContentFindResponse{}, errors.New("user has no jellyfin auth token")
}
if contentType == "" || contentName == "" {
slog.Error("Bad request", "content_type", contentType, "content_name", contentName)
return JFContentFindResponse{}, errors.New("content type or name not provided")
+311
View File
@@ -0,0 +1,311 @@
package main
import (
"errors"
"log/slog"
"strconv"
"gorm.io/gorm"
)
type JellyfinSeriesSeasonsResponse struct {
Items []JellyfinSeriesSeasonItem `json:"Items"`
}
type JellyfinSeriesSeasonItem struct {
JellyfinItems
// aka the season number
IndexNumber int `json:"IndexNumber"`
}
type JellyfinSeriesEpisodesResponse struct {
Items []JellyfinSeriesEpisodeItem `json:"Items"`
}
type JellyfinSeriesEpisodeItem struct {
JellyfinItems
// the episode number
IndexNumber int `json:"IndexNumber"`
// the episodes season number
ParentIndexNumber int `json:"ParentIndexNumber"`
}
type JellyfinSyncResponse struct {
JobId string `json:"jobId"`
}
// Perform the jellyfin sync.
// Gets each type of media separately from jellyfin and attempts to import them.
// Errors are added silently to the job.
func startJellyfinSync(
db *gorm.DB,
jobId string,
userId uint,
username string,
userThirdPartyId string,
userThirdPartyAuth string,
) {
// Get played movies
updateJobCurrentTask(jobId, userId, "syncing movies")
playedMovies := new(JellyfinItemSearchResponse)
err := jellyfinAPIRequest(
"GET",
"/Users/"+userThirdPartyId+"/Items",
map[string]string{
"Filters": "IsPlayed",
"IncludeItemTypes": "Movie",
"Fields": "ProviderIds",
"Recursive": "true",
},
username,
userThirdPartyAuth,
&playedMovies,
)
if err != nil {
slog.Error("jellyfinSyncWatched: Jellyfin API request failed", "error", err)
addJobError(jobId, userId, "failed to get jellyfin response for movies")
} else {
if len(playedMovies.Items) <= 0 {
slog.Info("jellyfinSyncWatched: User has no played movies.", "user_id", userId)
} else {
for _, v := range playedMovies.Items {
slog.Info("jellyfinSyncWatched: Importing played movie.", "movie_name", v.Name, "user_id", userId)
slog.Debug("jellyfinSyncWatched: Importing played movie.", "full_item", v, "user_id", userId)
// 1. Ensure we have a tmdbId
if v.ProviderIds.Tmdb == "" {
slog.Error("jellyfinSyncWatched: Movie to import does not have a tmdb id.", "movie_name", v.Name, "movie_ids", v.ProviderIds, "user_id", userId)
addJobError(jobId, userId, "movie could not be imported (no tmdbId present): "+v.Name)
continue
}
tmdbId, err := strconv.Atoi(v.ProviderIds.Tmdb)
if err != nil {
slog.Error("jellyfinSyncWatched: Movie to import does not have a parseable (to int) tmdb id.", "movie_name", v.Name, "movie_ids", v.ProviderIds, "user_id", userId)
addJobError(jobId, userId, "movie could not be imported (tmdbId was not parseable): "+v.Name)
continue
}
updateJobCurrentTask(jobId, userId, "syncing "+v.Name)
// 2. Imported watched movie
w, err := addWatched(db, userId, WatchedAddRequest{
Status: FINISHED,
ContentID: tmdbId,
ContentType: MOVIE,
WatchedDate: v.UserData.LastPlayedDate,
}, IMPORTED_WATCHED_JF)
if err != nil {
if err.Error() == "content already on watched list" {
slog.Error("jellyfinSyncWatched: Unique constraint hit.. content must already be on watch list.", "movie_name", v.Name, "movie_ids", v.ProviderIds, "user_id", userId)
} else {
slog.Error("jellyfinSyncWatched: Movie failed to import.", "movie_name", v.Name, "movie_ids", v.ProviderIds, "user_id", userId)
addJobError(jobId, userId, "movie could not be imported (failed when adding to watched list): "+v.Name)
}
} else {
// 3. Add IMPORTED_ADDED_WATCHED_JF activity
if !v.UserData.LastPlayedDate.IsZero() {
_, err := addActivity(db, userId, ActivityAddRequest{WatchedID: w.ID, Type: IMPORTED_ADDED_WATCHED_JF, CustomDate: &v.UserData.LastPlayedDate})
if err != nil {
slog.Error("jellyfinSyncWatched: Failed to add dateswatched activity.", "movie_name", v.Name,
"movie_ids", v.ProviderIds, "user_id", userId, "date", v.UserData.LastPlayedDate, "error", err)
}
}
}
}
}
}
// Get played series
// Can't rely on IsPlayed filter, since we want to get partially played series too.
updateJobCurrentTask(jobId, userId, "syncing series")
allSeries := new(JellyfinItemSearchResponse)
err = jellyfinAPIRequest(
"GET",
"/Users/"+userThirdPartyId+"/Items",
map[string]string{
"IncludeItemTypes": "Series",
"Fields": "ProviderIds,RecursiveItemCount",
"Recursive": "true",
"IsPlaceHolder": "false",
},
username,
userThirdPartyAuth,
&allSeries,
)
if err != nil {
slog.Error("jellyfinSyncWatched: Jellyfin API request failed", "error", err)
addJobError(jobId, userId, "failed to get jellyfin response for series")
} else {
if len(allSeries.Items) <= 0 {
slog.Info("jellyfinSyncWatched: No series found.", "user_id", userId)
} else {
// Import series
for _, v := range allSeries.Items {
slog.Info("jellyfinSyncWatched: Processing series.", "series_name", v.Name, "user_id", userId)
slog.Debug("jellyfinSyncWatched: Processing series.", "full_item", v, "user_id", userId)
// 1. Make sure show is watched or at least partially watched
if !v.UserData.Played && v.UserData.PlayedPercentage <= 0 && v.RecursiveItemCount == v.UserData.UnplayedItemCount {
slog.Debug("jellyfinSyncWatched: Skipping unwatched series:", "series_name", v.Name, "user_id", userId)
continue
}
// 1.1. Ensure we have a tmdbId
if v.ProviderIds.Tmdb == "" {
slog.Error("jellyfinSyncWatched: Series to import does not have a tmdb id.", "series_name", v.Name, "series_ids", v.ProviderIds, "user_id", userId)
addJobError(jobId, userId, "series could not be imported (no tmdbId present): "+v.Name)
continue
}
tmdbId, err := strconv.Atoi(v.ProviderIds.Tmdb)
if err != nil {
slog.Error("jellyfinSyncWatched: Series to import does not have a parseable (to int) tmdb id.", "series_name", v.Name, "series_ids", v.ProviderIds, "user_id", userId)
addJobError(jobId, userId, "series could not be imported (tmdbId was not parseable): "+v.Name)
continue
}
updateJobCurrentTask(jobId, userId, "syncing serie "+v.Name)
// 2. Imported watched series
w, err := addWatched(db, userId, WatchedAddRequest{
Status: FINISHED,
ContentID: tmdbId,
ContentType: SHOW,
WatchedDate: v.UserData.LastPlayedDate,
}, IMPORTED_WATCHED_JF)
if err != nil {
if err.Error() == "content already on watched list" {
slog.Info("jellyfinSyncWatched: Unique constraint hit.. content must already be on watch list.",
"series_name", v.Name, "series_ids", v.ProviderIds, "user_id", userId, "watched_id", w.ID)
} else {
slog.Error("jellyfinSyncWatched: Series failed to import.", "series_name", v.Name, "series_ids", v.ProviderIds, "user_id", userId)
addJobError(jobId, userId, "series could not be imported (failed when adding to watched list): "+v.Name)
}
} else {
// 3. Add IMPORTED_ADDED_WATCHED activity (only if no err above, show also must not have already been on our list)
if !v.UserData.LastPlayedDate.IsZero() {
_, err := addActivity(db, userId, ActivityAddRequest{WatchedID: w.ID, Type: IMPORTED_ADDED_WATCHED_JF, CustomDate: &v.UserData.LastPlayedDate})
if err != nil {
slog.Error("jellyfinSyncWatched: Failed to add dateswatched activity.", "series_name", v.Name,
"series_ids", v.ProviderIds, "user_id", userId, "date", v.UserData.LastPlayedDate, "error", err)
}
}
}
// 4. Import watched seasons for this serie
// Get all show seasons (filtering isPlayed doesn't seem to be a thing, so we will have to do that ourselves)
seriesSeasons := new(JellyfinSeriesSeasonsResponse)
err = jellyfinAPIRequest(
"GET",
"/Shows/"+v.Id+"/Seasons",
map[string]string{
"UserId": userThirdPartyId,
"Fields": "ProviderIds",
"IsPlaceHolder": "false",
},
username,
userThirdPartyAuth,
&seriesSeasons,
)
if err != nil {
slog.Error("jellyfinSyncWatched: Failed to fetch series seasons.", "series_name", v.Name, "series_ids", v.ProviderIds, "user_id", userId, "error", err)
addJobError(jobId, userId, "series seasons could not be imported (request failed): "+v.Name)
} else if len(seriesSeasons.Items) <= 0 {
slog.Info("jellyfinSyncWatched: Series has no seasons.", "series_name", v.Name, "series_ids", v.ProviderIds, "user_id", userId)
} else {
for _, vs := range seriesSeasons.Items {
slog.Debug("jellyfinSyncWatched: Processing a season.", "full_item", v, "user_id", userId)
if !vs.UserData.Played {
slog.Debug("jellyfinSyncWatched: Skipping import of unplayed season.", "series_name", v.Name, "season_num", vs.IndexNumber, "user_id", userId)
continue
}
updateJobCurrentTask(jobId, userId, "syncing "+v.Name+" season "+strconv.Itoa(vs.IndexNumber))
_, err = addWatchedSeason(db, userId, WatchedSeasonAddRequest{
WatchedID: w.ID,
SeasonNumber: vs.IndexNumber,
Status: FINISHED,
addActivity: SEASON_ADDED_JF,
addActivityDate: vs.UserData.LastPlayedDate,
})
if err != nil {
slog.Error("jellyfinSyncWatched: Failed to fetch series seasons.", "series_name", v.Name, "series_ids", v.ProviderIds, "user_id", userId, "error", err)
addJobError(jobId, userId, "series season could not be imported (addWatchedSeason request failed): "+v.Name+" season "+strconv.Itoa(vs.IndexNumber))
}
}
}
// 5. Import watched episodes for this serie
// Gets all show episodes (filtering isPlayed doesn't seem to be a thing, so we will have to do that ourselves)
seriesEpisodes := new(JellyfinSeriesEpisodesResponse)
err = jellyfinAPIRequest(
"GET",
"/Shows/"+v.Id+"/Episodes",
map[string]string{
"UserId": userThirdPartyId,
"Fields": "ProviderIds",
"IsPlaceHolder": "false",
},
username,
userThirdPartyAuth,
&seriesEpisodes,
)
if err != nil {
slog.Error("jellyfinSyncWatched: Failed to fetch series episodes.", "series_name", v.Name, "series_ids", v.ProviderIds, "user_id", userId, "error", err)
addJobError(jobId, userId, "series episodes could not be imported (request failed): "+v.Name)
} else if len(seriesEpisodes.Items) <= 0 {
slog.Info("jellyfinSyncWatched: Series has no episodes.", "series_name", v.Name, "series_ids", v.ProviderIds, "user_id", userId)
} else {
for _, vs := range seriesEpisodes.Items {
slog.Debug("jellyfinSyncWatched: Processing an episode.", "full_item", v, "user_id", userId)
if !vs.UserData.Played {
slog.Debug("jellyfinSyncWatched: Skipping import of unplayed episode.", "series_name", v.Name, "season_num", vs.ParentIndexNumber, "episode_num", vs.IndexNumber, "user_id", userId)
continue
}
updateJobCurrentTask(jobId, userId, "syncing "+v.Name+" season "+strconv.Itoa(vs.ParentIndexNumber)+" episode "+strconv.Itoa(vs.IndexNumber))
_, err = addWatchedEpisodes(db, userId, WatchedEpisodeAddRequest{
WatchedID: w.ID,
SeasonNumber: vs.ParentIndexNumber,
EpisodeNumber: vs.IndexNumber,
Status: FINISHED,
addActivity: EPISODE_ADDED_JF,
addActivityDate: vs.UserData.LastPlayedDate,
})
if err != nil {
slog.Error("jellyfinSyncWatched: Failed to import series episode.", "series_name", v.Name, "season_num", vs.ParentIndexNumber, "episode_num", vs.IndexNumber, "user_id", userId, "error", err)
addJobError(jobId, userId, "series episode could not be imported (addWatchedEpisode request failed): "+v.Name+" "+vs.Name)
}
}
}
}
}
}
updateJobStatus(jobId, userId, JOB_DONE)
}
func jellyfinSyncWatched(
db *gorm.DB,
userId uint,
userType UserType,
username string,
userThirdPartyId string,
userThirdPartyAuth string,
) (JellyfinSyncResponse, error) {
jobId, err := addJob("jf_sync", userId)
if err != nil {
slog.Error("jellyfinSyncWatched: Failed to create a job", "error", err)
return JellyfinSyncResponse{}, errors.New("failed to create job")
}
updateJobStatus(jobId, userId, JOB_RUNNING)
go startJellyfinSync(
db,
jobId,
userId,
username,
userThirdPartyId,
userThirdPartyAuth,
)
return JellyfinSyncResponse{JobId: jobId}, nil
}
+125
View File
@@ -0,0 +1,125 @@
// We will use jobs only for storing/retrieving active job statuses for the client.
// Running the job will be done wherever needed, but isn't handled here.
// When starting a job elsewhere, we should first add a job here as active to get an `id`,
// this id should be used to update the active job so the client can request job status updates.
package main
import (
"errors"
"log/slog"
"time"
)
type JobStatus string
var (
JOB_CREATED JobStatus = "CREATED"
JOB_RUNNING JobStatus = "RUNNING"
JOB_DONE JobStatus = "DONE"
JOB_CANCELLED JobStatus = "CANCELLED"
)
type Job struct {
// We can give the job a name simply for showing on the client.
Name string `json:"name"`
// The current status of the job.
Status JobStatus `json:"status"`
// The current task we are performing inside the job.
// Just so we can portray progress on the client by displaying the current task.
CurrentTask string `json:"currentTask,omitempty"`
// Errors that occurred in the task
Errors []string `json:"errors"`
// Stored for access control.
UserId uint `json:"-"`
}
var activeJobs = make(map[string]*Job)
// Add a job to our activeJobs map.
// Returns id of job on success, or error if failed to add.
func addJob(name string, userId uint) (string, error) {
idk, err := generateString(8)
if err != nil {
return "", err
}
_, ok := activeJobs[idk]
if ok {
// Lets just hope this doesn't happen, may the odds be with us.
return "", errors.New("job already exists with id generated, please try again")
}
activeJobs[idk] = &Job{
Name: name,
Status: JOB_CREATED,
UserId: userId,
}
return idk, nil
}
func rmJob(id string, userId uint) {
slog.Debug("rmJob: Removing a job.", "id", id)
v, ok := activeJobs[id]
if ok && v.UserId == userId {
delete(activeJobs, id)
slog.Debug("rmJob: Removed a job.", "id", id)
return
}
slog.Debug("rmJob: Job to remove does not exist (or not owned by this user).", "id", id, "user_id", userId)
}
// Get a job.
// Returns job if found, otherwise errors if job does not exist.
func getJob(id string, userId uint) (*Job, error) {
j, ok := activeJobs[id]
if ok {
// Ensure user requesting a job, owns the job.
if j.UserId != userId {
slog.Warn("getJob: A user tried to access a job they do not own.", "user_id", userId, "job_id", id)
return &Job{}, errors.New("job does not exist")
}
return j, nil
}
return &Job{}, errors.New("job does not exist")
}
// Update a jobs status.
func updateJobStatus(id string, userId uint, status JobStatus) error {
j, err := getJob(id, userId)
if err != nil {
slog.Error("updateJobStatus: Failed!", "status", status, "error", err)
return err
}
j.Status = status
// If job is set to done, remove it after 1 minute.
if status == JOB_DONE {
slog.Debug("updateJobStatus: Job set to done. Will be removed after 1m.", "id", id)
go func() {
time.Sleep(1 * time.Minute)
slog.Debug("updateJobStatus: Job done. waited 1m.. removing job now.", "id", id)
rmJob(id, userId)
}()
}
return nil
}
// Update a jobs current task.
func updateJobCurrentTask(id string, userId uint, ct string) error {
j, err := getJob(id, userId)
if err != nil {
slog.Error("updateJobCurrentTask: Failed!", "ct", ct, "error", err)
return err
}
j.CurrentTask = ct
return nil
}
// Add an error to a job.
func addJobError(id string, userId uint, e string) error {
j, err := getJob(id, userId)
if err != nil {
slog.Error("updateJobCurrentTask: Failed!", "e", e, "error", err)
return err
}
j.Errors = append(j.Errors, e)
return nil
}
+676
View File
@@ -0,0 +1,676 @@
package main
import (
"encoding/json"
"encoding/xml"
"errors"
"io"
"log/slog"
"net/http"
"time"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type PlexLoginRequest struct {
AuthToken string `json:"token" binding:"required"`
ClientIdentifier string `json:"clientIdentifier" binding:"required"`
}
type PlexUser struct {
Id uint64 `json:"id" binding:"required"`
Uuid string `json:"uuid" binding:"required"`
Email string `json:"email" binding:"required"`
Username string `json:"username" binding:"required"`
}
type PlexAccountResponse struct {
User PlexUser `json:"user" binding:"required"`
}
type PlexIdentity struct {
MediaContainer struct {
MachineIdentifier string `json:"machineIdentifier"`
} `json:"MediaContainer"`
}
type PlexHostConfigUpdateResponse struct {
PLEX_MACHINE_ID string
}
type PlexUsersResponse struct {
XMLName xml.Name `xml:"MediaContainer"`
Text string `xml:",chardata"`
FriendlyName string `xml:"friendlyName,attr"`
Identifier string `xml:"identifier,attr"`
MachineIdentifier string `xml:"machineIdentifier,attr"`
TotalSize string `xml:"totalSize,attr"`
Size string `xml:"size,attr"`
User []struct {
Text string `xml:",chardata"`
ID string `xml:"id,attr"`
Title string `xml:"title,attr"`
Username string `xml:"username,attr"`
Email string `xml:"email,attr"`
RecommendationsPlaylistId string `xml:"recommendationsPlaylistId,attr"`
Thumb string `xml:"thumb,attr"`
Protected string `xml:"protected,attr"`
Home string `xml:"home,attr"`
AllowTuners string `xml:"allowTuners,attr"`
AllowSync string `xml:"allowSync,attr"`
AllowCameraUpload string `xml:"allowCameraUpload,attr"`
AllowChannels string `xml:"allowChannels,attr"`
AllowSubtitleAdmin string `xml:"allowSubtitleAdmin,attr"`
FilterAll string `xml:"filterAll,attr"`
FilterMovies string `xml:"filterMovies,attr"`
FilterMusic string `xml:"filterMusic,attr"`
FilterPhotos string `xml:"filterPhotos,attr"`
FilterTelevision string `xml:"filterTelevision,attr"`
Restricted string `xml:"restricted,attr"`
Server []struct {
Text string `xml:",chardata"`
ID string `xml:"id,attr"`
ServerId string `xml:"serverId,attr"`
MachineIdentifier string `xml:"machineIdentifier,attr"`
Name string `xml:"name,attr"`
LastSeenAt string `xml:"lastSeenAt,attr"`
NumLibraries string `xml:"numLibraries,attr"`
AllLibraries string `xml:"allLibraries,attr"`
Owned string `xml:"owned,attr"`
Pending string `xml:"pending,attr"`
} `xml:"Server"`
} `xml:"User"`
}
// Plex get libraries response
// /library/sections
type PlexLibrariesResponse struct {
MediaContainer struct {
Size int `json:"size"`
AllowSync bool `json:"allowSync"`
Title1 string `json:"title1"`
Directory []struct {
AllowSync bool `json:"allowSync"`
Art string `json:"art"`
Composite string `json:"composite"`
Filters bool `json:"filters"`
Refreshing bool `json:"refreshing"`
Thumb string `json:"thumb"`
Key string `json:"key"`
Type string `json:"type"`
Title string `json:"title"`
Agent string `json:"agent"`
Scanner string `json:"scanner"`
Language string `json:"language"`
UUID string `json:"uuid"`
UpdatedAt int `json:"updatedAt"`
CreatedAt int `json:"createdAt"`
ScannedAt int `json:"scannedAt"`
Content bool `json:"content"`
Directory bool `json:"directory"`
ContentChangedAt int64 `json:"contentChangedAt"`
Hidden int `json:"hidden"`
Location []struct {
ID int `json:"id"`
Path string `json:"path"`
} `json:"Location"`
} `json:"Directory"`
} `json:"MediaContainer"`
}
// Plex get all library items response (with includeGuids parameter)
// /library/sections/{sectionId}/all
type PlexLibraryItemsResponse struct {
MediaContainer struct {
Size int `json:"size"`
AllowSync bool `json:"allowSync"`
Art string `json:"art"`
Identifier string `json:"identifier"`
LibrarySectionID int `json:"librarySectionID"`
LibrarySectionTitle string `json:"librarySectionTitle"`
LibrarySectionUUID string `json:"librarySectionUUID"`
MediaTagPrefix string `json:"mediaTagPrefix"`
MediaTagVersion int `json:"mediaTagVersion"`
Thumb string `json:"thumb"`
Title1 string `json:"title1"`
Title2 string `json:"title2"`
ViewGroup string `json:"viewGroup"`
ViewMode int `json:"viewMode"`
Metadata []struct {
RatingKey string `json:"ratingKey"`
Key string `json:"key"`
GUID string `json:"guid"` // Plex guid
Slug string `json:"slug"`
Studio string `json:"studio"`
Type string `json:"type"`
Title string `json:"title"`
ContentRating string `json:"contentRating"`
Summary string `json:"summary"`
Rating float64 `json:"rating"`
UserRating float64 `json:"userRating"`
AudienceRating float64 `json:"audienceRating"`
ViewCount int `json:"viewCount,omitempty"`
LastViewedAt int64 `json:"lastViewedAt,omitempty"`
Year int `json:"year"`
Tagline string `json:"tagline"`
Thumb string `json:"thumb"`
Art string `json:"art"`
Duration int `json:"duration"`
OriginallyAvailableAt string `json:"originallyAvailableAt"`
AddedAt int `json:"addedAt"`
UpdatedAt int `json:"updatedAt"`
AudienceRatingImage string `json:"audienceRatingImage"`
HasPremiumPrimaryExtra string `json:"hasPremiumPrimaryExtra"`
RatingImage string `json:"ratingImage"`
LeafCount int `json:"leafCount,omitempty"`
ViewedLeafCount int `json:"viewedLeafCount,omitempty"`
Media []struct {
ID int `json:"id"`
Duration int `json:"duration"`
Bitrate int `json:"bitrate"`
Width int `json:"width"`
Height int `json:"height"`
AspectRatio float64 `json:"aspectRatio"`
AudioChannels int `json:"audioChannels"`
AudioCodec string `json:"audioCodec"`
VideoCodec string `json:"videoCodec"`
VideoResolution string `json:"videoResolution"`
Container string `json:"container"`
VideoFrameRate string `json:"videoFrameRate"`
VideoProfile string `json:"videoProfile"`
Part []struct {
ID int `json:"id"`
Key string `json:"key"`
Duration int `json:"duration"`
File string `json:"file"`
Size int64 `json:"size"`
Container string `json:"container"`
HasThumbnail string `json:"hasThumbnail"`
VideoProfile string `json:"videoProfile"`
} `json:"Part"`
} `json:"Media"`
// External ids
Guid []struct {
ID string `json:"id"`
} `json:"Guid"`
Genre []struct {
Tag string `json:"tag"`
} `json:"Genre"`
Country []struct {
Tag string `json:"tag"`
} `json:"Country"`
Director []struct {
Tag string `json:"tag"`
} `json:"Director"`
Writer []struct {
Tag string `json:"tag"`
} `json:"Writer"`
Role []struct {
Tag string `json:"tag"`
} `json:"Role"`
ChapterSource string `json:"chapterSource,omitempty"`
} `json:"Metadata"`
} `json:"MediaContainer"`
}
// Plex get all children (seasons) for a serie.
// /library/metadata/{ratingKey}/children
type PlexLibraryItemSeasonsResponse struct {
MediaContainer struct {
Size int `json:"size"`
AllowSync bool `json:"allowSync"`
Art string `json:"art"`
Identifier string `json:"identifier"`
Key string `json:"key"`
LibrarySectionID int `json:"librarySectionID"`
LibrarySectionTitle string `json:"librarySectionTitle"`
LibrarySectionUUID string `json:"librarySectionUUID"`
MediaTagPrefix string `json:"mediaTagPrefix"`
MediaTagVersion int `json:"mediaTagVersion"`
Nocache bool `json:"nocache"`
ParentIndex int `json:"parentIndex"`
ParentTitle string `json:"parentTitle"`
ParentYear int `json:"parentYear"`
Summary string `json:"summary"`
Theme string `json:"theme"`
Thumb string `json:"thumb"`
Title1 string `json:"title1"`
Title2 string `json:"title2"`
ViewGroup string `json:"viewGroup"`
ViewMode int `json:"viewMode"`
Directory []struct {
LeafCount int `json:"leafCount"`
Thumb string `json:"thumb"`
ViewedLeafCount int `json:"viewedLeafCount"`
Key string `json:"key"`
Title string `json:"title"`
} `json:"Directory"`
Metadata []struct {
RatingKey string `json:"ratingKey"`
Key string `json:"key"`
ParentRatingKey string `json:"parentRatingKey"`
GUID string `json:"guid"`
ParentGUID string `json:"parentGuid"`
ParentSlug string `json:"parentSlug"`
ParentStudio string `json:"parentStudio"`
Type string `json:"type"`
Title string `json:"title"`
ParentKey string `json:"parentKey"`
ParentTitle string `json:"parentTitle"`
Summary string `json:"summary"`
Index int `json:"index"`
ParentIndex int `json:"parentIndex"`
UserRating float64 `json:"userRating,omitempty"`
LastRatedAt int64 `json:"lastRatedAt,omitempty"`
ParentYear int `json:"parentYear"`
Thumb string `json:"thumb"`
Art string `json:"art"`
ParentThumb string `json:"parentThumb"`
ParentTheme string `json:"parentTheme"`
LeafCount int `json:"leafCount"`
ViewedLeafCount int `json:"viewedLeafCount"`
AddedAt int `json:"addedAt"`
UpdatedAt int `json:"updatedAt"`
ViewCount int `json:"viewCount,omitempty"`
LastViewedAt int64 `json:"lastViewedAt,omitempty"`
} `json:"Metadata"`
} `json:"MediaContainer"`
}
// Plex get all children (episodes) for a season.
// /library/metadata/{ratingKey}/allLeaves
type PlexLibraryItemEpisodesResponse struct {
MediaContainer struct {
Size int `json:"size"`
AllowSync bool `json:"allowSync"`
Art string `json:"art"`
Identifier string `json:"identifier"`
Key string `json:"key"`
LibrarySectionID int `json:"librarySectionID"`
LibrarySectionTitle string `json:"librarySectionTitle"`
LibrarySectionUUID string `json:"librarySectionUUID"`
MediaTagPrefix string `json:"mediaTagPrefix"`
MediaTagVersion int `json:"mediaTagVersion"`
MixedParents bool `json:"mixedParents"`
Nocache bool `json:"nocache"`
ParentIndex int `json:"parentIndex"`
ParentTitle string `json:"parentTitle"`
ParentYear int `json:"parentYear"`
Theme string `json:"theme"`
Title1 string `json:"title1"`
Title2 string `json:"title2"`
ViewGroup string `json:"viewGroup"`
ViewMode int `json:"viewMode"`
Metadata []struct {
RatingKey string `json:"ratingKey"`
Key string `json:"key"`
ParentRatingKey string `json:"parentRatingKey"`
GrandparentRatingKey string `json:"grandparentRatingKey"`
GUID string `json:"guid"`
GrandparentSlug string `json:"grandparentSlug"`
Studio string `json:"studio"`
Type string `json:"type"`
Title string `json:"title"`
GrandparentKey string `json:"grandparentKey"`
ParentKey string `json:"parentKey"`
GrandparentTitle string `json:"grandparentTitle"`
ParentTitle string `json:"parentTitle"`
ContentRating string `json:"contentRating"`
Summary string `json:"summary"`
Index int `json:"index"`
ParentIndex int `json:"parentIndex"`
AudienceRating float64 `json:"audienceRating"`
Year int `json:"year"`
Thumb string `json:"thumb"`
Art string `json:"art"`
ParentThumb string `json:"parentThumb"`
GrandparentThumb string `json:"grandparentThumb"`
GrandparentArt string `json:"grandparentArt"`
GrandparentTheme string `json:"grandparentTheme"`
Duration int `json:"duration"`
OriginallyAvailableAt string `json:"originallyAvailableAt"`
AddedAt int `json:"addedAt"`
UpdatedAt int `json:"updatedAt"`
AudienceRatingImage string `json:"audienceRatingImage"`
ChapterSource string `json:"chapterSource"`
TitleSort string `json:"titleSort,omitempty"`
UserRating float64 `json:"userRating,omitempty"`
ViewCount int `json:"viewCount,omitempty"`
LastViewedAt int64 `json:"lastViewedAt,omitempty"`
LastRatedAt int64 `json:"lastRatedAt,omitempty"`
} `json:"Metadata"`
} `json:"MediaContainer"`
}
// Response from clients.plex.tv/api/v2/resources
// Used to get users auth token for home plex server.
type PlexClientResources []struct {
Name string `json:"name"`
Product string `json:"product"`
ProductVersion string `json:"productVersion"`
Platform string `json:"platform"`
PlatformVersion string `json:"platformVersion"`
Device string `json:"device"`
ClientIdentifier string `json:"clientIdentifier"`
CreatedAt time.Time `json:"createdAt"`
LastSeenAt time.Time `json:"lastSeenAt"`
Provides string `json:"provides"`
OwnerID interface{} `json:"ownerId"`
SourceTitle interface{} `json:"sourceTitle"`
PublicAddress string `json:"publicAddress"`
AccessToken string `json:"accessToken"`
Owned bool `json:"owned"`
Home bool `json:"home"`
Synced bool `json:"synced"`
Relay bool `json:"relay"`
Presence bool `json:"presence"`
HTTPSRequired bool `json:"httpsRequired"`
PublicAddressMatches bool `json:"publicAddressMatches"`
DNSRebindingProtection bool `json:"dnsRebindingProtection"`
NatLoopbackSupported bool `json:"natLoopbackSupported"`
Connections []struct {
Protocol string `json:"protocol"`
Address string `json:"address"`
Port int `json:"port"`
URI string `json:"uri"`
Local bool `json:"local"`
Relay bool `json:"relay"`
IPv6 bool `json:"IPv6"`
} `json:"connections"`
}
// Plex access middleware, ensures user is a Plex user.
// To be ran after AuthRequired middleware with extra data.
func PlexAccessRequired(db *gorm.DB) gin.HandlerFunc {
return func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
slog.Debug("PlexAccessRequired middleware hit", "user_id", userId)
userType := c.MustGet("userType").(UserType)
if Config.PLEX_HOST == "" || Config.PLEX_MACHINE_ID == "" {
slog.Error("PlexAccessRequired: Plex has not been configured.", "user_id", userId)
c.AbortWithStatus(401)
return
}
if userType != PLEX_USER {
slog.Error("PlexAccessRequired: User is not a Plex user..", "user_id", userId, "user_type", userType)
c.AbortWithStatus(401)
return
}
userPlexService := new(UserServices)
if res := db.Where("user_id = ? AND name = ?", userId, "plex").Take(&userPlexService); res.Error != nil {
slog.Error("PlexAccessRequired: Failed when attempting to get users plex service integration..", "user_id", userId, "user_type", userType)
c.AbortWithStatus(401)
return
}
if userPlexService.ClientID == "" || userPlexService.AuthToken == "" || userPlexService.AuthToken2 == "" {
slog.Error("PlexAccessRequired: User has missing details from service (clientId, authToken or authToken2)..", "user_id", userId, "client_id", userPlexService.ClientID)
c.AbortWithStatus(401)
return
}
c.Set("plexAuthToken", userPlexService.AuthToken)
c.Set("plexLocalAuthToken", userPlexService.AuthToken2)
}
}
func getPlexIdentity(host string) (PlexIdentity, error) {
httpClient := &http.Client{}
req, err := http.NewRequest("GET", host+"/identity", nil)
if err != nil {
return PlexIdentity{}, err
}
req.Header.Set("Accept", "application/json")
resp, err := httpClient.Do(req)
if err != nil {
return PlexIdentity{}, err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return PlexIdentity{}, err
}
defer resp.Body.Close()
var pi PlexIdentity
err = json.Unmarshal(body, &pi)
if err != nil {
return PlexIdentity{}, err
}
return pi, nil
}
func fetchPlexAccountFromToken(token string) (PlexUser, error) {
httpClient := &http.Client{}
req, err := http.NewRequest("GET", "https://plex.tv/users/account.json", nil)
if err != nil {
return PlexUser{}, err
}
req.Header.Set("X-Plex-Token", token)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
resp, err := httpClient.Do(req)
if err != nil {
return PlexUser{}, err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return PlexUser{}, err
}
slog.Info(string(body))
defer resp.Body.Close()
var pa PlexAccountResponse
err = json.Unmarshal(body, &pa)
if err != nil {
return PlexUser{}, err
}
return pa.User, nil
}
// Update plex host setting
func updateConfigPlexHost(v string) (PlexHostConfigUpdateResponse, error) {
Config.PLEX_HOST = v
if Config.PLEX_HOST != "" {
pi, err := getPlexIdentity(Config.PLEX_HOST)
if err != nil {
slog.Error("updateConfigPlexHost: Failed to get plex server identity!", "error", err)
return PlexHostConfigUpdateResponse{}, errors.New("failed to get Plex server identity. Please try setting the Plex Host again or setting PLEX_MACHINE_ID manually in your config file")
}
if pi.MediaContainer.MachineIdentifier == "" {
slog.Error("updateConfigPlexHost: Plex server identity response had no machine id!", "response", pi)
return PlexHostConfigUpdateResponse{}, errors.New("got Plex server identity, but no machine id was found")
}
Config.PLEX_MACHINE_ID = pi.MediaContainer.MachineIdentifier
} else {
Config.PLEX_MACHINE_ID = ""
}
if err := writeConfig(); err != nil {
slog.Error("updateConfigPlexHost: Failed to write updated config to file!", "err", err)
return PlexHostConfigUpdateResponse{}, errors.New("failed to write config")
}
return PlexHostConfigUpdateResponse{PLEX_MACHINE_ID: Config.PLEX_MACHINE_ID}, nil
}
// If a plex user has access to our home plex server (PLEX_HOST).
func plexUserHasAccessToPlexHost(token string) error {
httpClient := &http.Client{}
req, err := http.NewRequest("GET", "https://plex.tv/api/users", nil)
if err != nil {
return err
}
req.Header.Set("X-Plex-Token", token)
resp, err := httpClient.Do(req)
if err != nil {
return err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
defer resp.Body.Close()
var pa PlexUsersResponse
err = xml.Unmarshal(body, &pa)
if err != nil {
return err
}
if len(pa.User) <= 0 {
return errors.New("found no users in response")
}
// Now check if any of the users servers include our home server machine id
homeServerFound := false
userLoop:
for _, user := range pa.User {
for _, server := range user.Server {
if server.MachineIdentifier == Config.PLEX_MACHINE_ID {
slog.Debug("plexUserHasAccessToPlexHost: Processing a server.", "server", server.MachineIdentifier)
homeServerFound = true
break userLoop
}
}
if homeServerFound {
break
}
}
if homeServerFound {
return nil
}
return errors.New("user does not have access to home plex server")
}
func getPlexLibraries(plexAuth string) (PlexLibrariesResponse, error) {
httpClient := &http.Client{}
req, err := http.NewRequest("GET", Config.PLEX_HOST+"/library/sections", nil)
if err != nil {
return PlexLibrariesResponse{}, err
}
req.Header.Add("Accept", "application/json")
req.Header.Set("X-Plex-Token", plexAuth)
resp, err := httpClient.Do(req)
if err != nil {
return PlexLibrariesResponse{}, err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return PlexLibrariesResponse{}, err
}
defer resp.Body.Close()
var pl PlexLibrariesResponse
err = json.Unmarshal(body, &pl)
if err != nil {
return PlexLibrariesResponse{}, err
}
return pl, nil
}
func getPlexLibraryItems(plexAuth string, libraryKey string) (PlexLibraryItemsResponse, error) {
httpClient := &http.Client{}
req, err := http.NewRequest("GET", Config.PLEX_HOST+"/library/sections/"+libraryKey+"/all?includeGuids=1", nil)
if err != nil {
return PlexLibraryItemsResponse{}, err
}
req.Header.Add("Accept", "application/json")
req.Header.Set("X-Plex-Token", plexAuth)
resp, err := httpClient.Do(req)
if err != nil {
return PlexLibraryItemsResponse{}, err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return PlexLibraryItemsResponse{}, err
}
defer resp.Body.Close()
var pl PlexLibraryItemsResponse
err = json.Unmarshal(body, &pl)
if err != nil {
return PlexLibraryItemsResponse{}, err
}
return pl, nil
}
func getPlexLibraryItemSeasons(plexAuth string, ratingKey string) (PlexLibraryItemSeasonsResponse, error) {
httpClient := &http.Client{}
req, err := http.NewRequest("GET", Config.PLEX_HOST+"/library/metadata/"+ratingKey+"/children", nil)
if err != nil {
return PlexLibraryItemSeasonsResponse{}, err
}
req.Header.Add("Accept", "application/json")
req.Header.Set("X-Plex-Token", plexAuth)
resp, err := httpClient.Do(req)
if err != nil {
return PlexLibraryItemSeasonsResponse{}, err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return PlexLibraryItemSeasonsResponse{}, err
}
defer resp.Body.Close()
var pl PlexLibraryItemSeasonsResponse
err = json.Unmarshal(body, &pl)
if err != nil {
return PlexLibraryItemSeasonsResponse{}, err
}
return pl, nil
}
func getPlexLibraryItemEpisodes(plexAuth string, ratingKey string) (PlexLibraryItemEpisodesResponse, error) {
httpClient := &http.Client{}
req, err := http.NewRequest("GET", Config.PLEX_HOST+"/library/metadata/"+ratingKey+"/allLeaves", nil)
if err != nil {
return PlexLibraryItemEpisodesResponse{}, err
}
req.Header.Add("Accept", "application/json")
req.Header.Set("X-Plex-Token", plexAuth)
resp, err := httpClient.Do(req)
if err != nil {
return PlexLibraryItemEpisodesResponse{}, err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return PlexLibraryItemEpisodesResponse{}, err
}
defer resp.Body.Close()
var pl PlexLibraryItemEpisodesResponse
err = json.Unmarshal(body, &pl)
if err != nil {
return PlexLibraryItemEpisodesResponse{}, err
}
return pl, nil
}
// Gets users auth token for local plex server,
// so they can authenticate against it for api requests.
func getPlexHomeServerAuthToken(plexAuth string, userClientId string) (string, error) {
httpClient := &http.Client{}
req, err := http.NewRequest("GET", "https://clients.plex.tv/api/v2/resources", nil)
if err != nil {
return "", err
}
req.Header.Add("Accept", "application/json")
req.Header.Set("X-Plex-Token", plexAuth)
req.Header.Set("X-Plex-Client-Identifier", userClientId)
resp, err := httpClient.Do(req)
if err != nil {
return "", err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
defer resp.Body.Close()
var pl PlexClientResources
err = json.Unmarshal(body, &pl)
if err != nil {
return "", err
}
authToken := ""
for _, v := range pl {
if v.ClientIdentifier == Config.PLEX_MACHINE_ID {
slog.Debug("getPlexHomeServerAuthToken: Found entry with clientIdentifier matching home server machine id.")
if v.AccessToken == "" {
slog.Warn("getPlexHomeServerAuthToken: Matching entry has no AccessToken!")
continue
}
authToken = v.AccessToken
}
}
return authToken, nil
}
+267
View File
@@ -0,0 +1,267 @@
package main
import (
"errors"
"log/slog"
"strconv"
"strings"
"time"
"gorm.io/gorm"
)
type PlexSyncResponse struct {
JobId string `json:"jobId"`
}
// Perform a Plex sync.
// Errors are added silently to the job.
func startPlexSync(
db *gorm.DB,
jobId string,
userId uint,
userPlexLocalAuth string,
) {
updateJobCurrentTask(jobId, userId, "fetching libraries")
libraries, err := getPlexLibraries(userPlexLocalAuth)
if err != nil {
slog.Error("plexSyncWatched: Failed to fetch libraries", "user_id", userId, "error", err)
addJobError(jobId, userId, "failed to get plex libraries")
updateJobStatus(jobId, userId, JOB_DONE)
return
}
for _, library := range libraries.MediaContainer.Directory {
slog.Debug("plexSyncWatched: Processing a library", "library_title", library.Title, "library_type", library.Type, "user_id", userId)
if library.Type == "movie" {
updateJobCurrentTask(jobId, userId, "importing movies from "+library.Title)
movies, err := getPlexLibraryItems(userPlexLocalAuth, library.Key)
if err != nil {
slog.Error("plexSyncWatched: Failed to fetch movies from library", "library", library.Key, "user_id", userId, "error", err)
addJobError(jobId, userId, "failed to fetch movies from library "+library.Key)
continue
}
for _, movie := range movies.MediaContainer.Metadata {
if movie.ViewCount == 0 {
// Not viewed and not rated, skip importing
slog.Debug("plexSyncWatched: Skipping unwatched movie:", "movie_name", movie.Title, "user_id", userId)
continue
}
updateJobCurrentTask(jobId, userId, "importing movie "+movie.Title)
slog.Info("plexSyncWatched: Importing movie.", "movie_name", movie.Title, "user_id", userId)
// Find tmdb id
if len(movie.Guid) <= 0 {
slog.Error("plexSyncWatched: Movie to import does not have any external guids.", "movie_name", movie.Title, "movie_id", movie.GUID, "user_id", userId)
addJobError(jobId, userId, "movie could not be imported (no external ids present): "+movie.Title)
continue
}
tmdbIdStr := ""
for _, v := range movie.Guid {
if strings.HasPrefix(v.ID, "tmdb://") {
tmdbIdStr = v.ID[7:]
break
}
}
if tmdbIdStr == "" {
slog.Error("plexSyncWatched: Movie to import does not have a tmdb id.", "movie_name", movie.Title, "tmdb_id_str", tmdbIdStr, "movie_id", movie.GUID, "user_id", userId)
addJobError(jobId, userId, "movie could not be imported (no tmdbId present): "+movie.Title)
continue
}
tmdbId, err := strconv.Atoi(tmdbIdStr)
if err != nil {
slog.Error("plexSyncWatched: Movie to import does not have a parseable (to int) tmdb id.", "movie_name", movie.Title, "tmdb_id_str", tmdbIdStr, "movie_id", movie.GUID, "user_id", userId)
addJobError(jobId, userId, "movie could not be imported (tmdbId was not parseable): "+movie.Title)
continue
}
lastViewedAt := time.Unix(movie.LastViewedAt, 0)
w, err := addWatched(db, userId, WatchedAddRequest{
Status: FINISHED,
ContentID: tmdbId,
ContentType: MOVIE,
Rating: int8(movie.UserRating),
WatchedDate: lastViewedAt,
}, IMPORTED_WATCHED_PLEX)
if err != nil {
if err.Error() == "content already on watched list" {
slog.Error("plexSyncWatched: unique constraint hit. movie must already be on watch list", "error", err)
continue
}
slog.Error("plexSyncWatched: Failed to add movie as watched", "error", err)
addJobError(jobId, userId, "failed to add movie "+movie.Title)
} else {
// 3. Add IMPORTED_ADDED_WATCHED_PLEX activity
if !lastViewedAt.IsZero() {
_, err := addActivity(db, userId, ActivityAddRequest{
WatchedID: w.ID,
Type: IMPORTED_ADDED_WATCHED_PLEX,
CustomDate: &lastViewedAt,
})
if err != nil {
slog.Error("plexSyncWatched: Failed to add dateswatched activity.", "movie_name", movie.Title,
"movie_id", movie.GUID, "user_id", userId, "date", lastViewedAt, "unparsed_date", movie.LastViewedAt, "error", err)
}
}
}
}
} else if library.Type == "show" {
updateJobCurrentTask(jobId, userId, "importing tv shows from "+library.Title)
shows, err := getPlexLibraryItems(userPlexLocalAuth, library.Key)
if err != nil {
slog.Error("plexSyncWatched: Failed to fetch shows from library", "library", library.Key, "error", err)
addJobError(jobId, userId, "failed to fetch shows from library "+library.Key)
continue
}
for _, show := range shows.MediaContainer.Metadata {
if show.ViewedLeafCount != show.LeafCount {
// Not viewed, skip importing
// (could be improved to set status as watching when viewedLeafCount is higher than 0)
slog.Debug("plexSyncWatched: Skipping unwatched show:", "show_name", show.Title, "leaf_count", show.LeafCount, "viewed_leaf_count", show.ViewedLeafCount, "user_id", userId)
continue
}
updateJobCurrentTask(jobId, userId, "importing show "+show.Title)
slog.Info("plexSyncWatched: Importing show.", "show_name", show.Title, "user_id", userId)
tmdbIdStr := ""
for _, v := range show.Guid {
if strings.HasPrefix(v.ID, "tmdb://") {
tmdbIdStr = v.ID[7:]
break
}
}
if tmdbIdStr == "" {
slog.Error("plexSyncWatched: Show to import does not have a tmdb id.", "show_name", show.Title, "tmdb_id_str", tmdbIdStr, "show_id", show.GUID, "user_id", userId)
addJobError(jobId, userId, "movie could not be imported (no tmdbId present): "+show.Title)
continue
}
tmdbId, err := strconv.Atoi(tmdbIdStr)
if err != nil {
slog.Error("plexSyncWatched: Show to import does not have a parseable (to int) tmdb id.", "show_name", show.Title, "tmdb_id_str", tmdbIdStr, "show_id", show.GUID, "user_id", userId)
addJobError(jobId, userId, "show could not be imported (tmdbId was not parseable): "+show.Title)
continue
}
lastViewedAt := time.Unix(show.LastViewedAt, 0)
w, err := addWatched(db, userId, WatchedAddRequest{
Status: FINISHED,
ContentID: tmdbId,
ContentType: SHOW,
Rating: int8(show.UserRating),
WatchedDate: lastViewedAt,
}, IMPORTED_WATCHED_PLEX)
if err != nil {
if err.Error() == "content already on watched list" {
slog.Info("plexSyncWatched: unique constraint hit. show must already be on watch list", "error", err)
} else {
slog.Error("plexSyncWatched: Failed to add show as watched", "error", err)
addJobError(jobId, userId, "failed to add show "+show.Title)
}
} else {
// 3. Add IMPORTED_ADDED_WATCHED_PLEX activity
if !lastViewedAt.IsZero() {
_, err := addActivity(db, userId, ActivityAddRequest{
WatchedID: w.ID,
Type: IMPORTED_ADDED_WATCHED_PLEX,
CustomDate: &lastViewedAt,
})
if err != nil {
slog.Error("plexSyncWatched: Failed to add dateswatched activity.", "movie_name", show.Title,
"movie_id", show.GUID, "user_id", userId, "date", lastViewedAt, "unparsed_date", show.LastViewedAt, "error", err)
}
}
}
// Import watched seasons for this serie
seriesSeasons, err := getPlexLibraryItemSeasons(userPlexLocalAuth, show.RatingKey)
if err != nil {
slog.Error("plexSyncWatched: Failed to fetch series seasons.", "series_name", show.Title, "series_id", show.GUID, "user_id", userId, "error", err)
addJobError(jobId, userId, "series seasons could not be imported (request failed): "+show.Title)
} else if len(seriesSeasons.MediaContainer.Metadata) <= 0 {
slog.Info("plexSyncWatched: Series has no seasons.", "series_name", show.Title, "serie_ids", show.GUID, "user_id", userId)
} else {
for _, vs := range seriesSeasons.MediaContainer.Metadata {
slog.Debug("plexSyncWatched: Processing a season.", "full_item", vs, "user_id", userId)
if vs.ViewedLeafCount != vs.LeafCount {
slog.Debug("plexSyncWatched: Skipping import of unplayed season.", "series_name", show.Title, "season_num", vs.Index, "user_id", userId)
continue
}
updateJobCurrentTask(jobId, userId, "syncing "+show.Title+" season "+strconv.Itoa(vs.Index))
var seasonLastViewedAt time.Time
if vs.LastViewedAt != 0 {
seasonLastViewedAt = time.Unix(vs.LastViewedAt, 0)
}
_, err = addWatchedSeason(db, userId, WatchedSeasonAddRequest{
WatchedID: w.ID,
SeasonNumber: vs.Index,
Status: FINISHED,
addActivity: SEASON_ADDED_PLEX,
addActivityDate: seasonLastViewedAt,
})
if err != nil {
slog.Error("plexSyncWatched: Failed to fetch series seasons.", "series_name", show.Title, "series_id", show.GUID, "user_id", userId, "error", err)
addJobError(jobId, userId, "series season could not be imported (addWatchedSeason request failed): "+show.Title+" season "+strconv.Itoa(vs.Index))
}
}
}
// Import watched episodes for this serie
seriesEpisodes, err := getPlexLibraryItemEpisodes(userPlexLocalAuth, show.RatingKey)
if err != nil {
slog.Error("plexSyncWatched: Failed to fetch series episodes.", "series_name", show.Title, "series_id", show.GUID, "user_id", userId, "error", err)
addJobError(jobId, userId, "series episodes could not be imported (request failed): "+show.Title)
} else if len(seriesEpisodes.MediaContainer.Metadata) <= 0 {
slog.Info("plexSyncWatched: Series has no episodes.", "series_name", show.Title, "series_id", show.GUID, "user_id", userId)
} else {
for _, vs := range seriesEpisodes.MediaContainer.Metadata {
slog.Debug("plexSyncWatched: Processing an episode.", "full_item", vs, "user_id", userId)
if vs.ViewCount <= 0 {
slog.Debug("plexSyncWatched: Skipping import of unplayed episode.", "series_name", show.Title, "season_num", vs.ParentIndex, "episode_num", vs.Index, "user_id", userId)
continue
}
updateJobCurrentTask(jobId, userId, "syncing "+show.Title+" season "+strconv.Itoa(vs.ParentIndex)+" episode "+strconv.Itoa(vs.Index))
var episodeLastViewedAt time.Time
if vs.LastViewedAt != 0 {
episodeLastViewedAt = time.Unix(vs.LastViewedAt, 0)
}
_, err = addWatchedEpisodes(db, userId, WatchedEpisodeAddRequest{
WatchedID: w.ID,
SeasonNumber: vs.ParentIndex,
EpisodeNumber: vs.Index,
Status: FINISHED,
addActivity: EPISODE_ADDED_PLEX,
addActivityDate: episodeLastViewedAt,
})
if err != nil {
slog.Error("plexSyncWatched: Failed to import series episode.", "series_name", show.Title, "season_num", vs.ParentIndex, "episode_num", vs.Index, "user_id", userId, "error", err)
addJobError(jobId, userId, "series episode could not be imported (addWatchedEpisode request failed): "+show.Title+" "+vs.Title)
}
}
}
}
}
}
updateJobStatus(jobId, userId, JOB_DONE)
}
func plexSyncWatched(
db *gorm.DB,
userId uint,
userPlexLocalAuth string,
) (PlexSyncResponse, error) {
jobId, err := addJob("plex_sync", userId)
if err != nil {
slog.Error("startPlexSync: Failed to create a job", "error", err)
return PlexSyncResponse{}, errors.New("failed to create job")
}
updateJobStatus(jobId, userId, JOB_RUNNING)
go startPlexSync(
db,
jobId,
userId,
userPlexLocalAuth,
)
return PlexSyncResponse{JobId: jobId}, nil
}
+87 -9
View File
@@ -1,6 +1,7 @@
package main
import (
"encoding/json"
"errors"
"log/slog"
"time"
@@ -9,9 +10,56 @@ import (
)
type Profile struct {
Joined time.Time `json:"joined"`
ShowsWatched int32 `json:"showsWatched"`
MoviesWatched int32 `json:"moviesWatched"`
Joined time.Time `json:"joined"`
ShowsWatched int32 `json:"showsWatched"`
MoviesWatched int32 `json:"moviesWatched"`
MoviesWatchedRuntime uint32 `json:"moviesWatchedRuntime"`
ShowsWatchedRuntime uint32 `json:"showsWatchedRuntime"`
}
// Check if content has been previsouly watched by looking for related activity.
func hasBeenPreviouslyWatched(a *[]Activity) bool {
wp := false
var relatedActivity []Activity
for _, v := range *a {
if v.Type == ADDED_WATCHED ||
v.Type == IMPORTED_ADDED_WATCHED ||
v.Type == IMPORTED_WATCHED ||
v.Type == STATUS_CHANGED {
relatedActivity = append(relatedActivity, v)
}
}
if len(relatedActivity) <= 0 {
return false
}
for _, ra := range relatedActivity {
if ra.Type == IMPORTED_ADDED_WATCHED {
wp = true
break
} else if ra.Type == ADDED_WATCHED || ra.Type == IMPORTED_WATCHED {
if ra.Data == "" {
continue
}
var v map[string]any
err := json.Unmarshal([]byte(ra.Data), &v)
if err != nil {
slog.Error("Checking ADDED_WATCHED or IMPORTED_WATCHED.. failed to parse json data", "error", err)
continue
}
if status, ok := v["status"]; ok {
if status == "FINISHED" {
wp = true
break
}
}
} else if ra.Type == STATUS_CHANGED {
if ra.Data == "FINISHED" {
wp = true
break
}
}
}
return wp
}
// Gets any data required for profile page
@@ -23,24 +71,54 @@ func getProfile(db *gorm.DB, userId uint) (Profile, error) {
return Profile{}, errors.New("failed to get profile")
}
watched := new([]Watched)
res = db.Model(&Watched{}).Preload("Content").Where("user_id = ?", userId).Find(&watched)
res = db.Model(&Watched{}).Preload("Content").Preload("Activity").Where("user_id = ?", userId).Find(&watched)
if res.Error != nil {
slog.Error("Profile: Failed to get watched for processing:", "error", res.Error.Error())
return Profile{}, errors.New("failed to get watched for processing")
}
var (
showsWatched int32
moviesWatched int32
showsWatched int32
moviesWatched int32
moviesWatchedRuntime uint32
showsWatchedRuntime uint32
)
for _, w := range *watched {
isFinished := false
if w.Status == FINISHED {
if w.Content.Type == SHOW {
isFinished = true
} else if *user.IncludePreviouslyWatched && hasBeenPreviouslyWatched(&w.Activity) {
// If status is not finished and user has IncludePreviouslyWatched enabled,
// then we can also check if content hasBeenPreviouslyWatched.
isFinished = true
}
if isFinished {
if w.Content == nil {
continue
}
c := *w.Content
if c.Type == SHOW {
showsWatched++
} else if w.Content.Type == MOVIE {
// This aint a science, just a very inaccurate guesstimate.
if c.NumberOfEpisodes != 0 {
var showRuntime uint32 = 30
if c.Runtime != 0 {
showRuntime = c.Runtime
}
showsWatchedRuntime += showRuntime * c.NumberOfEpisodes
slog.Debug("calcualted", "show", c.Title, "runti", showRuntime*c.NumberOfEpisodes)
}
} else if c.Type == MOVIE {
moviesWatched++
moviesWatchedRuntime += c.Runtime
}
}
}
profile := Profile{Joined: user.CreatedAt, ShowsWatched: showsWatched, MoviesWatched: moviesWatched}
profile := Profile{
Joined: user.CreatedAt,
ShowsWatched: showsWatched,
MoviesWatched: moviesWatched,
MoviesWatchedRuntime: moviesWatchedRuntime,
ShowsWatchedRuntime: showsWatchedRuntime,
}
return profile, nil
}
+659 -45
View File
@@ -9,6 +9,8 @@ import (
"github.com/gin-contrib/cache"
"github.com/gin-contrib/cache/persistence"
"github.com/gin-gonic/gin"
"github.com/sbondCo/Watcharr/arr"
"github.com/sbondCo/Watcharr/game"
"gorm.io/gorm"
)
@@ -16,6 +18,10 @@ type ErrorResponse struct {
Error string `json:"error"`
}
type ValueRequest struct {
Value any `json:"value"`
}
type KeyValueRequest struct {
Key string `json:"key"`
Value any `json:"value"`
@@ -24,12 +30,14 @@ type KeyValueRequest struct {
type BaseRouter struct {
db *gorm.DB
rg *gin.RouterGroup
ms *persistence.InMemoryStore
}
func newBaseRouter(db *gorm.DB, rg *gin.RouterGroup) *BaseRouter {
return &BaseRouter{
db: db,
rg: rg,
ms: persistence.NewInMemoryStore(time.Hour * 24),
}
}
@@ -69,10 +77,9 @@ func (b *BaseRouter) addSetupRoutes() {
func (b *BaseRouter) addContentRoutes() {
content := b.rg.Group("/content").Use(AuthRequired(nil))
exp := time.Hour * 24
store := persistence.NewInMemoryStore(exp)
// Search for content
content.GET("/:query", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/:query", cache.CachePage(b.ms, exp, func(c *gin.Context) {
// println(c.Param("query"))
if c.Param("query") == "" {
c.Status(400)
@@ -87,12 +94,12 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Get movie details (for movie page)
content.Use(WhereaboutsRequired()).GET("/movie/:id", cache.CachePage(store, exp, func(c *gin.Context) {
content.Use(WhereaboutsRequired()).GET("/movie/:id", cache.CachePage(b.ms, exp, func(c *gin.Context) {
if c.Param("id") == "" {
c.Status(400)
return
}
content, err := movieDetails(c.Param("id"), c.MustGet("userCountry").(string), map[string]string{"append_to_response": "videos,watch/providers"})
content, err := movieDetails(b.db, c.Param("id"), c.MustGet("userCountry").(string), map[string]string{"append_to_response": "videos,watch/providers,similar"})
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
@@ -101,7 +108,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Get movie cast
content.GET("/movie/:id/credits", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/movie/:id/credits", cache.CachePage(b.ms, exp, func(c *gin.Context) {
if c.Param("id") == "" {
c.Status(400)
return
@@ -115,12 +122,12 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Get tv details (for tv page)
content.Use(WhereaboutsRequired()).GET("/tv/:id", cache.CachePage(store, exp, func(c *gin.Context) {
content.Use(WhereaboutsRequired()).GET("/tv/:id", cache.CachePage(b.ms, exp, func(c *gin.Context) {
if c.Param("id") == "" {
c.Status(400)
return
}
content, err := tvDetails(c.Param("id"), c.MustGet("userCountry").(string), map[string]string{"append_to_response": "videos,watch/providers"})
content, err := tvDetails(b.db, c.Param("id"), c.MustGet("userCountry").(string), map[string]string{"append_to_response": "videos,watch/providers,similar,external_ids,keywords"})
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
@@ -129,7 +136,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Get tv cast
content.GET("/tv/:id/credits", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/tv/:id/credits", cache.CachePage(b.ms, exp, func(c *gin.Context) {
if c.Param("id") == "" {
c.Status(400)
return
@@ -143,7 +150,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Get season details
content.GET("/tv/:id/season/:num", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/tv/:id/season/:num", cache.CachePage(b.ms, exp, func(c *gin.Context) {
if c.Param("id") == "" || c.Param("num") == "" {
c.Status(400)
return
@@ -157,7 +164,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Get person details
content.GET("/person/:id", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/person/:id", cache.CachePage(b.ms, exp, func(c *gin.Context) {
if c.Param("id") == "" {
c.Status(400)
return
@@ -171,7 +178,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Get person credits
content.GET("/person/:id/credits", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/person/:id/credits", cache.CachePage(b.ms, exp, func(c *gin.Context) {
if c.Param("id") == "" {
c.Status(400)
return
@@ -185,7 +192,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Discover movies
content.GET("/discover/movies", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/discover/movies", cache.CachePage(b.ms, exp, func(c *gin.Context) {
content, err := discoverMovies()
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
@@ -195,7 +202,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Discover shows
content.GET("/discover/tv", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/discover/tv", cache.CachePage(b.ms, exp, func(c *gin.Context) {
content, err := discoverTv()
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
@@ -205,7 +212,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Get all trending (movies, tv, people)
content.GET("/trending", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/trending", cache.CachePage(b.ms, exp, func(c *gin.Context) {
content, err := allTrending()
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
@@ -215,7 +222,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Upcoming Movies
content.GET("/upcoming/movies", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/upcoming/movies", cache.CachePage(b.ms, exp, func(c *gin.Context) {
content, err := upcomingMovies()
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
@@ -225,7 +232,7 @@ func (b *BaseRouter) addContentRoutes() {
}))
// Upcoming Tv
content.GET("/upcoming/tv", cache.CachePage(store, exp, func(c *gin.Context) {
content.GET("/upcoming/tv", cache.CachePage(b.ms, exp, func(c *gin.Context) {
content, err := upcomingTv()
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
@@ -235,6 +242,90 @@ func (b *BaseRouter) addContentRoutes() {
}))
}
func (b *BaseRouter) addGameRoutes() {
gamer := b.rg.Group("/game").Use(AuthRequired(nil))
exp := time.Hour * 24
igdb := &Config.TWITCH
igdb.OnTokenRefreshed(func() {
// Save new token to config when we refresh it.
slog.Debug("GameRoutes: token refreshed.. saving to config.")
if err := writeConfig(); err != nil {
slog.Error("GameRoutes: failed to save refreshed token to config.", "error", err)
}
})
err := igdb.Init()
// Save cfg if init succeeded, this will save our access token
if err == nil {
slog.Error("GameRoutes: Twitch init failed!", "error", err)
}
// Search for games
gamer.GET("/search/:query", cache.CachePage(b.ms, exp, func(c *gin.Context) {
if c.Param("query") == "" {
c.Status(400)
return
}
games, err := igdb.Search(c.Param("query"))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, games)
}))
// Game details for game page
gamer.GET("/:id", cache.CachePage(b.ms, exp, func(c *gin.Context) {
if c.Param("id") == "" {
c.Status(400)
return
}
content, err := igdb.GameDetails(c.Param("id"))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, content)
}))
// Add game to played(watched) list
gamer.POST("/played", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
var ar PlayedAddRequest
err := c.ShouldBindJSON(&ar)
if err == nil {
response, err := addPlayed(b.db, igdb, userId, ar, ADDED_WATCHED)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
// IMPORTANT: Routes below only for admins!
gamer.Use(AuthRequired(b.db), AdminRequired())
{
gamer.POST("/config", func(c *gin.Context) {
var ar game.IGDB
err := c.ShouldBindJSON(&ar)
if err == nil {
err := saveTwitchConfig(ar)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
igdb = &Config.TWITCH
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
}
}
func (b *BaseRouter) addWatchedRoutes() {
watched := b.rg.Group("/watched").Use(AuthRequired(nil))
@@ -313,6 +404,68 @@ func (b *BaseRouter) addWatchedRoutes() {
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
watched.POST("/season", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
var ar WatchedSeasonAddRequest
err := c.ShouldBindJSON(&ar)
if err == nil {
response, err := addWatchedSeason(b.db, userId, ar)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
watched.DELETE("/season/:id", func(c *gin.Context) {
id, err := strconv.Atoi(c.Param("id"))
if err != nil {
c.Status(400)
return
}
userId := c.MustGet("userId").(uint)
response, err := rmWatchedSeason(b.db, userId, uint(id))
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
watched.POST("/episode", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
var ar WatchedEpisodeAddRequest
err := c.ShouldBindJSON(&ar)
if err == nil {
response, err := addWatchedEpisodes(b.db, userId, ar)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
watched.DELETE("/episode/:id", func(c *gin.Context) {
id, err := strconv.Atoi(c.Param("id"))
if err != nil {
c.Status(400)
return
}
userId := c.MustGet("userId").(uint)
response, err := rmWatchedEpisode(b.db, userId, uint(id))
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
}
func (b *BaseRouter) addActivityRoutes() {
@@ -348,6 +501,43 @@ func (b *BaseRouter) addActivityRoutes() {
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
activity.PUT(":id", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
id, err := strconv.ParseUint(c.Param("id"), 10, 32)
if err != nil {
c.Status(400)
return
}
var activityUpdateRequest ActivityUpdateRequest
err = c.ShouldBindJSON(&activityUpdateRequest)
if err == nil {
err = updateActivity(b.db, userId, uint(id), activityUpdateRequest)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
activity.DELETE(":id", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
id, err := strconv.ParseUint(c.Param("id"), 10, 32)
if err != nil {
c.Status(400)
slog.Error("Could not process activity id when attempting a deletion", "error", err.Error(), "id", c.Param("id"))
return
}
err = deleteActivity(b.db, userId, uint(id))
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
})
}
func (b *BaseRouter) addAuthRoutes() {
@@ -383,6 +573,21 @@ func (b *BaseRouter) addAuthRoutes() {
c.Status(400)
})
// Plex login
auth.POST("/plex", func(c *gin.Context) {
var plexRequest PlexLoginRequest
if c.ShouldBindJSON(&plexRequest) == nil {
response, err := loginPlex(&plexRequest, b.db)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
return
}
c.Status(400)
})
// Register
auth.POST("/register", func(c *gin.Context) {
var user UserRegisterRequest
@@ -404,6 +609,9 @@ func (b *BaseRouter) addAuthRoutes() {
if Config.JELLYFIN_HOST != "" {
availableAuthProviders = append(availableAuthProviders, "jellyfin")
}
if Config.PLEX_HOST != "" && Config.PLEX_MACHINE_ID != "" {
availableAuthProviders = append(availableAuthProviders, "plex")
}
c.JSON(http.StatusOK, &AvailableAuthProvidersResponse{
AvailableAuthProviders: availableAuthProviders,
SignupEnabled: Config.SIGNUP_ENABLED,
@@ -411,33 +619,54 @@ func (b *BaseRouter) addAuthRoutes() {
})
})
// Request admin token
auth.Use(AuthRequired(nil)).GET("/admin_token", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
token, err := createOneUseToken(b.db, TOKENTYPE_ADMIN, userId)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
slog.Info("Admin token generated. Type this token into the web ui to gain admin access on your account.", "token", token, "generated_for", userId)
c.Status(http.StatusNoContent)
})
// Use admin token
auth.Use(AuthRequired(nil)).POST("/admin_token", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
var atr UseAdminTokenRequest
if c.ShouldBindJSON(&atr) == nil {
err := useAdminToken(&atr, b.db, userId)
// IMPORTANT: Routes below here must be authenticated.
auth.Use(AuthRequired(nil))
{
// Request admin token
auth.GET("/admin_token", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
token, err := createOneUseToken(b.db, TOKENTYPE_ADMIN, userId)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
slog.Info("Admin token generated. Type this token into the web ui to gain admin access on your account.", "token", token, "generated_for", userId)
c.Status(http.StatusNoContent)
return
}
c.Status(400)
})
})
// Use admin token
auth.POST("/admin_token", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
var atr UseAdminTokenRequest
if c.ShouldBindJSON(&atr) == nil {
err := useAdminToken(&atr, b.db, userId)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusNoContent)
return
}
c.Status(400)
})
// Change password
auth.POST("/change_password", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
var pwds UserPasswordUpdateRequest
err := c.ShouldBindJSON(&pwds)
if err == nil {
err := userChangePassword(b.db, pwds, userId)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
}
}
func (b *BaseRouter) addProfileRoutes() {
@@ -456,7 +685,7 @@ func (b *BaseRouter) addProfileRoutes() {
}
func (b *BaseRouter) addJellyfinRoutes() {
jf := b.rg.Group("/jellyfin").Use(AuthRequired(b.db))
jf := b.rg.Group("/jellyfin").Use(AuthRequired(b.db), JellyfinAccessRequired())
// Check if jf has item
jf.GET("/:type/:name/:tmdbId", func(c *gin.Context) {
@@ -472,6 +701,37 @@ func (b *BaseRouter) addJellyfinRoutes() {
}
c.JSON(http.StatusOK, response)
})
// Sync users jellyfin watched items to watchlist
jf.GET("/sync", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
userType := c.MustGet("userType").(UserType)
username := c.MustGet("username").(string)
userThirdPartyId := c.MustGet("userThirdPartyId").(string)
userThirdPartyAuth := c.MustGet("userThirdPartyAuth").(string)
response, err := jellyfinSyncWatched(b.db, userId, userType, username, userThirdPartyId, userThirdPartyAuth)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
}
func (b *BaseRouter) addPlexRoutes() {
plex := b.rg.Group("/plex").Use(AuthRequired(b.db), PlexAccessRequired(b.db))
// Sync users plex watched items to watchlist
plex.GET("/sync", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
userPlexLocalAuth := c.MustGet("plexLocalAuthToken").(string)
response, err := plexSyncWatched(b.db, userId, userPlexLocalAuth)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
}
func (b *BaseRouter) addUserRoutes() {
@@ -526,6 +786,114 @@ func (b *BaseRouter) addUserRoutes() {
}
c.JSON(http.StatusOK, response)
})
// Search users
u.GET("/public/:pubUserId/:pubUsername", func(c *gin.Context) {
id, err := strconv.Atoi(c.Param("pubUserId"))
if err != nil {
c.Status(400)
return
}
response, err := getUserPublicInfo(b.db, uint(id), c.Param("pubUsername"))
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
// Update bio
u.POST("/bio", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
var br UserBioUpdateRequest
err := c.ShouldBindJSON(&br)
if err == nil {
err := userUpdateBio(b.db, userId, br.NewBio)
if err != nil {
c.JSON(http.StatusInternalServerError, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
// Upload avatar
u.POST("/avatar", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
response, err := uploadUserAvatar(c, b.db, userId)
if err != nil {
c.JSON(http.StatusInternalServerError, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
}
func (b *BaseRouter) addFollowRoutes() {
f := b.rg.Group("/follow").Use(AuthRequired(b.db))
// Get users follows // TODO extend to support optionally passing user id as route param, default to current user
f.GET("", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
response, err := getFollows(b.db, userId)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
// Follow a user
f.POST("/:toFollowId", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
toFollowId, err := strconv.ParseUint(c.Param("toFollowId"), 10, 64)
if err != nil {
slog.Error("failed to convert toFollowId param to uint", "toFollowId", toFollowId)
c.Status(400)
return
}
response, err := followUser(b.db, userId, uint(toFollowId))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
// Unfollow a user
f.DELETE("/:toUnfollowId", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
toUnfollowId, err := strconv.ParseUint(c.Param("toUnfollowId"), 10, 64)
if err != nil {
slog.Error("failed to convert toUnfollowId param to uint", "toUnfollowId", toUnfollowId)
c.Status(400)
return
}
response, err := unfollowUser(b.db, userId, uint(toUnfollowId))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
// Get follows thoughts on content
f.GET("/thoughts/:type/:tmdbId", func(c *gin.Context) {
t := c.Param("type")
if t != "movie" && t != "tv" && t != "game" {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: "only movie, tv or game types are supported"})
return
}
userId := c.MustGet("userId").(uint)
response, err := getFollowsThoughts(b.db, userId, t, c.Param("tmdbId"))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, response)
})
}
func (b *BaseRouter) addImportRoutes() {
@@ -554,12 +922,7 @@ func (b *BaseRouter) addServerRoutes() {
// Get server config (minus very sensitive fields, like JWT_SECRET)
server.GET("/config", func(c *gin.Context) {
// Return new ServerConfig with only the fields we want to show in settings ui
c.JSON(http.StatusOK, ServerConfig{
SIGNUP_ENABLED: Config.SIGNUP_ENABLED,
JELLYFIN_HOST: Config.JELLYFIN_HOST,
TMDB_KEY: Config.TMDB_KEY,
DEBUG: Config.DEBUG,
})
c.JSON(http.StatusOK, Config.GetSafe())
})
// Update config
@@ -577,4 +940,255 @@ func (b *BaseRouter) addServerRoutes() {
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
// Update plex host config
server.POST("/config/plex_host", func(c *gin.Context) {
var ur ValueRequest
err := c.ShouldBindJSON(&ur)
if err == nil {
resp, err := updateConfigPlexHost(ur.Value.(string))
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, resp)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
// Get server stats
server.GET("/stats", cache.CachePage(b.ms, time.Minute*5, func(c *gin.Context) {
c.JSON(http.StatusOK, getServerStats(b.db))
}))
}
func (b *BaseRouter) addFeatureRoutes() {
feature := b.rg.Group("/features").Use(AuthRequired(b.db))
// Get enabled features (aka functionality)
feature.GET("", func(c *gin.Context) {
c.JSON(http.StatusOK, getEnabledFeatures(c.GetInt("userPermissions")))
})
}
func (b *BaseRouter) addSonarrRoutes() {
s := b.rg.Group("/arr/son").Use(AuthRequired(b.db), AdminRequired())
// Test configuration
s.POST("/test", func(c *gin.Context) {
var ur ArrTestParams
err := c.ShouldBindJSON(&ur)
if err == nil {
resp, err := testSonarr(ur)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, resp)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
// Used to get config for specific server (quality profile, root folder, etc)
s.GET("/config/:name", func(c *gin.Context) {
server, err := getSonarr(c.Param("name"))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
resp, err := testSonarr(ArrTestParams{Host: server.Host, Key: server.Key})
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, resp)
})
// Add sonarr server into config
s.POST("/add", func(c *gin.Context) {
var ur SonarrSettings
err := c.ShouldBindJSON(&ur)
if err == nil {
err := addSonarr(ur)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
// Edit sonarr servers config
s.POST("/edit", func(c *gin.Context) {
var ur SonarrSettings
err := c.ShouldBindJSON(&ur)
if err == nil {
err := editSonarr(ur)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
// Remove sonarr server
s.POST("/rm/:name", func(c *gin.Context) {
err := rmSonarr(c.Param("name"))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
})
// Get safe config for all sonarr servers
s.GET("", func(c *gin.Context) {
response := getSonarrsSafe()
c.JSON(http.StatusOK, response)
})
// Request a show
s.POST("/request", func(c *gin.Context) {
var ur arr.SonarrRequest
err := c.ShouldBindJSON(&ur)
if err == nil {
server, err := getSonarr(ur.ServerName)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
ur.AutomaticSearch = server.AutomaticSearch
sonarr := arr.New(arr.SONARR, &server.Host, &server.Key)
err = sonarr.AddContent(sonarr.BuildAddShowBody(ur))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
}
func (b *BaseRouter) addRadarrRoutes() {
s := b.rg.Group("/arr/rad").Use(AuthRequired(b.db), AdminRequired())
// Test configuration
s.POST("/test", func(c *gin.Context) {
var ur ArrTestParams
err := c.ShouldBindJSON(&ur)
if err == nil {
resp, err := testRadarr(ur)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, resp)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
// Get config for specific server
s.GET("/config/:name", func(c *gin.Context) {
server, err := getRadarr(c.Param("name"))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
resp, err := testRadarr(ArrTestParams{Host: server.Host, Key: server.Key})
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, resp)
})
s.POST("/add", func(c *gin.Context) {
var ur RadarrSettings
err := c.ShouldBindJSON(&ur)
if err == nil {
err := addRadarr(ur)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
s.POST("/edit", func(c *gin.Context) {
var ur RadarrSettings
err := c.ShouldBindJSON(&ur)
if err == nil {
err := editRadarr(ur)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
s.POST("/rm/:name", func(c *gin.Context) {
err := rmRadarr(c.Param("name"))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
})
s.GET("", func(c *gin.Context) {
response := getRadarrsSafe()
c.JSON(http.StatusOK, response)
})
s.POST("/request", func(c *gin.Context) {
var ur arr.RadarrRequest
err := c.ShouldBindJSON(&ur)
if err == nil {
server, err := getRadarr(ur.ServerName)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
ur.AutomaticSearch = server.AutomaticSearch
radarr := arr.New(arr.RADARR, &server.Host, &server.Key)
err = radarr.AddContent(radarr.BuildAddMovieBody(ur))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
return
}
c.Status(http.StatusOK)
return
}
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
})
}
func (b *BaseRouter) addJobRoutes() {
job := b.rg.Group("/job").Use(AuthRequired(nil))
job.GET("/:id", func(c *gin.Context) {
userId := c.MustGet("userId").(uint)
response, err := getJob(c.Param("id"), userId)
if err != nil {
c.JSON(http.StatusForbidden, ErrorResponse{Error: err.Error()})
return
}
c.JSON(http.StatusOK, *response)
})
}
+15
View File
@@ -8,6 +8,11 @@ import (
// Setup recurring tasks (eg cleanup every x mins)
func setupTasks(db *gorm.DB) {
go setupMinutelyTasks(db)
go setupDailyTasks(db)
}
func setupMinutelyTasks(db *gorm.DB) {
taskRunInterval := 1 * time.Minute
ticker := time.NewTicker(taskRunInterval)
defer ticker.Stop()
@@ -18,3 +23,13 @@ func setupTasks(db *gorm.DB) {
cleanupTokens(db)
}
}
func setupDailyTasks(db *gorm.DB) {
taskRunInterval := 24 * time.Hour
ticker := time.NewTicker(taskRunInterval)
defer ticker.Stop()
for range ticker.C {
cleanupImages(db)
}
}
+82 -4
View File
@@ -87,8 +87,10 @@ type TMDBMovieDetails struct {
Video bool `json:"video"`
// Extra items because we use `append_to_response` on the request
Videos TMDBContentVideos `json:"videos"`
WatchProviders interface{} `json:"watch/providers"`
Videos TMDBContentVideos `json:"videos"`
WatchProviders interface{} `json:"watch/providers"`
Similar TMDBMovieSimilar `json:"similar"`
ExternalIds TMDBExternalIdsMovie `json:"external_ids"`
}
type TMDBShowDetails struct {
@@ -141,8 +143,11 @@ type TMDBShowDetails struct {
Type string `json:"type"`
// Extra items because we use `append_to_response` on the request
Videos TMDBContentVideos `json:"videos"`
WatchProviders interface{} `json:"watch/providers"`
Videos TMDBContentVideos `json:"videos"`
WatchProviders interface{} `json:"watch/providers"`
Similar TMDBShowSimilar `json:"similar"`
ExternalIds TMDBExternalIdsShow `json:"external_ids"`
Keywords TMDBKeywords `json:"keywords"`
}
type WatchProvider struct {
@@ -217,6 +222,50 @@ type TMDBSeasonDetails struct {
SeasonNumber int `json:"season_number"`
}
type TMDBShowSimilar struct {
Page int `json:"page"`
Results []struct {
Adult bool `json:"adult"`
BackdropPath string `json:"backdrop_path"`
GenreIds []int `json:"genre_ids"`
ID int `json:"id"`
OriginCountry []string `json:"origin_country"`
OriginalLanguage string `json:"original_language"`
OriginalName string `json:"original_name"`
Overview string `json:"overview"`
Popularity float64 `json:"popularity"`
PosterPath string `json:"poster_path"`
FirstAirDate string `json:"first_air_date"`
Name string `json:"name"`
VoteAverage float64 `json:"vote_average"`
VoteCount uint32 `json:"vote_count"`
} `json:"results"`
TotalPages int `json:"total_pages"`
TotalResults int `json:"total_results"`
}
type TMDBMovieSimilar struct {
Page int `json:"page"`
Results []struct {
Adult bool `json:"adult"`
BackdropPath string `json:"backdrop_path"`
GenreIds []int `json:"genre_ids"`
ID int `json:"id"`
OriginalLanguage string `json:"original_language"`
OriginalTitle string `json:"original_title"`
Overview string `json:"overview"`
Popularity float64 `json:"popularity"`
PosterPath string `json:"poster_path"`
ReleaseDate string `json:"release_date"`
Title string `json:"title"`
Video bool `json:"video"`
VoteAverage float64 `json:"vote_average"`
VoteCount uint32 `json:"vote_count"`
} `json:"results"`
TotalPages int `json:"total_pages"`
TotalResults int `json:"total_results"`
}
type TMDBPersonDetails struct {
Birthday string `json:"birthday"`
KnownForDepartment string `json:"known_for_department"`
@@ -413,6 +462,35 @@ type TMDBUpcomingShows struct {
TotalResults int `json:"total_results"`
}
type TMDBExternalIds struct {
ID int `json:"id"`
ImdbID string `json:"imdb_id"`
WikidataID string `json:"wikidata_id"`
FacebookID string `json:"facebook_id"`
InstagramID string `json:"instagram_id"`
TwitterID string `json:"twitter_id"`
}
type TMDBExternalIdsMovie struct {
TMDBExternalIds
}
type TMDBExternalIdsShow struct {
TMDBExternalIds
FreebaseMid string `json:"freebase_mid"`
FreebaseID string `json:"freebase_id"`
TvdbID int `json:"tvdb_id"`
TvrageID int `json:"tvrage_id"`
}
type TMDBKeywords struct {
// ID int `json:"id"`
Results []struct {
Name string `json:"name"`
ID int `json:"id"`
} `json:"results"`
}
func getTMDBKey() string {
if Config.TMDB_KEY != "" {
return Config.TMDB_KEY
+122 -11
View File
@@ -1,9 +1,16 @@
package main
import (
"crypto/sha256"
"encoding/hex"
"errors"
"io"
"log"
"log/slog"
"path"
"path/filepath"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
@@ -11,6 +18,9 @@ import (
type PublicUser struct {
ID uint `json:"id"`
Username string `json:"username"`
AvatarID uint `json:"-"`
Avatar Image `json:"avatar"`
Bio string `json:"bio,omitempty"`
}
// Private user details, for returning users details to themselves
@@ -18,23 +28,43 @@ type PrivateUser struct {
Username string `json:"username"`
Type UserType `json:"type"`
Permissions int `json:"permissions"`
AvatarID uint `json:"-"`
Avatar Image `json:"avatar"`
Bio string `json:"bio"`
}
// This really only works if all settings are repassed in, otherwise they
// will be reset to their default value.
// When more settings are added in, this should be updated to work so you
// only have to pass in the setting you want to update.
type UserBioUpdateRequest struct {
NewBio string `json:"newBio" binding:"max=128"`
}
// Update user settings
func userUpdate(db *gorm.DB, userId uint, ur UserSettings) (UserSettings, error) {
slog.Debug("user update request running", "user_id", userId, "ur", ur)
user := new(User)
res := db.Where("id = ?", userId).Take(&user)
if res.Error != nil {
slog.Error("user update failed", "user_id", userId, "error", "failed to retrieve user from database")
slog.Error("user update failed", "user_id", userId, "error", res.Error)
return UserSettings{}, errors.New("failed to retrieve user")
}
user.Private = ur.Private
if ur.HideSpoilers != nil {
user.HideSpoilers = ur.HideSpoilers
}
if ur.Private != nil {
user.Private = ur.Private
}
if ur.PrivateThoughts != nil {
user.PrivateThoughts = ur.PrivateThoughts
}
if ur.IncludePreviouslyWatched != nil {
user.IncludePreviouslyWatched = ur.IncludePreviouslyWatched
}
db.Save(&user)
return UserSettings{Private: user.Private}, nil
return UserSettings{
Private: user.Private,
PrivateThoughts: user.PrivateThoughts,
HideSpoilers: user.HideSpoilers,
IncludePreviouslyWatched: user.IncludePreviouslyWatched,
}, nil
}
func userGetSettings(db *gorm.DB, userId uint) (UserSettings, error) {
@@ -42,10 +72,15 @@ func userGetSettings(db *gorm.DB, userId uint) (UserSettings, error) {
user := new(User)
res := db.Where("id = ?", userId).Take(&user)
if res.Error != nil {
slog.Error("user get failed", "user_id", userId, "error", "failed to retrieve user from database")
slog.Error("user get failed", "user_id", userId, "error", res.Error)
return UserSettings{}, errors.New("failed to retrieve user")
}
return UserSettings{Private: user.Private}, nil
return UserSettings{
Private: user.Private,
PrivateThoughts: user.PrivateThoughts,
HideSpoilers: user.HideSpoilers,
IncludePreviouslyWatched: user.IncludePreviouslyWatched,
}, nil
}
func userSearch(db *gorm.DB, currentUsersId uint, q string) ([]PublicUser, error) {
@@ -53,7 +88,7 @@ func userSearch(db *gorm.DB, currentUsersId uint, q string) ([]PublicUser, error
users := new([]PublicUser)
res := db.Where("private = 0 AND username LIKE ? AND id != ?", "%"+q+"%", currentUsersId).Table("users").Find(&users)
if res.Error != nil {
slog.Error("user search failed", "error", "failed to query database")
slog.Error("user search failed", "error", res.Error)
return []PublicUser{}, errors.New("failed to find users")
}
return *users, nil
@@ -62,10 +97,86 @@ func userSearch(db *gorm.DB, currentUsersId uint, q string) ([]PublicUser, error
func getUserInfo(db *gorm.DB, currentUsersId uint) (PrivateUser, error) {
slog.Debug("user get info request running")
user := new(PrivateUser)
res := db.Where("id = ?", currentUsersId).Table("users").Take(&user)
res := db.Where("id = ?", currentUsersId).Table("users").Preload("Avatar").Take(&user)
if res.Error != nil {
slog.Error("user get info failed", "error", res.Error)
return PrivateUser{}, errors.New("failed to find current user")
}
return *user, nil
}
// For getting a public user's info, when viewing their list for example
func getUserPublicInfo(db *gorm.DB, userId uint, username string) (PublicUser, error) {
slog.Debug("user get info request running")
user := new(PublicUser)
res := db.Where("private = 0 AND id = ? AND username = ?", userId, username).Table("users").Preload("Avatar").Take(&user)
if res.Error != nil {
slog.Error("public user get info failed", "error", res.Error)
return PublicUser{}, errors.New("failed to find user")
}
return *user, nil
}
func userUpdateBio(db *gorm.DB, userId uint, newBio string) error {
slog.Debug("userUpdateBio request running", "user_id", userId, "newBio", newBio)
if res := db.Model(&User{}).Where("id = ?", userId).Update("bio", newBio); res.Error != nil {
slog.Error("userUpdateBio failed", "user_id", userId, "error", res.Error)
return errors.New("failed to update bio")
}
return nil
}
func uploadUserAvatar(c *gin.Context, db *gorm.DB, userId uint) (Image, error) {
file, err := c.FormFile("avatar")
if err != nil {
slog.Error("failed to get file", "error", err)
return Image{}, errors.New("no file found")
}
slog.Debug("an avatar is being uploaded", "name", file.Filename)
f, _ := file.Open()
if err := isValidImageType(f); err != nil {
return Image{}, errors.New("invalid image type")
}
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
log.Fatal(err) // TODO nu le fatal
}
hs := hex.EncodeToString(h.Sum(nil))
slog.Debug("image hash calculated", "hash", hs, "first_letter", hs[0:1])
// Upload the file to specific dst.
outp := path.Join("img/up/", hs[0:1], hs+filepath.Ext(file.Filename))
c.SaveUploadedFile(file, path.Join(DataPath, outp))
_, err = f.Seek(0, 0)
if err != nil {
slog.Error("uploadUserAvatar seeking back to start of image failed", "error", err)
}
// No need to remove old image, the daily cleanup task will handle removing unused ones.
var img Image
err = db.Transaction(func(tx *gorm.DB) error {
// Insert avatar into db
img, err = insertImage(db, hs, outp, f)
if err != nil {
return err
}
if img.ID == 0 {
return errors.New("image has no id")
}
// Update users avatar to newly inserted
if err := tx.Where("id = ?", userId).Updates(&User{AvatarID: img.ID}).Error; err != nil {
return err
}
// commit transaction if no errors
return nil
})
if err != nil {
slog.Error("uploadUserAvatar failed!", "error", err)
return Image{}, errors.New("uploadUserAvatar transaction failed")
}
return img, nil
}
+23 -3
View File
@@ -10,6 +10,7 @@ import (
"net/http/httputil"
"os"
"os/exec"
"path"
"time"
"github.com/gin-contrib/cors"
@@ -63,12 +64,24 @@ func main() {
isProd = false
}
db, err := gorm.Open(sqlite.Open("./data/watcharr.db"), &gorm.Config{})
db, err := gorm.Open(sqlite.Open("./data/watcharr.db"), &gorm.Config{TranslateError: true})
if err != nil {
log.Fatal("Failed to connect to database:", err)
}
err = db.AutoMigrate(&User{}, &Content{}, &Watched{}, &Activity{}, &Token{})
err = db.AutoMigrate(
&User{},
&UserServices{},
&Content{},
&Watched{},
&WatchedSeason{},
&WatchedEpisode{},
&Activity{},
&Token{},
&Follow{},
&Image{},
&Game{},
)
if err != nil {
log.Fatal("Failed to auto migrate database:", err)
}
@@ -114,14 +127,21 @@ func main() {
}
br.addAuthRoutes()
br.addContentRoutes()
br.addGameRoutes()
br.addWatchedRoutes()
br.addActivityRoutes()
br.addProfileRoutes()
br.addJellyfinRoutes()
br.addPlexRoutes()
br.addUserRoutes()
br.addFollowRoutes()
br.addImportRoutes()
br.addServerRoutes()
br.rg.Static("/img", "./data/img")
br.addFeatureRoutes()
br.addSonarrRoutes()
br.addRadarrRoutes()
br.addJobRoutes()
br.rg.Static("/img", path.Join(DataPath, "img"))
go setupTasks(db)
+52 -110
View File
@@ -10,7 +10,6 @@ import (
"os"
"path"
"strconv"
"strings"
"time"
"gorm.io/gorm"
@@ -28,20 +27,28 @@ const (
type Watched struct {
GormModel
Status WatchedStatus `json:"status"`
Rating int8 `json:"rating"`
Thoughts string `json:"thoughts"`
UserID uint `json:"-" gorm:"uniqueIndex:usernctnidx"`
ContentID int `json:"-" gorm:"uniqueIndex:usernctnidx"`
Content Content `json:"content"`
Activity []Activity `json:"activity"`
Status WatchedStatus `json:"status"`
Rating int8 `json:"rating"`
Thoughts string `json:"thoughts"`
UserID uint `json:"-" gorm:"uniqueIndex:usernctnidx;uniqueIndex:userngamidx"`
ContentID *int `json:"-" gorm:"uniqueIndex:usernctnidx"`
Content *Content `json:"content,omitempty"`
GameID *int `json:"-" gorm:"uniqueIndex:userngamidx"`
Game *Game `json:"game,omitempty"`
Activity []Activity `json:"activity"`
WatchedSeasons []WatchedSeason `json:"watchedSeasons,omitempty"` // For shows
WatchedEpisodes []WatchedEpisode `json:"watchedEpisodes,omitempty"` // For shows
}
type WatchedAddRequest struct {
Status WatchedStatus `json:"status"`
Rating int8 `json:"rating" binding:"max=10"`
Thoughts string `json:"thoughts"`
ContentID int `json:"contentId" binding:"required"`
ContentType ContentType `json:"contentType" binding:"required,oneof=movie tv"`
// Pass a watched date and we will set the CreatedAt (and initial UpdatedAt)
// properties for this watched entry to this specific date.
WatchedDate time.Time `json:"watchedDate,omitempty"`
}
type WatchedUpdateRequest struct {
@@ -61,7 +68,7 @@ type WatchedRemoveResponse struct {
func getWatched(db *gorm.DB, userId uint) []Watched {
watched := new([]Watched)
res := db.Model(&Watched{}).Preload("Content").Preload("Activity").Where("user_id = ?", userId).Find(&watched)
res := db.Model(&Watched{}).Preload("Content").Preload("Game").Preload("Game.Poster").Preload("Activity").Preload("WatchedSeasons").Preload("WatchedEpisodes").Where("user_id = ?", userId).Find(&watched)
if res.Error != nil {
panic(res.Error)
}
@@ -81,13 +88,13 @@ func getPublicWatched(db *gorm.DB, userId uint, username string) ([]Watched, err
slog.Error("Failed to get user for getPublicWatched request")
return []Watched{}, errors.New("failed to check privacy settings")
}
if user.Private {
if user.Private != nil && *user.Private {
slog.Error("getPublicWatched attempted to get a private list")
return []Watched{}, errors.New("this watched list is private")
}
// Now we know the user is public, return their list
watched := new([]Watched)
res = db.Model(&Watched{}).Preload("Content").Where("user_id = ?", userId).Find(&watched)
res = db.Model(&Watched{}).Preload("Content").Preload("Game").Preload("Game.Poster").Where("user_id = ?", userId).Find(&watched)
if res.Error != nil {
panic(res.Error)
}
@@ -98,7 +105,7 @@ func addWatched(db *gorm.DB, userId uint, ar WatchedAddRequest, at ActivityType)
slog.Debug("Adding watched item", "userId", userId, "contentType", ar.ContentType, "contentId", ar.ContentID)
var content Content
db.Where("tmdb_id = ?", ar.ContentID).Find(&content)
db.Where("type = ? AND tmdb_id = ?", ar.ContentType, ar.ContentID).Find(&content)
// Create content if not found from our db
if content == (Content{}) {
@@ -110,110 +117,29 @@ func addWatched(db *gorm.DB, userId uint, ar WatchedAddRequest, at ActivityType)
return Watched{}, errors.New("failed to find requested media")
}
var (
id int
title string
overview string
posterPath string
releaseDate time.Time
popularity float32
voteAverage float32
voteCount uint32
imdbID string
status string
budget uint32
revenue uint32
runtime uint32
numberOfEpisodes uint32
numberOfSeasons uint32
)
var dateFormat = "2006-01-02"
// Get details from movie/show response and fill out needed vars
if ar.ContentType == "movie" {
content := new(TMDBMovieDetails)
err = json.Unmarshal([]byte(resp), &content)
c := new(TMDBMovieDetails)
err := json.Unmarshal([]byte(resp), &c)
if err != nil {
slog.Error("Failed to unmarshal movie details", "error", err)
return Watched{}, errors.New("failed to process movie details response")
}
id = content.ID
overview = content.Overview
posterPath = content.PosterPath
title = content.Title
releaseDate, err = time.Parse(dateFormat, content.ReleaseDate)
content, err = cacheContentMovie(db, *c, false)
if err != nil {
slog.Error("Failed to parse movie release date", "error", err)
slog.Error("addWatched failed to cache movie content", "content_id", ar.ContentID, "err", err)
return Watched{}, errors.New("failed to cache content")
}
popularity = content.Popularity
voteAverage = content.VoteAverage
voteCount = content.VoteCount
imdbID = content.ImdbID
status = content.Status
budget = content.Budget
revenue = content.Revenue
runtime = content.Runtime
} else {
content := new(TMDBShowDetails)
err = json.Unmarshal(resp, &content)
c := new(TMDBShowDetails)
err := json.Unmarshal(resp, &c)
if err != nil {
slog.Error("Failed to unmarshal show details", "error", err)
return Watched{}, errors.New("failed to process show details response")
slog.Error("Failed to unmarshal tv details", "error", err)
return Watched{}, errors.New("failed to process tv details response")
}
id = content.ID
overview = content.Overview
posterPath = content.PosterPath
title = content.Name
releaseDate, err = time.Parse(dateFormat, content.FirstAirDate)
content, err = cacheContentTv(db, *c, false)
if err != nil {
slog.Error("Failed to parse tv release date", "error", err)
}
popularity = content.Popularity
voteAverage = content.VoteAverage
voteCount = content.VoteCount
status = content.Status
if len(content.EpisodeRunTime) > 0 {
runtime = uint32(content.EpisodeRunTime[0])
}
numberOfEpisodes = content.NumberOfEpisodes
numberOfSeasons = content.NumberOfSeasons
}
// Save the content in our db
slog.Info("Saving content to db", "id", id, "title", title)
if id == 0 || title == "" {
slog.Error("addWatched, returned content missing id or title!", "id", id, "title", title)
return Watched{}, errors.New("content response missing id or title")
}
content = Content{
TmdbID: id,
Title: title,
Overview: overview,
PosterPath: posterPath,
Type: ar.ContentType,
ReleaseDate: &releaseDate,
Popularity: popularity,
VoteAverage: voteAverage,
VoteCount: voteCount,
ImdbID: imdbID,
Status: status,
Budget: budget,
Revenue: revenue,
Runtime: runtime,
NumberOfEpisodes: numberOfEpisodes,
NumberOfSeasons: numberOfSeasons,
}
res := db.Create(&content)
if res.Error != nil {
// Error if anything but unique contraint error
if !strings.Contains(res.Error.Error(), "UNIQUE") {
slog.Error("Error creating content in database", "error", res.Error.Error())
return Watched{}, errors.New("failed to cache content in database")
}
}
// If row created, download the image
if res.RowsAffected > 0 {
err := download("https://image.tmdb.org/t/p/w500"+posterPath, path.Join("./data/img", posterPath))
if err != nil {
slog.Error("Failed to download content image!", "error", err.Error())
slog.Error("addWatched failed to cache tv content", "content_id", ar.ContentID, "err", err)
return Watched{}, errors.New("failed to cache content")
}
}
}
@@ -223,23 +149,39 @@ func addWatched(db *gorm.DB, userId uint, ar WatchedAddRequest, at ActivityType)
}
// Create watched entry in db
if ar.Status == "" {
ar.Status = WATCHING
// Set default status for when content is added by
// rating it instead of giving status first.
if ar.ContentType == "movie" {
ar.Status = FINISHED
} else {
ar.Status = WATCHING
}
}
watched := Watched{Status: ar.Status, Rating: ar.Rating, UserID: userId, ContentID: &content.ID}
if ar.Thoughts != "" {
watched.Thoughts = ar.Thoughts
}
// If custom WatchedDate passed, set CreatedAt and UpdatedAt fields to it.
if !ar.WatchedDate.IsZero() {
slog.Debug("Adding watched item: The provided WatchedDate is valid.", "watched_date", ar.WatchedDate, "userId", userId, "contentType", ar.ContentType, "contentId", ar.ContentID)
watched.CreatedAt = ar.WatchedDate
watched.UpdatedAt = ar.WatchedDate
}
watched := Watched{Status: ar.Status, Rating: ar.Rating, UserID: userId, ContentID: content.ID}
res := db.Create(&watched)
if res.Error != nil {
if strings.Contains(res.Error.Error(), "UNIQUE") {
if res.Error == gorm.ErrDuplicatedKey {
res = db.Model(&Watched{}).Unscoped().Preload("Activity").Where("user_id = ? AND content_id = ?", userId, watched.ContentID).Take(&watched)
if res.Error != nil {
return Watched{}, errors.New("content already on watched list. errored checking for soft deleted record")
}
if watched.DeletedAt.Time.IsZero() {
return Watched{}, errors.New("content already on watched list")
return watched, errors.New("content already on watched list")
} else {
slog.Info("addWatched: Watched list item for this content exists as soft deleted record.. attempting to restore")
res = db.Model(&Watched{}).Unscoped().Where("user_id = ? AND content_id = ?", userId, watched.ContentID).Updates(map[string]interface{}{"status": ar.Status, "rating": ar.Rating, "deleted_at": nil})
watched.Status = ar.Status
watched.Rating = ar.Rating
watched.Thoughts = ar.Thoughts
if res.Error != nil {
slog.Error("addWatched: Failed to restore soft deleted watch list item", "error", res.Error)
return Watched{}, errors.New("content already on watched list. errored removing soft delete timestamp")
@@ -261,7 +203,7 @@ func addWatched(db *gorm.DB, userId uint, ar WatchedAddRequest, at ActivityType)
activity, _ = addActivity(db, userId, ActivityAddRequest{WatchedID: watched.ID, Type: at, Data: string(activityJson)})
}
watched.Activity = append(watched.Activity, activity)
watched.Content = content
watched.Content = &content
return watched, nil
}
+149
View File
@@ -0,0 +1,149 @@
package main
import (
"encoding/json"
"errors"
"log/slog"
"time"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
// UniqueIndex applied between WatchedID, SeasonNum and EpisodeNum to avoid duplicates incase logic fails.
//
// Episodes on tmdb are only queried by season number + episode number, not possible via episode id,
// since episodes can be removed and re-added. For this reason we store season and episodes nums instead
// of just the episode id.
type WatchedEpisode struct {
GormModel
UserID uint `json:"-" gorm:"not null"`
User User `json:"-"`
WatchedID uint `json:"-" gorm:"uniqueIndex:we_watched_to_ens;not null"`
SeasonNumber int `json:"seasonNumber" gorm:"uniqueIndex:we_watched_to_ens;not null"`
EpisodeNumber int `json:"episodeNumber" gorm:"uniqueIndex:we_watched_to_ens;not null"`
Status WatchedStatus `json:"status"`
Rating int8 `json:"rating"`
}
type WatchedEpisodeAddRequest struct {
WatchedID uint `json:"watchedId"`
SeasonNumber int `json:"seasonNumber"`
EpisodeNumber int `json:"episodeNumber"`
Status WatchedStatus `json:"status"`
Rating int8 `json:"rating"`
addActivity ActivityType `json:"-"`
addActivityDate time.Time `json:"-"`
}
type WatchedEpisodeAddResponse struct {
WatchedEpisodes []WatchedEpisode `json:"watchedEpisodes"`
AddedActivity Activity `json:"addedActivity"`
}
// Add/edit a watched episode.
func addWatchedEpisodes(db *gorm.DB, userId uint, ar WatchedEpisodeAddRequest) (WatchedEpisodeAddResponse, error) {
slog.Debug("Adding watched episode item", "userId", userId, "watchedID", ar.WatchedID, "season", ar.SeasonNumber, "episode", ar.EpisodeNumber)
// 1. Make sure watched item exists and it is the correct type (TV)
var w Watched
if resp := db.Where("id = ? AND user_id = ?", ar.WatchedID, userId).Preload("Content").Preload("WatchedEpisodes").Find(&w); resp.Error != nil {
slog.Error("Failed when adding a watched episode", "error", "failed to get watched item from db")
return WatchedEpisodeAddResponse{}, errors.New("failed when retrieving watched item")
}
if w.ID == 0 {
slog.Error("Failed when adding a watched episode", "error", "watched item does not exist in db")
return WatchedEpisodeAddResponse{}, errors.New("can't add a watched episode for a show that doesnt have a status itself")
}
if w.Content.Type != SHOW {
return WatchedEpisodeAddResponse{}, errors.New("can't add watched episode for non show content")
}
found := false
updated := false
for i, we := range w.WatchedEpisodes {
if we.SeasonNumber == ar.SeasonNumber && we.EpisodeNumber == ar.EpisodeNumber {
slog.Debug("Existing watched episode item found, updating existing")
found = true
if ar.Status != "" && ar.Status != w.WatchedEpisodes[i].Status {
w.WatchedEpisodes[i].Status = ar.Status
updated = true
}
if ar.Rating != 0 && ar.Rating != w.WatchedEpisodes[i].Rating {
w.WatchedEpisodes[i].Rating = ar.Rating
updated = true
}
break
}
}
var addedActivity Activity
if !found {
slog.Debug("Existing watched episode not found, adding as new entry")
w.WatchedEpisodes = append(w.WatchedEpisodes, WatchedEpisode{
UserID: userId,
WatchedID: ar.WatchedID,
SeasonNumber: ar.SeasonNumber,
EpisodeNumber: ar.EpisodeNumber,
Status: ar.Status,
Rating: ar.Rating,
})
}
if resp := db.Save(&w.WatchedEpisodes); resp.Error != nil {
slog.Debug("Failed to save watched episode item in db", "error", resp.Error)
return WatchedEpisodeAddResponse{}, errors.New("failed to save")
}
// Add activity
if found {
// Only add change activity if we actually updated a value
// (changing value to same value doesn't count).
if updated {
if ar.Status != "" {
json, _ := json.Marshal(map[string]interface{}{"season": ar.SeasonNumber, "episode": ar.EpisodeNumber, "status": ar.Status})
addedActivity, _ = addActivity(db, userId, ActivityAddRequest{WatchedID: w.ID, Type: EPISODE_STATUS_CHANGED, Data: string(json)})
}
if ar.Rating != 0 {
json, _ := json.Marshal(map[string]interface{}{"season": ar.SeasonNumber, "episode": ar.EpisodeNumber, "rating": ar.Rating})
addedActivity, _ = addActivity(db, userId, ActivityAddRequest{WatchedID: w.ID, Type: EPISODE_RATING_CHANGED, Data: string(json)})
}
}
} else {
json, _ := json.Marshal(map[string]interface{}{"season": ar.SeasonNumber, "episode": ar.EpisodeNumber, "status": ar.Status, "rating": ar.Rating})
act := ActivityAddRequest{WatchedID: w.ID, Type: EPISODE_ADDED, Data: string(json)}
if ar.addActivity != "" {
act.Type = ar.addActivity
}
if !ar.addActivityDate.IsZero() {
act.CustomDate = &ar.addActivityDate
}
addedActivity, _ = addActivity(db, userId, act)
}
return WatchedEpisodeAddResponse{
WatchedEpisodes: w.WatchedEpisodes,
AddedActivity: addedActivity,
}, nil
}
// Remove a watched episode
func rmWatchedEpisode(db *gorm.DB, userId uint, id uint) (Activity, error) {
slog.Debug("rmWatchedSeason called", "user_id", userId, "id", id)
var watchedEpisode WatchedEpisode
resp := db.Clauses(clause.Returning{}).Model(&WatchedEpisode{}).Unscoped().Where("id = ? AND user_id = ?", id, userId).Delete(&watchedEpisode)
if resp.Error != nil {
slog.Error("Failed when removing a watched episode", "error", resp.Error)
return Activity{}, errors.New("failed when removing watched episode")
}
if resp.RowsAffected == 0 {
slog.Error("Failed when removing a watched episode", "error", "zero rows affected")
return Activity{}, errors.New("wasn't removed from db.. may not exist")
}
slog.Debug("rmWatchedEpisode, deleted row", "row", watchedEpisode)
if watchedEpisode.ID != 0 {
json, _ := json.Marshal(map[string]interface{}{
"season": watchedEpisode.SeasonNumber,
"episode": watchedEpisode.EpisodeNumber,
"status": watchedEpisode.Status,
"rating": watchedEpisode.Rating,
})
addedActivity, _ := addActivity(db, userId, ActivityAddRequest{WatchedID: watchedEpisode.WatchedID, Type: EPISODE_REMOVED, Data: string(json)})
return addedActivity, nil
}
return Activity{}, errors.New("removed, but failed to add activity entry")
}
+141
View File
@@ -0,0 +1,141 @@
package main
import (
"encoding/json"
"errors"
"log/slog"
"time"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
// UniqueIndex applied between WatchedID and SeasonNumber to avoid duplicates incase logic fails.
type WatchedSeason struct {
GormModel
UserID uint `json:"-" gorm:"not null"`
User User `json:"-"`
WatchedID uint `json:"-" gorm:"uniqueIndex:ws_watched_to_season_num;not null"`
SeasonNumber int `json:"seasonNumber" gorm:"uniqueIndex:ws_watched_to_season_num;not null"`
Status WatchedStatus `json:"status"`
Rating int8 `json:"rating"`
}
type WatchedSeasonAddRequest struct {
WatchedID uint `json:"watchedId"`
SeasonNumber int `json:"seasonNumber"`
Status WatchedStatus `json:"status"`
Rating int8 `json:"rating"`
addActivity ActivityType `json:"-"`
addActivityDate time.Time `json:"-"`
}
type WatchedSeasonAddResponse struct {
WatchedSeasons []WatchedSeason `json:"watchedSeasons"`
AddedActivity Activity `json:"addedActivity"`
}
// Add/edit a watched season.
func addWatchedSeason(db *gorm.DB, userId uint, ar WatchedSeasonAddRequest) (WatchedSeasonAddResponse, error) {
slog.Debug("Adding watched season item", "userId", userId, "watchedID", ar.WatchedID, "season", ar.SeasonNumber)
// 1. Make sure watched item exists and it is the correct type (TV)
var w Watched
if resp := db.Where("id = ? AND user_id = ?", ar.WatchedID, userId).Preload("Content").Preload("WatchedSeasons").Find(&w); resp.Error != nil {
slog.Error("Failed when adding a watched season", "error", "failed to get watched item from db")
return WatchedSeasonAddResponse{}, errors.New("failed when retrieving watched item")
}
if w.ID == 0 {
slog.Error("Failed when adding a watched season", "error", "watched item does not exist in db")
return WatchedSeasonAddResponse{}, errors.New("can't add a watched season for a show that doesnt have a status itself")
}
if w.Content.Type != SHOW {
return WatchedSeasonAddResponse{}, errors.New("can't add watched season for non show content")
}
found := false
updated := false
for i, ws := range w.WatchedSeasons {
if ws.SeasonNumber == ar.SeasonNumber {
slog.Debug("Existing watched season item found, updating existing")
found = true
if ar.Status != "" && ar.Status != w.WatchedSeasons[i].Status {
w.WatchedSeasons[i].Status = ar.Status
updated = true
}
if ar.Rating != 0 && ar.Rating != w.WatchedSeasons[i].Rating {
w.WatchedSeasons[i].Rating = ar.Rating
updated = true
}
break
}
}
var addedActivity Activity
if !found {
slog.Debug("Existing watched season not found, adding as new entry")
w.WatchedSeasons = append(w.WatchedSeasons, WatchedSeason{
UserID: userId,
WatchedID: ar.WatchedID,
SeasonNumber: ar.SeasonNumber,
Status: ar.Status,
Rating: ar.Rating,
})
}
if resp := db.Save(&w.WatchedSeasons); resp.Error != nil {
slog.Debug("Failed to save watched season item in db", "error", resp.Error)
return WatchedSeasonAddResponse{}, errors.New("failed to save")
}
// Add activity
if found {
// Only add change activity if we actually updated a value
// (changing value to same value doesn't count).
if updated {
if ar.Status != "" {
json, _ := json.Marshal(map[string]interface{}{"season": ar.SeasonNumber, "status": ar.Status})
addedActivity, _ = addActivity(db, userId, ActivityAddRequest{WatchedID: w.ID, Type: SEASON_STATUS_CHANGED, Data: string(json)})
}
if ar.Rating != 0 {
json, _ := json.Marshal(map[string]interface{}{"season": ar.SeasonNumber, "rating": ar.Rating})
addedActivity, _ = addActivity(db, userId, ActivityAddRequest{WatchedID: w.ID, Type: SEASON_RATING_CHANGED, Data: string(json)})
}
}
} else {
json, _ := json.Marshal(map[string]interface{}{"season": ar.SeasonNumber, "status": ar.Status, "rating": ar.Rating})
act := ActivityAddRequest{WatchedID: w.ID, Type: SEASON_ADDED, Data: string(json)}
if ar.addActivity != "" {
act.Type = ar.addActivity
}
if !ar.addActivityDate.IsZero() {
act.CustomDate = &ar.addActivityDate
}
addedActivity, _ = addActivity(db, userId, act)
}
return WatchedSeasonAddResponse{
WatchedSeasons: w.WatchedSeasons,
AddedActivity: addedActivity,
}, nil
}
// Remove a watched season
func rmWatchedSeason(db *gorm.DB, userId uint, seasonId uint) (Activity, error) {
slog.Debug("rmWatchedSeason called", "user_id", userId, "season_id", seasonId)
var watchedSeason WatchedSeason
resp := db.Clauses(clause.Returning{}).Model(&WatchedSeason{}).Unscoped().Where("id = ? AND user_id = ?", seasonId, userId).Delete(&watchedSeason)
if resp.Error != nil {
slog.Error("Failed when removing a watched season", "error", resp.Error)
return Activity{}, errors.New("failed when removing watched season")
}
if resp.RowsAffected == 0 {
slog.Error("Failed when removing a watched season", "error", "zero rows affected")
return Activity{}, errors.New("wasn't removed from db.. may not exist")
}
slog.Debug("rmWatchedSeason, deleted row", "row", watchedSeason)
if watchedSeason.ID != 0 {
json, _ := json.Marshal(map[string]interface{}{
"season": watchedSeason.SeasonNumber,
"status": watchedSeason.Status,
"rating": watchedSeason.Rating,
})
addedActivity, _ := addActivity(db, userId, ActivityAddRequest{WatchedID: watchedSeason.WatchedID, Type: SEASON_REMOVED, Data: string(json)})
return addedActivity, nil
}
return Activity{}, errors.New("removed, but failed to add activity entry")
}
+2
View File
@@ -3,7 +3,9 @@
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<link rel="apple-touch-icon" href="%sveltekit.assets%/logo-col.png" />
<meta name="viewport" content="width=device-width" />
<title>Watcharr</title>
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
+145 -25
View File
@@ -1,10 +1,14 @@
<script lang="ts">
import type { Activity } from "@/types";
import { getOrdinalSuffix, months } from "./util/helpers";
import { getOrdinalSuffix, months, seasonAndEpToReadable } from "./util/helpers";
import ActivityEditor from "./ActivityEditor.svelte";
export let activity: Activity[] | undefined;
export let wListId: number;
let clickedActivity: Activity;
let groupedActivities: { [index: string]: any };
let isActivityEditorVisible: boolean;
$: {
groupedActivities = getGroupedActivity(activity);
@@ -15,46 +19,143 @@
case "ADDED_WATCHED":
if (a.data) {
const data = JSON.parse(a.data);
return `added to watched list${data?.status ? ` as ${data.status?.toLowerCase()}` : ""}${
data?.rating ? ` with ${data.rating} stars` : ""
return `Added to Watched List${data?.status ? ` as ${toFullTitleCase(data.status)}` : ""}${
data?.rating ? ` with ${data.rating} Stars` : ""
}`;
}
return "added to watched list";
return "Added to Watched List";
case "REMOVED_WATCHED":
return "removed from watched list";
return "Removed from Watched List";
case "RATING_CHANGED":
if (a.data) {
return `rating changed to ${a.data}`;
return `Rating Changed to ${a.data}`;
}
return "rating changed";
return "Rating Changed";
case "STATUS_CHANGED":
if (a.data) {
return `status changed to ${a.data?.toLowerCase()}`;
return `Status Changed to ${toFullTitleCase(a.data)}`;
}
return "status changed";
return "Status Changed";
case "THOUGHTS_CHANGED":
return "thoughts changed";
return "Thoughts Changed";
case "THOUGHTS_REMOVED":
return "thoughts removed";
return "Thoughts Removed";
case "IMPORTED_WATCHED":
return "imported";
return "Imported";
case "IMPORTED_WATCHED_JF":
case "IMPORTED_WATCHED_PLEX":
return "Synced";
case "IMPORTED_RATING":
if (a.data) {
const data = JSON.parse(a.data);
if (data.rating) {
return `Rating Changed to ${data.rating}`;
} else {
return "Added to Watchlist with No Rating";
}
}
return "Imported Rating";
case "IMPORTED_ADDED_WATCHED":
case "IMPORTED_ADDED_WATCHED_JF":
case "IMPORTED_ADDED_WATCHED_PLEX":
return "Imported Watch Date";
case "SEASON_ADDED":
if (a.data) {
const data = JSON.parse(a.data);
return `Season ${data.season} Added as ${toFullTitleCase(data.status)}`;
}
return "Season Added";
case "SEASON_ADDED_JF":
case "SEASON_ADDED_PLEX":
if (a.data) {
const data = JSON.parse(a.data);
return `Season ${data.season} Synced as ${toFullTitleCase(data.status)}`;
}
return "Season Synced";
case "SEASON_RATING_CHANGED":
if (a.data) {
const data = JSON.parse(a.data);
return `Changed Season ${data.season} Rating to ${data.rating}`;
}
return "Season Rating Changed";
case "SEASON_STATUS_CHANGED":
if (a.data) {
const data = JSON.parse(a.data);
return `Changed Season ${data.season} Status to ${toFullTitleCase(data.status)}`;
}
return "Season Status Changed";
case "SEASON_REMOVED":
if (a.data) {
const data = JSON.parse(a.data);
return `Season ${data.season} Status Removed`;
}
return "Season Removed";
case "EPISODE_ADDED":
if (a.data) {
const data = JSON.parse(a.data);
return `${seasonAndEpToReadable(data.season, data.episode)} Added ${data.status ? `as ${toFullTitleCase(data.status)}` : data.rating ? `with Rating ${data.rating}` : ""}`;
}
return "Episode Added";
case "EPISODE_ADDED_JF":
case "EPISODE_ADDED_PLEX":
if (a.data) {
const data = JSON.parse(a.data);
return `${seasonAndEpToReadable(data.season, data.episode)} Synced ${data.status ? `as ${toFullTitleCase(data.status)}` : data.rating ? `with Rating ${data.rating}` : ""}`;
}
return "Episode Synced";
case "EPISODE_RATING_CHANGED":
if (a.data) {
const data = JSON.parse(a.data);
return `${seasonAndEpToReadable(data.season, data.episode)} Rating Changed to ${data.rating}`;
}
return "Episode Rating Changed";
case "EPISODE_STATUS_CHANGED":
if (a.data) {
const data = JSON.parse(a.data);
return `${seasonAndEpToReadable(data.season, data.episode)} Status Changed to ${toFullTitleCase(data.status)}`;
}
return "Episode Status Changed";
case "EPISODE_REMOVED":
if (a.data) {
const data = JSON.parse(a.data);
return `${seasonAndEpToReadable(data.season, data.episode)} Removed`;
}
return "Episode Removed";
default:
return a.type;
}
}
function toFullTitleCase(text: string | undefined) {
if (text) {
return text
.split(" ")
.map((l) => l[0].toUpperCase() + l.substring(1).toLowerCase())
.join(" ");
}
return "Unknown";
}
function toDayTime(d: Date) {
return `${d.getDate()}${getOrdinalSuffix(d.getDate())} at ${d.toLocaleTimeString()}`;
}
/**
* Get what will be the visible date the activity was 'created'.
* @returns customDate if defined or createdAt if not.
*/
function getCreatedAtVis(a: Activity) {
return Date.parse(a.customDate ?? a.createdAt);
}
function getGroupedActivity(activities?: Activity[]) {
activities = activities?.filter((a) => a.type);
const a = activities?.sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt));
const a = activities?.sort((a, b) => getCreatedAtVis(b) - getCreatedAtVis(a));
let grouped: { [index: string]: any } = {};
if (a) {
for (let i = 0; i < a.length; i++) {
const activity = a[i];
const date = new Date(Date.parse(activity.createdAt));
const date = new Date(getCreatedAtVis(activity));
const key = `${months[date.getMonth()]} ${date.getFullYear()}`;
if (grouped[key]) {
grouped[key].push(activity);
@@ -65,8 +166,23 @@
}
return grouped;
}
function openEditor(a: Activity) {
clickedActivity = a;
isActivityEditorVisible = true;
return;
}
</script>
{#if isActivityEditorVisible}
<ActivityEditor
watchedId={wListId}
activity={clickedActivity}
activityMessage={getMsg(clickedActivity)}
onClose={() => (isActivityEditorVisible = false)}
/>
{/if}
<div class="activity">
<h2>Activity</h2>
{#if groupedActivities && Object.keys(groupedActivities).length > 0}
@@ -75,11 +191,12 @@
<h3>{k}</h3>
{#each groupedActivities[k] as a}
{@const d = new Date(getCreatedAtVis(a))}
<li>
<span title={new Date(a.createdAt).toDateString()}>
{toDayTime(new Date(a.createdAt))}
</span>
<span>{getMsg(a)}</span>
<button class="unset" on:click={() => openEditor(a)}>
<span title={d.toDateString()}>{toDayTime(d)}</span>
<span>{getMsg(a)}</span>
</button>
</li>
{/each}
{/each}
@@ -118,12 +235,16 @@
}
li {
display: flex;
flex-flow: row;
align-items: center;
gap: 8px;
width: max-content;
max-width: 100%;
button {
all: unset;
display: flex;
flex-flow: row;
align-items: center;
gap: 8px;
width: max-content;
max-width: 100%;
cursor: pointer;
}
span {
width: max-content;
@@ -135,7 +256,6 @@
&:last-child {
background-color: $accent-color;
text-transform: capitalize;
color: $text-color;
border-radius: 8px;
padding: 10px 12px;
+131
View File
@@ -0,0 +1,131 @@
<script lang="ts">
import { updateActivity, removeActivity } from "@/lib/util/api";
import Modal from "./Modal.svelte";
import type { Activity } from "@/types";
import { notify } from "./util/notify";
export let watchedId: number;
export let activity: Activity;
export let activityMessage: string;
export let onClose: () => void;
let isDateTimeChanged: boolean;
let isDateTimeValid = true;
let currentDateObject = new Date(Date.parse(activity.customDate ?? activity.createdAt));
let currentDateString = dateToInputDateString(currentDateObject);
let currentTimeString = dateToInputTimeString(currentDateObject);
let selectedDateString = currentDateString;
let selectedTimeString = currentTimeString;
$: {
isDateTimeChanged =
currentDateString != selectedDateString || currentTimeString != selectedTimeString;
}
function dateToInputDateString(date: Date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const day = date.getDate().toString().padStart(2, "0");
return `${year}-${month}-${day}`;
}
function dateToInputTimeString(date: Date) {
const hours = date.getHours().toString().padStart(2, "0");
const minutes = date.getMinutes().toString().padStart(2, "0");
return `${hours}:${minutes}`;
}
function validateNewDate() {
try {
const epochMillis = Date.parse(`${selectedDateString} ${selectedTimeString}`);
const dateObj = new Date(epochMillis);
if (isNaN(dateObj.getTime())) {
isDateTimeValid = false;
return;
}
isDateTimeValid = true;
return dateObj;
} catch (err) {
console.error("ActivityEditor: validateNewDate failed!", err);
isDateTimeValid = false;
}
}
function update() {
const dateObj = validateNewDate();
if (dateObj && isDateTimeValid && isDateTimeChanged) {
updateActivity(watchedId, activity.id, dateObj);
onClose();
return;
}
notify({ text: "Unable to try updating!", type: "error" });
console.error(
"ActivityEditor: Can't try updating, data missing/invalid:",
dateObj,
isDateTimeValid,
isDateTimeChanged
);
}
function remove() {
removeActivity(watchedId, activity.id);
onClose();
}
</script>
<Modal title="Edit Activity" desc={activityMessage} maxWidth="400px" {onClose}>
<div class="centered">
<h3>Date</h3>
<input
id="activity-date"
type="date"
bind:value={selectedDateString}
on:change={validateNewDate}
class:invalid={!isDateTimeValid}
/>
<h3>Time</h3>
<input
id="activity-time"
type="time"
bind:value={selectedTimeString}
on:change={validateNewDate}
/>
<div class="button-row">
<button class="danger" on:click={remove}>Delete</button>
<div>
<button on:click={update} disabled={!(isDateTimeChanged && isDateTimeValid)}>Update</button>
</div>
</div>
</div>
</Modal>
<style lang="scss">
.centered {
display: flex;
flex-flow: column;
gap: 10px;
height: 100%;
h3 {
font-size: 16px;
font-family:
sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont;
}
.button-row {
display: flex;
flex-flow: row;
justify-content: space-between;
margin-top: 10px;
button {
margin-top: auto;
width: max-content;
}
}
}
</style>
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
export let name: string;
export let value: boolean = false;
export let toggled: (on: boolean) => void;
export let toggled: (on: boolean) => void = () => {};
export let disabled = false;
let actualDisabled = false;
+20 -8
View File
@@ -1,38 +1,50 @@
<script lang="ts">
import type { DropDownItem } from "@/types";
import Icon from "./Icon.svelte";
export let options: string[];
export let active: string | undefined;
export let options: string[] | DropDownItem[];
export let active: string | number | undefined = undefined;
export let placeholder: string;
export let blendIn: boolean = false;
export let disabled = false;
export let onChange: () => void = () => {};
let availableOptions = options.filter((o) => o !== active);
let activeValue: string;
let open = false;
$: {
if (typeof active === "string") {
activeValue = active;
} else {
const v = options.find((o) => (typeof o !== "string" ? o.id === active : false));
if (v && typeof v !== "string") activeValue = v.value;
}
}
</script>
<div
class={[
open ? "is-open" : "",
!active ? "placeholder-shown" : "",
typeof active === "undefined" ? "placeholder-shown" : "",
blendIn ? "blend-in" : ""
].join(" ")}
>
<button on:click={() => (open = !open)} {disabled}>
{active ? active : placeholder}
{activeValue ? activeValue : placeholder}
<Icon i="chevron" facing={open ? "up" : "down"} />
</button>
<ul>
{#each availableOptions as o}
{#each options.filter((o) => (typeof o === "string" ? o !== active : o.id !== active)) as o}
<li>
<button
class="plain"
on:click={() => {
active = o;
active = typeof o == "string" ? o : o.id;
open = false;
onChange();
}}
>
{o}
{typeof o == "string" ? o : o.value}
</button>
</li>
{/each}
+121
View File
@@ -0,0 +1,121 @@
<script lang="ts">
import { onMount } from "svelte";
import type { Icon as IconT } from "@/types";
import Icon from "./Icon.svelte";
export let text: string;
export let icon: IconT = "document";
export let filesSelected: (f?: FileList | null) => void;
export let allowSelectMultipleFiles = false;
let fileInput: HTMLInputElement;
let dragEnterTarget: EventTarget | null;
let isDragOver = false;
function importFile() {
fileInput.click();
}
onMount(() => {
if (fileInput) {
fileInput.addEventListener("change", () => {
filesSelected(fileInput.files);
});
}
});
</script>
<div class="drop-file-btn">
<button
on:click={importFile}
on:dragover={(ev) => {
ev.preventDefault();
ev.stopPropagation();
}}
on:dragenter={(ev) => {
ev.preventDefault();
ev.stopPropagation();
dragEnterTarget = ev.target;
console.log("enter");
isDragOver = true;
}}
on:dragleave={(ev) => {
ev.preventDefault();
ev.stopPropagation();
if (dragEnterTarget === ev.target) {
console.log("leave");
isDragOver = false;
}
}}
on:drop={(ev) => {
ev.preventDefault();
ev.stopPropagation();
filesSelected(ev.dataTransfer?.files);
}}
class={isDragOver ? "dragging-over" : ""}
>
<Icon i={isDragOver ? "add" : icon} wh="100%" />
<div>
<h4 class="norm">
{#if isDragOver}
Import {text}
{:else}
Browse For {text}
{/if}
</h4>
</div>
</button>
<input type="file" multiple={allowSelectMultipleFiles} bind:this={fileInput} />
</div>
<style lang="scss">
.drop-file-btn {
button {
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
gap: 10px;
height: 180px;
padding: 20px;
background-color: $accent-color;
border: unset;
border-radius: 10px;
user-select: none;
transition: 180ms ease-in-out;
:global {
#reel path {
transition: 180ms ease-in-out;
&:first-of-type {
fill: transparent;
}
&:last-of-type {
fill: $text-color;
}
}
}
&:hover,
&.dragging-over {
color: $bg-color;
background-color: $accent-color-hover;
:global(#reel path:last-of-type) {
fill: $bg-color;
}
}
}
input[type="file"] {
width: 0px;
overflow: hidden;
border: unset;
background-color: transparent;
position: absolute;
top: -500px;
}
}
</style>
+20 -7
View File
@@ -2,19 +2,32 @@
export let title: string | undefined;
</script>
{#if title}
<h2>{title}</h2>
{/if}
<ul>
<slot />
</ul>
<div>
{#if title}
<h2>{title}</h2>
{/if}
<ul>
<slot />
</ul>
</div>
<style lang="scss">
div {
width: 100%;
overflow-x: auto;
}
h2 {
font-family: sans-serif, system-ui, -apple-system, BlinkMacSystemFont;
font-family:
sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont;
font-size: 30px;
font-weight: bold;
margin-left: 30px;
position: sticky;
left: 0;
}
ul {
+96 -9
View File
@@ -58,6 +58,10 @@
d="M12 .002C8.826.002-1.398 18.537.16 21.666c1.56 3.129 22.14 3.094 23.682 0C25.384 18.573 15.177 0 12 0zm7.76 18.949c-1.008 2.028-14.493 2.05-15.514 0C3.224 16.9 9.92 4.755 12.003 4.755c2.081 0 8.77 12.166 7.759 14.196zM12 9.198c-1.054 0-4.446 6.15-3.93 7.189.518 1.04 7.348 1.027 7.86 0 .511-1.027-2.874-7.19-3.93-7.19z"
/>
</svg>
{:else if i === "plex"}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width={wh} height={wh}>
<path d="M256 70H148l108 186-108 186h108l108-186z" fill="#e5a00d" />
</svg>
{:else if i === "trash"}
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">
<path
@@ -120,16 +124,10 @@
/>
</svg>
{:else if i === "compass"}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<svg xmlns="http://www.w3.org/2000/svg" width={wh} height={wh} viewBox="0 0 512 512">
<circle cx="256" cy="256" r="24" />
<path
fill="none"
stroke="currentColor"
stroke-miterlimit="10"
stroke-width="32"
d="M448 256a192 192 0 1 0-384 0 192 192 0 0 0 384 0z"
/>
<path
d="m351 151-118 47a64 64 0 0 0-35 35l-47 118a8 8 0 0 0 10 10l118-47a64 64 0 0 0 35-35l47-118a8 8 0 0 0-10-10zm-95 129a24 24 0 1 1 24-24 24 24 0 0 1-24 24z"
d="M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm105.07 113.33l-46.88 117.2a64 64 0 01-35.66 35.66l-117.2 46.88a8 8 0 01-10.4-10.4l46.88-117.2a64 64 0 0135.66-35.66l117.2-46.88a8 8 0 0110.4 10.4z"
/>
</svg>
{:else if i === "document"}
@@ -207,6 +205,91 @@
d="M296 464a23.88 23.88 0 01-7.55-1.23L208.3 436.1a23.92 23.92 0 01-16.3-22.78V294.11a.44.44 0 00-.09-.13L23.26 97.54A30 30 0 0146.05 48H466a30 30 0 0122.79 49.54L320.09 294a.77.77 0 00-.09.13V440a23.93 23.93 0 01-24 24z"
/>
</svg>
{:else if i === "eye-closed"}
<svg xmlns="http://www.w3.org/2000/svg" width={wh} height={wh} viewBox="0 0 512 512">
<path
d="M432 448a15.92 15.92 0 01-11.31-4.69l-352-352a16 16 0 0122.62-22.62l352 352A16 16 0 01432 448zM248 315.85l-51.79-51.79a2 2 0 00-3.39 1.69 64.11 64.11 0 0053.49 53.49 2 2 0 001.69-3.39zM264 196.15L315.87 248a2 2 0 003.4-1.69 64.13 64.13 0 00-53.55-53.55 2 2 0 00-1.72 3.39z"
/>
<path
d="M491 273.36a32.2 32.2 0 00-.1-34.76c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.68 96a226.54 226.54 0 00-71.82 11.79 4 4 0 00-1.56 6.63l47.24 47.24a4 4 0 003.82 1.05 96 96 0 01116 116 4 4 0 001.05 3.81l67.95 68a4 4 0 005.4.24 343.81 343.81 0 0067.24-77.4zM256 352a96 96 0 01-93.3-118.63 4 4 0 00-1.05-3.81l-66.84-66.87a4 4 0 00-5.41-.23c-24.39 20.81-47 46.13-67.67 75.72a31.92 31.92 0 00-.64 35.54c26.41 41.33 60.39 76.14 98.28 100.65C162.06 402 207.92 416 255.68 416a238.22 238.22 0 0072.64-11.55 4 4 0 001.61-6.64l-47.47-47.46a4 4 0 00-3.81-1.05A96 96 0 01256 352z"
/>
</svg>
{:else if i === "people"}
<svg xmlns="http://www.w3.org/2000/svg" width={wh} height={wh} viewBox="0 0 512 512">
<path
d="M258.9 48C141.92 46.42 46.42 141.92 48 258.9c1.56 112.19 92.91 203.54 205.1 205.1 117 1.6 212.48-93.9 210.88-210.88C462.44 140.91 371.09 49.56 258.9 48zm-3.68 152.11c.21-1.2.44-2.4.71-3.59a66.46 66.46 0 0116.29-31.21c12.89-13.73 31.16-21.31 51.45-21.31a74.05 74.05 0 0125.06 4.26 66.69 66.69 0 0126.27 17.2 68.15 68.15 0 0118 42.14 78.46 78.46 0 010 11.4 86.19 86.19 0 01-8.2 31q-.76 1.59-1.59 3.15c-1.11 2.07-2.3 4.1-3.58 6.06a79.47 79.47 0 01-8.63 11c-13.12 14-29.92 21.73-47.31 21.73a59.61 59.61 0 01-19.17-3.18 63.47 63.47 0 01-6.1-2.43 70.76 70.76 0 01-22.07-16.12 83.76 83.76 0 01-22-51.32q-.27-3.88-.18-7.68a75.62 75.62 0 011.05-11.08zm-149.73 24.34a59.87 59.87 0 015.2-20.64 56.76 56.76 0 012.78-5.3 54.49 54.49 0 017.19-9.56 55.62 55.62 0 0114-10.82 56.84 56.84 0 018.11-3.64 63.85 63.85 0 0133.35-2.39 57 57 0 0130.78 17 57.86 57.86 0 0115.41 38.62c.05 2.11 0 4.23-.15 6.38a71.58 71.58 0 01-6 23.84 69.49 69.49 0 01-5.73 10.42 65.39 65.39 0 01-15.76 16.57c-1.5 1.07-3.06 2.07-4.67 3.07a54.21 54.21 0 01-10 4.65 49.31 49.31 0 01-16.2 2.76c-.93 0-1.86 0-2.78-.08a47.6 47.6 0 01-5.48-.62 51.19 51.19 0 01-5.35-1.23 53.54 53.54 0 01-7.72-2.89c-.84-.39-1.66-.8-2.48-1.23-18-9.49-31.57-29.16-34.23-52.12-.12-1.05-.22-2.1-.29-3.16a66.59 66.59 0 01.02-9.63zm53.92 178.6a177.27 177.27 0 01-61.94-70.65 4 4 0 011.62-5.26C117.67 316.69 141.4 311 163.82 311c17 0 30.7 2 42.69 5.88a8 8 0 012.59 13.77c-23.35 19-38.4 42.54-45.47 70.75a2.77 2.77 0 01-4.22 1.65zM256 432a175.12 175.12 0 01-65.7-12.72 4 4 0 01-2.4-4.46c.4-2.05.84-3.92 1.23-5.48 7.12-28.43 24.76-52 51-68.18 23.29-14.35 53-22.25 83.52-22.25 31.16 0 60 7.58 83.48 21.91a2.72 2.72 0 01.91 3.67A176.1 176.1 0 01256 432z"
/>
<path
d="M161 295.28a47.6 47.6 0 01-5.48-.62 47.6 47.6 0 005.48.62zM134.64 178.13a55.62 55.62 0 00-14 10.82 54.49 54.49 0 00-7.19 9.56 54.49 54.49 0 017.19-9.56 55.62 55.62 0 0114-10.82zM216.17 257.89a71.58 71.58 0 006-23.84c.15-2.15.2-4.27.15-6.38q.08 3.15-.15 6.38a71.58 71.58 0 01-6 23.84zM134.64 178.13a56.84 56.84 0 018.11-3.64 56.84 56.84 0 00-8.11 3.64zM150.21 293.43a53.54 53.54 0 01-7.72-2.89 53.54 53.54 0 007.72 2.89zM105.78 237.19c2.66 23 16.26 42.63 34.23 52.12-18.01-9.49-31.57-29.16-34.23-52.12zM254.34 219a83.76 83.76 0 0022 51.32 70.76 70.76 0 0022.07 16.12 70.76 70.76 0 01-22.07-16.12 83.76 83.76 0 01-22-51.32q-.27-3.88-.18-7.68-.09 3.75.18 7.68zM304.5 288.82a63.47 63.47 0 01-6.1-2.43 63.47 63.47 0 006.1 2.43zM255.93 196.54a66.46 66.46 0 0116.29-31.21 66.46 66.46 0 00-16.29 31.21zM375 165.46a68.15 68.15 0 0118 42.14 68.15 68.15 0 00-18-42.14 66.69 66.69 0 00-26.27-17.2 66.69 66.69 0 0126.27 17.2zM393 219a86.19 86.19 0 01-8.2 31 86.19 86.19 0 008.2-31zM254.16 211.27a75.62 75.62 0 011.06-11.14 75.62 75.62 0 00-1.06 11.14zM383.19 253.16zM206.88 189.05a57.86 57.86 0 0115.41 38.62 57.86 57.86 0 00-15.41-38.62 57 57 0 00-30.78-17 57 57 0 0130.78 17zM190 288a54.21 54.21 0 01-10 4.65 54.21 54.21 0 0010-4.65zM105.49 224.45a59.87 59.87 0 015.2-20.64 59.87 59.87 0 00-5.2 20.64zM194.68 284.88C193.17 286 191.61 287 190 288c1.61-1 3.17-2 4.68-3.12zM216.17 257.89a69.49 69.49 0 01-5.73 10.42 69.49 69.49 0 005.73-10.42zM110.69 203.81a56.76 56.76 0 012.78-5.3 56.76 56.76 0 00-2.78 5.3zM194.68 284.88a65.39 65.39 0 0015.76-16.57 65.39 65.39 0 01-15.76 16.57z"
/>
</svg>
{:else if i === "person"}
<svg xmlns="http://www.w3.org/2000/svg" width={wh} height={wh} viewBox="0 0 512 512">
<path
d="M258.9 48C141.92 46.42 46.42 141.92 48 258.9c1.56 112.19 92.91 203.54 205.1 205.1 117 1.6 212.48-93.9 210.88-210.88C462.44 140.91 371.09 49.56 258.9 48zm126.42 327.25a4 4 0 01-6.14-.32 124.27 124.27 0 00-32.35-29.59C321.37 329 289.11 320 256 320s-65.37 9-90.83 25.34a124.24 124.24 0 00-32.35 29.58 4 4 0 01-6.14.32A175.32 175.32 0 0180 259c-1.63-97.31 78.22-178.76 175.57-179S432 158.81 432 256a175.32 175.32 0 01-46.68 119.25z"
/>
<path
d="M256 144c-19.72 0-37.55 7.39-50.22 20.82s-19 32-17.57 51.93C191.11 256 221.52 288 256 288s64.83-32 67.79-71.24c1.48-19.74-4.8-38.14-17.68-51.82C293.39 151.44 275.59 144 256 144z"
/>
</svg>
{:else if i === "person-add"}
<svg xmlns="http://www.w3.org/2000/svg" width={wh} height={wh} viewBox="0 0 512 512">
<path
d="M288 256c52.79 0 99.43-49.71 104-110.82 2.27-30.7-7.36-59.33-27.12-80.6C345.33 43.57 318 32 288 32c-30.24 0-57.59 11.5-77 32.38-19.63 21.11-29.2 49.8-27 80.78C188.49 206.28 235.12 256 288 256zM495.38 439.76c-8.44-46.82-34.79-86.15-76.19-113.75C382.42 301.5 335.83 288 288 288s-94.42 13.5-131.19 38c-41.4 27.6-67.75 66.93-76.19 113.75-1.93 10.73.69 21.34 7.19 29.11A30.94 30.94 0 00112 480h352a30.94 30.94 0 0024.21-11.13c6.48-7.77 9.1-18.38 7.17-29.11zM104 288v-40h40a16 16 0 000-32h-40v-40a16 16 0 00-32 0v40H32a16 16 0 000 32h40v40a16 16 0 0032 0z"
/>
</svg>
{:else if i === "person-minus"}
<svg xmlns="http://www.w3.org/2000/svg" width={wh} height={wh} viewBox="0 0 512 512">
<path
d="M288 256c52.79 0 99.43-49.71 104-110.82 2.27-30.7-7.36-59.33-27.12-80.6C345.33 43.57 318 32 288 32c-30.24 0-57.59 11.5-77 32.38-19.63 21.11-29.2 49.8-27 80.78C188.49 206.28 235.12 256 288 256zM495.38 439.76c-8.44-46.82-34.79-86.15-76.19-113.75C382.42 301.5 335.83 288 288 288s-94.42 13.5-131.19 38c-41.4 27.6-67.75 66.93-76.19 113.75-1.93 10.73.69 21.34 7.19 29.11A30.94 30.94 0 00112 480h352a30.94 30.94 0 0024.21-11.13c6.48-7.77 9.1-18.38 7.17-29.11zM144 216H32a16 16 0 000 32h112a16 16 0 000-32z"
/>
</svg>
{:else if i === "pencil"}
<svg xmlns="http://www.w3.org/2000/svg" width={wh} height={wh} viewBox="0 0 512 512">
<path
fill="none"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="44"
d="M358.62 129.28L86.49 402.08 70 442l39.92-16.49 272.8-272.13-24.1-24.1zM413.07 74.84l-11.79 11.78 24.1 24.1 11.79-11.79a16.51 16.51 0 000-23.34l-.75-.75a16.51 16.51 0 00-23.35 0z"
/>
</svg>
{:else if i === "eye"}
<svg xmlns="http://www.w3.org/2000/svg" width={wh} height={wh} viewBox="0 0 512 512">
<circle cx="256" cy="256" r="64" />
<path
d="M490.84 238.6c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.66 96c-42.52 0-84.33 12.15-124.27 36.11-40.73 24.43-77.63 60.12-109.68 106.07a31.92 31.92 0 00-.64 35.54c26.41 41.33 60.4 76.14 98.28 100.65C162 402 207.9 416 255.66 416c46.71 0 93.81-14.43 136.2-41.72 38.46-24.77 72.72-59.66 99.08-100.92a32.2 32.2 0 00-.1-34.76zM256 352a96 96 0 1196-96 96.11 96.11 0 01-96 96z"
/>
</svg>
{:else if i === "star"}
<svg xmlns="http://www.w3.org/2000/svg" width={wh} height={wh} viewBox="0 0 512 512">
<path
d="M394 480a16 16 0 01-9.39-3L256 383.76 127.39 477a16 16 0 01-24.55-18.08L153 310.35 23 221.2a16 16 0 019-29.2h160.38l48.4-148.95a16 16 0 0130.44 0l48.4 149H480a16 16 0 019.05 29.2L359 310.35l50.13 148.53A16 16 0 01394 480z"
/>
</svg>
{:else if i === "movary"}
<svg
xmlns="http://www.w3.org/2000/svg"
width={wh}
height={wh}
viewBox="0 0 120 120"
preserveAspectRatio="xMidYMid meet"
>
<g transform="translate(0.000000,120.000000) scale(0.100000,-0.100000)" fill="currentColor">
<path
d="M470 1184 c-221 -47 -408 -236 -455 -459 -43 -204 16 -398 164 -545
87 -87 164 -131 277 -160 375 -96 742 191 744 581 0 83 -30 202 -72 282 -48
92 -165 205 -258 251 -129 62 -264 80 -400 50z m-147 -216 c12 -6 75 -51 140
-100 64 -49 123 -91 131 -94 7 -3 67 35 132 84 168 125 169 125 193 112 11 -6
25 -19 31 -30 6 -11 10 -141 10 -342 0 -358 -2 -368 -60 -368 -56 0 -60 18
-60 288 0 208 -2 243 -15 248 -9 4 -54 -11 -100 -31 l-85 -38 -2 -211 -3 -211
-33 0 -34 0 2 201 c0 162 -2 205 -14 216 -22 23 -164 81 -181 75 -13 -6 -15
-41 -15 -253 0 -216 -2 -250 -17 -266 -19 -21 -66 -24 -82 -4 -8 10 -12 113
-12 357 0 340 1 344 22 362 25 20 24 20 52 5z"
/>
</g>
</svg>
{/if}
<style lang="scss">
@@ -220,6 +303,10 @@
&.down {
transform: rotate(270deg);
}
&.right {
transform: rotate(180deg);
}
}
#reel {
+65
View File
@@ -0,0 +1,65 @@
<script lang="ts">
import type { ListBoxItem } from "@/types";
import Checkbox from "./Checkbox.svelte";
export let options: ListBoxItem[];
/**
* If a checkbox to select all checkboxes is wanted,
* provide the text to display besides it.
*/
export let allCheckBox: string | undefined = undefined;
let allCheckBoxValue: boolean = false;
</script>
<div>
{#if allCheckBox}
<div>
<Checkbox
name={allCheckBox}
bind:value={allCheckBoxValue}
toggled={(on) => {
for (let i = 0; i < options.length; i++) {
const e = options[i];
e.value = on;
}
options = options;
}}
/>
<span>{allCheckBox}</span>
</div>
{/if}
{#each options as o}
<div>
<Checkbox
name={o.displayValue}
bind:value={o.value}
toggled={(on) => {
if (!on) {
allCheckBoxValue = false;
} else if (!allCheckBoxValue) {
if (!options.some((o) => !o.value)) {
allCheckBoxValue = true;
}
}
}}
/>
<span>{o.displayValue}</span>
</div>
{/each}
</div>
<style lang="scss">
div {
display: flex;
flex-flow: column;
gap: 10px;
& > div {
display: flex;
flex-flow: row;
gap: 10px;
}
}
</style>
+17 -7
View File
@@ -2,18 +2,21 @@
import Icon from "./Icon.svelte";
export let title: string;
export let desc: string;
export let desc: string | undefined = undefined;
export let onClose: (() => void) | undefined = undefined;
export let maxWidth = "1000px";
</script>
<div class="backdrop"></div>
<div class="modal">
<div>
<div style="max-width:{maxWidth};">
{#if typeof onClose !== "undefined"}
<button class="close" on:click={onClose}><Icon i="close" wh="20" /></button>
{/if}
<h3 class="norm">{title}</h3>
<h5 class="norm">{desc}</h5>
{#if desc}
<h5 class="norm">{desc}</h5>
{/if}
<slot />
</div>
</div>
@@ -25,10 +28,10 @@
left: 0;
width: 100dvw;
height: 100dvh;
z-index: 9998;
backdrop-filter: blur(2px) saturate(180%);
background-color: color-mix(in srgb, black 85%, transparent);
position: fixed;
z-index: 99998;
}
.modal {
@@ -40,19 +43,26 @@
top: 0;
left: 0;
position: fixed;
z-index: 9999;
z-index: 99998;
& > div {
position: relative;
display: flex;
flex-flow: column;
min-width: 300px;
min-height: 300px;
width: 100%;
max-width: 1000px;
max-height: calc(100% - 20px);
background-color: $bg-color;
border-radius: 10px;
padding: 15px 20px;
margin: 20px 100px;
transition: margin 100ms ease;
outline: 2px solid $text-color;
overflow: auto;
h5 {
margin-bottom: 15px;
}
button.close {
position: absolute;
+56 -14
View File
@@ -1,9 +1,13 @@
<script lang="ts">
import { onMount } from "svelte";
export let rating: number | undefined;
export let onChange: (newRating: number) => void;
let hoveredRating: number | undefined;
let shownRating: number | undefined;
let ratingContainer: HTMLDivElement;
let ratingText: HTMLSpanElement;
const ratingDesc = [
"Apalling",
@@ -19,40 +23,67 @@
];
function handleStarClick(r: number) {
if (r === rating) return;
onChange(r);
}
$: {
if (hoveredRating !== undefined) shownRating = hoveredRating;
else if (rating !== undefined) shownRating = rating;
else shownRating = undefined;
else if (rating !== undefined) {
shownRating = rating;
resetRatingText();
} else shownRating = undefined;
}
function handleStarHover(r: number) {
function resetRatingText() {
if (!ratingText) {
console.warn("resetRatingText: ratingText is not defined yet.");
return;
}
if (typeof rating === "number" && rating > 0) {
ratingText.innerText = ratingDesc[rating - 1];
} else {
ratingText.innerText = "Select Your Rating";
}
}
function handleStarHover(
ev: MouseEvent & {
currentTarget: EventTarget & HTMLButtonElement;
},
r: number
) {
hoveredRating = r;
// We set innerText instead of letting svelte update dom for us
// since we need the new width of span right now.
ratingText.innerText = ratingDesc[r - 1];
const start = ratingContainer?.getBoundingClientRect()?.x;
const starl = ev?.currentTarget?.getBoundingClientRect()?.left;
const rb = ratingText?.getBoundingClientRect();
ratingText.style.left = `${starl - start - rb.width / 2 + 11.5}px`;
ratingText.style.transform = "unset";
}
function handleStarHoverEnd() {
hoveredRating = undefined;
ratingText.style.left = "50%";
ratingText.style.transform = "translateX(-50%)";
resetRatingText();
}
onMount(() => {
resetRatingText();
});
</script>
<div class="rating-container">
<span>
{#if typeof hoveredRating === "number"}
{ratingDesc[hoveredRating - 1]}
{:else if typeof rating === "number" && rating > 0}
{ratingDesc[rating - 1]}
{:else}
Select Your Rating
{/if}
</span>
<div class="rating-container" bind:this={ratingContainer}>
<span bind:this={ratingText}></span>
<div class="rating">
{#each [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] as v}
<button
class="plain{shownRating === v ? ' lit' : ''}"
on:click={() => handleStarClick(v)}
on:mouseenter={() => handleStarHover(v)}
on:mouseenter={(ev) => handleStarHover(ev, v)}
on:mouseleave={() => handleStarHoverEnd()}
>
*
@@ -65,6 +96,17 @@
.rating-container {
display: flex;
flex-flow: column;
overflow: visible;
& > span {
position: relative;
transition:
left 100ms ease-in,
transform 100ms ease-in;
max-width: max-content;
left: 50%;
transform: translateX(-50%);
}
}
.rating {
+171 -97
View File
@@ -1,36 +1,124 @@
<script lang="ts">
import type { TMDBSeasonDetails, TMDBShowSeason } from "@/types";
import type {
TMDBSeasonDetails,
TMDBShowSeason,
Watched,
WatchedSeasonAddResponse,
WatchedStatus
} from "@/types";
import axios from "axios";
import Spinner from "./Spinner.svelte";
import Error from "./Error.svelte";
import SeasonsListEpisode from "./SeasonsListEpisode.svelte";
import PosterStatus from "./poster/PosterStatus.svelte";
import { notify } from "./util/notify";
import { get } from "svelte/store";
import { watchedList } from "@/store";
import PosterRating from "./poster/PosterRating.svelte";
export let tvId: number;
export let seasons: TMDBShowSeason[];
export let watchedItem: Watched; // Watched list item id
let activeSeason = 1;
let seasonDetailsReq: Promise<TMDBSeasonDetails>;
let seasonsEl: HTMLUListElement, episodesEl: HTMLDivElement;
async function sdr(seasonNum: number) {
return (await axios.get(`/content/tv/${tvId}/season/${seasonNum}`)).data as TMDBSeasonDetails;
}
// Add/update watched season
function updateWatchedSeason(seasonNumber: number, status?: WatchedStatus, rating?: number) {
const nid = notify({ text: `Saving`, type: "loading" });
axios
.post<WatchedSeasonAddResponse>(`/watched/season`, {
watchedId: watchedItem.id,
seasonNumber: seasonNumber,
status,
rating
})
.then((r) => {
const wList = get(watchedList);
const wEntry = wList.find((w) => w.id === watchedItem.id);
if (!wEntry) {
notify({
id: nid,
text: `Request succeeded, but failed to find local data. Please refresh.`,
type: "error"
});
return;
}
if (r.status === 200) {
wEntry.watchedSeasons = r.data.watchedSeasons;
if (wEntry.activity?.length > 0) {
wEntry.activity.push(r.data.addedActivity);
} else {
wEntry.activity = [r.data.addedActivity];
}
watchedList.update((w) => w);
notify({ id: nid, text: `Saved!`, type: "success" });
}
})
.catch((err) => {
console.error(err);
notify({ id: nid, text: "Failed To Update!", type: "error" });
});
}
function handleStatusClick(type: WatchedStatus | "DELETE", seasonNumber: number) {
if (type === "DELETE") {
const ws = watchedItem.watchedSeasons?.find((s) => s.seasonNumber === seasonNumber);
if (!ws) {
notify({ text: "Failed to find watched season id. Please try refreshing.", type: "error" });
return;
}
const nid = notify({ text: `Saving`, type: "loading" });
axios
.delete(`/watched/season/${ws.id}`)
.then((r) => {
const wList = get(watchedList);
const wEntry = wList.find((w) => w.id === watchedItem.id);
if (!wEntry) {
notify({
id: nid,
text: `Request succeeded, but failed to find local data. Please refresh.`,
type: "error"
});
return;
}
if (r.status === 200) {
wEntry.watchedSeasons = wEntry.watchedSeasons?.filter((s) => s.id !== ws.id);
if (r.data) {
if (wEntry.activity?.length > 0) {
wEntry.activity.push(r.data);
} else {
wEntry.activity = [r.data];
}
}
watchedList.update((w) => w);
notify({ id: nid, text: `Removed!`, type: "success" });
}
})
.catch((err) => {
console.error(err);
notify({ id: nid, text: "Failed To Remove!", type: "error" });
});
return;
}
updateWatchedSeason(seasonNumber, type);
}
function handleStarClick(rating: number, seasonNumber: number) {
updateWatchedSeason(seasonNumber, undefined, rating);
}
$: {
seasonDetailsReq = sdr(activeSeason);
}
// onMount(() => {
// episodesEl.style.height = `${seasonsEl.clientHeight}px`;
// seasonsEl.addEventListener("resize", () => {
// console.log("resize");
// episodesEl.style.height = `${seasonsEl.clientHeight}px`;
// });
// });
</script>
<div class="ctr">
<ul class="seasons" bind:this={seasonsEl}>
<!-- {#each seasons.sort((a, b) => Date.parse(b.air_date) - Date.parse(a.air_date)) as season} -->
<ul class="seasons">
{#each seasons as season}
<button
class={`plain${activeSeason === season.season_number ? " active" : ""}`}
@@ -49,34 +137,43 @@
<div class="last" />
</ul>
<div class="episodes" bind:this={episodesEl}>
<div class="episodes">
{#await seasonDetailsReq}
<Spinner />
{:then season}
<div class="episodes-topbar">
<h3>{season.name}</h3>
{#if watchedItem}
{@const ws = watchedItem?.watchedSeasons?.find(
(s) => s.seasonNumber === season.season_number
)}
{#if ws}
<div class="rating" style={ws?.rating ? "width: 65px" : "width: 45px"}>
<PosterRating
rating={ws?.rating}
btnTooltip="Season Rating"
handleStarClick={(r) => handleStarClick(r, season.season_number)}
minimal={true}
direction="bot"
/>
</div>
{/if}
<div class="status">
<PosterStatus
status={ws?.status}
btnTooltip="Season Status"
handleStatusClick={(t) => handleStatusClick(t, season.season_number)}
direction="bot"
width="100%"
small
/>
</div>
{/if}
</div>
{#if season?.episodes?.length > 0}
<ul>
{#each season.episodes as ep}
<li>
{#if ep.still_path}
<img
src={`https://www.themoviedb.org/t/p/w227_and_h127_bestv2/${ep.still_path}`}
alt=""
/>
{:else}
<div class="no-still" />
{/if}
<span>
<b>{ep.episode_number}</b>
{ep.name}
</span>
<span
class="rating"
title={`TMDB Rating: ${ep.vote_average} out of 10 (based on ${ep.vote_count} votes)`}
>
<span>*</span>
{Math.round(ep.vote_average * 10) / 10}
</span>
</li>
<SeasonsListEpisode {ep} {watchedItem} />
{/each}
</ul>
{:else}
@@ -97,7 +194,7 @@
}
.episodes {
overflow: auto;
width: 100%;
ul {
display: flex;
@@ -105,67 +202,6 @@
list-style: none;
gap: 20px;
}
li {
display: flex;
flex-flow: row;
gap: 8px;
img,
.no-still {
width: 227px;
min-width: 227px;
height: 127px;
min-height: 127px;
border-radius: 10px;
background-color: rgb(0, 0, 0);
object-fit: fill;
@media screen and (max-width: 590px) {
width: 80%;
height: auto;
}
@media screen and (max-width: 450px) {
width: 100%;
}
}
span {
padding: 3px 5px;
@media screen and (max-width: 590px) {
text-align: center;
}
}
.rating {
display: flex;
align-items: start;
justify-content: center;
font-size: 15px;
color: $rating-color;
font-weight: bolder;
overflow: hidden;
span {
font-family: "Rampart One";
-webkit-text-stroke: 1px $rating-color;
font-size: 25px;
line-height: 0.7;
margin-top: 1.5px;
}
}
}
@media screen and (max-width: 590px) {
li {
align-items: center;
flex-flow: column;
width: 100%;
height: 100%;
}
}
}
ul.seasons {
@@ -178,16 +214,19 @@
overflow: auto;
position: sticky;
top: 0px;
transition: top 200ms ease-in-out;
button {
display: flex;
flex-flow: row;
gap: 18px;
flex-wrap: wrap;
gap: 0 18px;
align-items: center;
padding: 10px;
border: 2px solid #302d2d;
border-radius: 8px;
cursor: pointer;
max-width: 220px;
transition: background-color 100ms ease;
&:first-of-type {
@@ -224,6 +263,41 @@
}
}
.episodes-topbar {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 20px;
min-height: 40px;
div {
transition: width 100ms ease;
&:first-of-type {
margin-left: auto;
}
&.rating {
height: 40px;
min-height: 40px;
}
&.status {
width: 45px;
min-height: 40px;
height: 40px;
overflow: visible;
}
}
}
@media screen and (min-width: 960px) {
:global(body.nav-shown) ul.seasons {
top: $nav-height;
height: calc(100vh - $nav-height);
}
}
@media screen and (max-width: 960px) {
.ctr {
flex-flow: column;
+359
View File
@@ -0,0 +1,359 @@
<script lang="ts">
import type {
TMDBSeasonDetailsEpisode,
WatchedStatus,
WatchedEpisodeAddResponse,
Watched
} from "@/types";
import Icon from "./Icon.svelte";
import { userSettings } from "@/store";
import PosterRating from "./poster/PosterRating.svelte";
import PosterStatus from "./poster/PosterStatus.svelte";
import axios from "axios";
import { notify } from "./util/notify";
import { get } from "svelte/store";
import { watchedList } from "@/store";
$: settings = $userSettings;
export let ep: TMDBSeasonDetailsEpisode;
export let watchedItem: Watched;
let isHidden = false;
$: {
if (settings) isHidden = settings.hideSpoilers;
}
function updateWatchedEpisode(status?: WatchedStatus, rating?: number) {
const nid = notify({ text: `Saving`, type: "loading" });
axios
.post<WatchedEpisodeAddResponse>(`/watched/episode`, {
watchedId: watchedItem.id,
seasonNumber: ep.season_number,
episodeNumber: ep.episode_number,
status,
rating
})
.then((r) => {
const wList = get(watchedList);
const wEntry = wList.find((w) => w.id === watchedItem.id);
if (!wEntry) {
notify({
id: nid,
text: `Request succeeded, but failed to find local data. Please refresh.`,
type: "error"
});
return;
}
if (r.status === 200) {
wEntry.watchedEpisodes = r.data.watchedEpisodes;
if (wEntry.activity?.length > 0) {
wEntry.activity.push(r.data.addedActivity);
} else {
wEntry.activity = [r.data.addedActivity];
}
watchedList.update((w) => w);
notify({ id: nid, text: `Saved!`, type: "success" });
}
})
.catch((err) => {
console.error(err);
notify({ id: nid, text: "Failed To Update!", type: "error" });
});
}
function handleStatusClick(type: WatchedStatus | "DELETE") {
if (type === "DELETE") {
const ws = watchedItem.watchedEpisodes?.find(
(s) => s.seasonNumber === ep.season_number && s.episodeNumber === ep.episode_number
);
if (!ws) {
notify({
text: "Failed to find watched episode id. Please try refreshing.",
type: "error"
});
return;
}
const nid = notify({ text: `Saving`, type: "loading" });
axios
.delete(`/watched/episode/${ws.id}`)
.then((r) => {
const wList = get(watchedList);
const wEntry = wList.find((w) => w.id === watchedItem.id);
if (!wEntry) {
notify({
id: nid,
text: `Request succeeded, but failed to find local data. Please refresh.`,
type: "error"
});
return;
}
if (r.status === 200) {
wEntry.watchedEpisodes = wEntry.watchedEpisodes?.filter((s) => s.id !== ws.id);
if (r.data) {
if (wEntry.activity?.length > 0) {
wEntry.activity.push(r.data);
} else {
wEntry.activity = [r.data];
}
}
watchedList.update((w) => w);
notify({ id: nid, text: `Removed!`, type: "success" });
}
})
.catch((err) => {
console.error(err);
notify({ id: nid, text: "Failed To Remove!", type: "error" });
});
return;
}
updateWatchedEpisode(type);
}
function handleStarClick(rating: number) {
updateWatchedEpisode(undefined, rating);
}
</script>
<li class={isHidden ? "dont-spoil" : ""}>
{#if ep.still_path}
<img src={`https://www.themoviedb.org/t/p/w227_and_h127_bestv2/${ep.still_path}`} alt="" />
{:else}
<div class="no-still" />
{/if}
<div class="info">
<div>
<span>
<b>{ep.episode_number}</b>
<span class="episode-name">{ep.name}</span>
{#if ep.runtime}
<span class="episode-runtime" title="This episode has a runtime of {ep.runtime} minutes."
>{ep.runtime}m</span
>
{/if}
</span>
<span
class="rating"
title={`TMDB Rating: ${ep.vote_average} out of 10 (based on ${ep.vote_count} votes)`}
>
<span>*</span>
{Math.round(ep.vote_average * 10) / 10}
</span>
</div>
<span class="overview">{ep.overview}</span>
</div>
{#if watchedItem}
{@const we = watchedItem.watchedEpisodes?.find(
(s) => s.seasonNumber === ep.season_number && s.episodeNumber === ep.episode_number
)}
<div class="status-rating-ctr">
<div class="rating" style={"width: 45px"}>
<PosterRating
rating={we?.rating}
btnTooltip={`Episode ${ep.episode_number} Rating`}
handleStarClick={(r) => handleStarClick(r)}
minimal={true}
direction="bot"
hideStarWhenRated
/>
</div>
<div class="status">
<PosterStatus
status={we?.status}
btnTooltip={`Episode ${ep.episode_number} Status`}
handleStatusClick={(t) => handleStatusClick(t)}
direction="bot"
width="100%"
small
/>
</div>
</div>
{/if}
{#if isHidden}
<button class="plain spoiler-text" on:click={() => (isHidden = false)}>
<Icon i="eye-closed" wh={34} />
<span>Click To Reveal</span>
</button>
{/if}
</li>
<style lang="scss">
li {
display: flex;
flex-flow: row;
gap: 8px;
position: relative;
img,
.no-still {
width: 227px;
min-width: 227px;
height: 127px;
min-height: 127px;
border-radius: 10px;
background-color: rgb(0, 0, 0);
object-fit: fill;
@media screen and (max-width: 590px) {
width: 80%;
height: auto;
}
@media screen and (max-width: 450px) {
width: 100%;
}
}
.info {
display: flex;
flex-flow: column;
& > div {
display: flex;
flex-flow: row;
align-items: center;
.episode-name,
.episode-runtime {
text-transform: lowercase;
font-variant: small-caps;
font-weight: bold;
font-size: 16px;
}
.episode-runtime {
font-size: 14px;
padding: 0 2px;
}
.rating {
display: flex;
align-items: start;
justify-content: center;
font-size: 15px;
color: $rating-color;
font-weight: bolder;
overflow: hidden;
span {
margin-top: 2px;
font-family: "Rampart One";
-webkit-text-stroke: 1px $rating-color;
font-size: 25px;
line-height: 0.7;
}
}
}
}
.status-rating-ctr {
display: flex;
align-items: center;
flex-flow: column-reverse;
gap: 10px;
margin-bottom: auto;
min-height: 40px;
margin-left: auto;
div {
transition: width 100ms ease;
&:first-of-type {
margin-left: auto;
}
&.rating {
height: 40px;
min-height: 40px;
}
&.status {
width: 45px;
min-height: 40px;
height: 40px;
overflow: visible;
}
}
}
span {
padding: 3px 5px;
@media screen and (max-width: 590px) {
text-align: center;
}
}
.spoiler-text {
display: flex;
flex-flow: column;
align-items: center;
justify-content: center;
gap: 8px;
position: absolute;
width: 100%;
height: 100%;
font-weight: bolder;
font-size: 20px;
fill: $text-color;
opacity: 0;
transition:
visibility 150ms ease-in,
opacity 150ms ease-in;
cursor: pointer;
span {
text-shadow: 0 0 6px $bg-color;
}
:global(svg) {
filter: drop-shadow(0 0 8px $bg-color);
}
&:hover,
&:active,
&:focus {
opacity: 1;
}
}
img,
.episode-name,
.rating,
.overview {
transition: filter 150ms ease-out;
}
&.dont-spoil {
.episode-name,
.rating,
.overview {
filter: blur(4px);
}
img {
filter: blur(6px);
}
}
}
@media screen and (max-width: 590px) {
li {
align-items: center;
flex-flow: column;
width: 100%;
height: 100%;
.status-rating-ctr {
flex-flow: row;
justify-content: center;
margin-left: unset;
}
}
.rating {
margin-left: auto;
}
}
</style>
+10 -3
View File
@@ -13,11 +13,13 @@
width: 80px;
aspect-ratio: 1;
border: 10px solid $bg-color;
background: radial-gradient(farthest-side, $text-color 98%, $bg-color) 0 0/20px 20px,
background:
radial-gradient(farthest-side, $text-color 98%, $bg-color) 0 0/20px 20px,
radial-gradient(farthest-side, $text-color 98%, $bg-color) 100% 0/20px 20px,
radial-gradient(farthest-side, $text-color 98%, $bg-color) 100% 100%/20px 20px,
radial-gradient(farthest-side, $text-color 98%, $bg-color) 0 100%/20px 20px,
linear-gradient($text-color 0 0) center/40px 40px, $bg-color;
linear-gradient($text-color 0 0) center/40px 40px,
$bg-color;
background-repeat: no-repeat;
filter: blur(4px) contrast(10);
animation: spin 800ms infinite;
@@ -25,7 +27,12 @@
@keyframes spin {
100% {
background-position: 100% 0, 100% 100%, 0 100%, 0 0, center;
background-position:
100% 0,
100% 100%,
0 100%,
0 0,
center;
}
}
</style>
+18 -10
View File
@@ -2,44 +2,51 @@
import Icon from "./Icon.svelte";
import type { WatchedStatus } from "../types";
import tooltip from "./actions/tooltip";
import { toUnderstandableStatus } from "./util/helpers";
export let status: WatchedStatus | undefined;
export let isForGame: boolean = false;
export let onChange: (newStatus: WatchedStatus) => void;
function handleStatusClick(s: WatchedStatus) {
if (s === status) return;
onChange(s);
}
</script>
<div class="status">
<button
class={status && status !== "PLANNED" ? "not-active" : ""}
on:click={() => onChange("PLANNED")}
use:tooltip={{ text: "Planned", pos: "top" }}
on:click={() => handleStatusClick("PLANNED")}
use:tooltip={{ text: toUnderstandableStatus("PLANNED", isForGame), pos: "top" }}
>
<Icon i="calendar" />
</button>
<button
class={status && status !== "WATCHING" ? "not-active" : ""}
on:click={() => onChange("WATCHING")}
use:tooltip={{ text: "Watching", pos: "top" }}
on:click={() => handleStatusClick("WATCHING")}
use:tooltip={{ text: toUnderstandableStatus("WATCHING", isForGame), pos: "top" }}
>
<Icon i="clock" />
</button>
<button
class={status && status !== "FINISHED" ? "not-active" : ""}
on:click={() => onChange("FINISHED")}
use:tooltip={{ text: "Finished", pos: "top" }}
on:click={() => handleStatusClick("FINISHED")}
use:tooltip={{ text: toUnderstandableStatus("FINISHED", isForGame), pos: "top" }}
>
<Icon i="check" />
</button>
<button
class={status && status !== "HOLD" ? "not-active" : ""}
on:click={() => onChange("HOLD")}
use:tooltip={{ text: "On Hold", pos: "top" }}
on:click={() => handleStatusClick("HOLD")}
use:tooltip={{ text: toUnderstandableStatus("HOLD", isForGame), pos: "top" }}
>
<Icon i="pause" />
</button>
<button
class={status && status !== "DROPPED" ? "not-active" : ""}
on:click={() => onChange("DROPPED")}
use:tooltip={{ text: "Dropped", pos: "top" }}
on:click={() => handleStatusClick("DROPPED")}
use:tooltip={{ text: toUnderstandableStatus("DROPPED", isForGame), pos: "top" }}
>
<Icon i="thumb-down" />
</button>
@@ -55,6 +62,7 @@
button {
font-size: 10px;
padding: 5px 10px;
}
}
</style>
+31 -14
View File
@@ -4,41 +4,58 @@
export let users: PublicUser[];
</script>
<ul>
{#each users as user}
<li title={user.username}><a href="/lists/{user.id}/{user.username}">{user.username}</a></li>
{/each}
</ul>
<div>
<h2>Users</h2>
<ul>
{#each users as user}
<li title={user.username}>
<a href="/lists/{user.id}/{user.username}">
<span>{user.username}</span>
</a>
</li>
{/each}
</ul>
</div>
<style lang="scss">
div {
display: flex;
flex-flow: column;
margin: 5px 15px;
}
ul {
display: flex;
flex-flow: row;
flex-wrap: wrap;
gap: 10px;
margin: 5px 20px;
list-style: none;
justify-content: center;
overflow: auto;
padding: 15px;
li {
display: flex;
min-width: 50px;
max-width: 200px;
a {
flex-shrink: 1;
display: flex;
flex-flow: column;
gap: 8px;
width: 100%;
height: 100%;
padding: 3px 8px;
border-radius: 4px;
padding: 10px 20px;
border-radius: 8px;
background-color: $accent-color;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
transition:
background-color 150ms ease,
color 150ms ease;
span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&:hover {
color: $bg-color;
background-color: $accent-color-hover;
+211 -34
View File
@@ -1,23 +1,74 @@
<script lang="ts">
import { goto } from "$app/navigation";
import Icon from "@/lib/Icon.svelte";
import Poster from "@/lib/Poster.svelte";
import PosterList from "@/lib/PosterList.svelte";
import { activeFilters, activeSort } from "@/store";
import type { Watched } from "@/types";
import Poster from "@/lib/poster/Poster.svelte";
import PosterList from "@/lib/poster/PosterList.svelte";
import { activeFilters, activeSort, serverFeatures, userSettings } from "@/store";
import type { Watched, WatchedEpisode, WatchedSeason } from "@/types";
import GamePoster from "./poster/GamePoster.svelte";
import { get } from "svelte/store";
import { seasonAndEpToReadable } from "./util/helpers";
export let list: Watched[];
export let isPublicList: boolean = false;
$: sort = $activeSort;
$: filters = $activeFilters;
$: watched = list
.sort((a, b) => {
$: watched = list;
$: settings = $userSettings;
$: features = $serverFeatures;
/**
* Checks if content has been watched previously
* by analyzing the watched entrys activity (with
* the latest AI improvements added in of course.)
*/
function contentWatchedPreviously(w: Watched) {
let wp = false;
const relatedActivity = w.activity.filter(
(a) =>
a.type === "ADDED_WATCHED" ||
a.type === "IMPORTED_ADDED_WATCHED" ||
a.type === "IMPORTED_WATCHED" ||
a.type === "STATUS_CHANGED"
);
for (let i = 0; i < relatedActivity.length; i++) {
const ra = relatedActivity[i];
if (ra.type === "IMPORTED_ADDED_WATCHED") {
wp = true;
break;
} else if (ra.type === "ADDED_WATCHED" || ra.type === "IMPORTED_WATCHED") {
const data = JSON.parse(ra.data);
if (data?.status == "FINISHED") {
wp = true;
break;
}
} else if (ra.type === "STATUS_CHANGED") {
if (ra.data === "FINISHED") {
wp = true;
break;
}
}
}
return wp;
}
// Monsterous code for filters. Soz.
$: (watched, filters, sort), filt();
function filt() {
// Set watched to list and sort it.
watched = list.sort((a, b) => {
if (sort[0] === "DATEADDED" && sort[1] === "UP") {
return Date.parse(a.createdAt) - Date.parse(b.createdAt);
} else if (sort[0] === "ALPHA") {
if (sort[1] === "UP") return a.content.title.localeCompare(b.content.title);
else if (sort[1] === "DOWN") return b.content.title.localeCompare(a.content.title);
const atitle = a.content ? a.content.title : a.game ? a.game.name : "";
const btitle = b.content ? b.content.title : b.game ? b.game.name : "";
if (sort[1] === "UP") {
return atitle.localeCompare(btitle);
} else if (sort[1] === "DOWN") {
return btitle.localeCompare(atitle);
}
} else if (sort[0] === "LASTCHANGED") {
if (sort[1] === "UP") return Date.parse(a.updatedAt) - Date.parse(b.updatedAt);
else if (sort[1] === "DOWN") return Date.parse(b.updatedAt) - Date.parse(a.updatedAt);
@@ -27,41 +78,167 @@
}
// default DATEADDED DOWN
return Date.parse(b.createdAt) - Date.parse(a.createdAt);
})
.filter((w) => {
if (filters.status.length <= 0 && filters.type.length <= 0) return w;
if (filters.status.length > 0 && filters.type.length > 0) {
return (
filters.status.includes(w.status?.toLowerCase()) && filters.type.includes(w.content.type)
});
// If games type filter enabled, but games disabled on server, make sure we remove it from active filters.
if (!features.games) {
const af = get(activeFilters);
af.type = af.type?.filter((a) => a !== "game");
filters.type = filters.type.filter((f) => f !== "game");
}
// Now apply filters to watch list.
if (filters.status.length > 0 && filters.type.length > 0) {
// If status and type filters applied, combine both.
if (settings?.includePreviouslyWatched && filters.status.includes("finished")) {
watched = watched.filter(
(w) =>
(filters.status.includes(w.status?.toLowerCase()) || contentWatchedPreviously(w)) &&
filters.type.includes(w.content ? w.content.type : w.game ? "game" : "")
);
} else {
watched = watched.filter(
(w) =>
filters.status.includes(w.status?.toLowerCase()) &&
filters.type.includes(w.content ? w.content.type : w.game ? "game" : "")
);
}
if (filters.type.length > 0) {
return filters.type.includes(w.content.type);
} else if (filters.type.length > 0) {
// Only filter type
watched = watched.filter((w) =>
filters.type.includes(w.content ? w.content.type : w.game ? "game" : "")
);
} else if (filters.status.length > 0) {
// Only filter status
if (settings?.includePreviouslyWatched && filters.status.includes("finished")) {
watched = watched.filter(
(w) => filters.status.includes(w.status?.toLowerCase()) || contentWatchedPreviously(w)
);
} else {
watched = watched.filter((w) => filters.status.includes(w.status?.toLowerCase()));
}
if (filters.status.length > 0) {
return filters.status.includes(w.status?.toLowerCase());
}
}
// Get biggest season watching or biggest season watched.
// This could probably be simpler but -_-
function getLatestWatchedInTv(
ws: WatchedSeason[] | undefined,
we: WatchedEpisode[] | undefined
): string {
if ((!ws || ws.length <= 0) && (!we || we.length <= 0)) {
return "";
}
let biggestSeasonWatched = -1;
let biggestSeasonWatching = -1;
if (ws && ws.length > 0) {
for (let i = 0; i < ws.length; i++) {
const s = ws[i];
if (s.status === "WATCHING") {
if (s.seasonNumber > biggestSeasonWatching) {
biggestSeasonWatching = s.seasonNumber;
}
} else if (s.status === "FINISHED") {
if (s.seasonNumber > biggestSeasonWatched) {
biggestSeasonWatched = s.seasonNumber;
}
}
}
});
}
const season = biggestSeasonWatching >= 0 ? biggestSeasonWatching : biggestSeasonWatched;
// Look for biggest watched/watching episode in season if any.
// Does same thing as above.
let episode: WatchedEpisode | undefined;
if (we && we.length > 0) {
let biggestEpisodeWatched: WatchedEpisode | undefined;
let biggestEpisodeWatching: WatchedEpisode | undefined;
for (let i = 0; i < we.length; i++) {
const s = we[i];
if (season >= 0 && s.seasonNumber !== season) continue;
if (s.status === "WATCHING") {
if (!biggestEpisodeWatching) {
biggestEpisodeWatching = s;
}
if (
s.episodeNumber > biggestEpisodeWatching.episodeNumber ||
s.seasonNumber > biggestEpisodeWatching.seasonNumber
) {
biggestEpisodeWatching = s;
}
} else if (s.status === "FINISHED") {
if (!biggestEpisodeWatched) {
biggestEpisodeWatched = s;
}
if (
s.episodeNumber > biggestEpisodeWatched.episodeNumber ||
s.seasonNumber > biggestEpisodeWatched.seasonNumber
) {
biggestEpisodeWatched = s;
}
}
}
if (biggestEpisodeWatched || biggestEpisodeWatching) {
episode =
biggestEpisodeWatching !== undefined ? biggestEpisodeWatching : biggestEpisodeWatched;
}
}
if (season >= 0 && episode) {
return seasonAndEpToReadable(season, episode.episodeNumber);
} else if (season >= 0) {
return `Season ${season}`;
} else if (episode) {
return seasonAndEpToReadable(episode.seasonNumber, episode.episodeNumber);
} else {
return "";
}
}
</script>
<PosterList>
{#if watched?.length > 0}
{#each watched as w (w.id)}
<Poster
id={w.id}
media={{
id: w.content.tmdbId,
poster_path: w.content.poster_path,
title: w.content.title,
overview: w.content.overview,
media_type: w.content.type,
release_date: w.content.release_date,
first_air_date: w.content.first_air_date
}}
rating={w.rating}
status={w.status}
disableInteraction={isPublicList}
/>
{#if w.game}
<GamePoster
id={w.id}
rating={w.rating}
status={w.status}
media={{
id: w.game.igdbId,
coverId: w.game.coverId,
name: w.game.name,
summary: w.game.summary,
firstReleaseDate: w.game.releaseDate,
poster: w.game.poster
}}
disableInteraction={isPublicList}
extraDetails={{
dateAdded: w.createdAt,
dateModified: w.updatedAt
}}
/>
{:else if w.content}
<Poster
id={w.id}
media={{
id: w.content.tmdbId,
poster_path: w.content.poster_path,
title: w.content.title,
overview: w.content.overview,
media_type: w.content.type,
release_date: w.content.release_date,
first_air_date: w.content.first_air_date
}}
rating={w.rating}
status={w.status}
disableInteraction={isPublicList}
extraDetails={{
dateAdded: w.createdAt,
dateModified: w.updatedAt,
lastWatched: getLatestWatchedInTv(w.watchedSeasons, w.watchedEpisodes)
}}
/>
{/if}
{/each}
{:else}
<div class="empty-list">
+16 -3
View File
@@ -1,13 +1,19 @@
export interface ToolTipOptions {
text: string;
pos?: "left" | "top";
pos?: "left" | "top" | "bot";
/**
* Only show tooltip if this condition is true.
*/
condition?: boolean;
}
export default function tooltip(node: HTMLElement, opts: ToolTipOptions) {
const { text, pos = "left" } = opts;
let { text, pos = "left", condition = true } = opts;
const tooltip = document.getElementById("tooltip");
const show = () => {
if (!condition) return;
if (tooltip) {
tooltip.innerHTML = text;
const nrect = node.getBoundingClientRect();
@@ -15,10 +21,13 @@ export default function tooltip(node: HTMLElement, opts: ToolTipOptions) {
nrect.y += window.scrollY; // Add scrollY to node dom rect so tooltip shows correcting when page is scrolled down
if (pos === "left") {
tooltip.style.left = `${nrect.x - trect.width - 10}px`;
tooltip.style.top = `${nrect.y + trect.height / 2 - 10}px`;
tooltip.style.top = `${nrect.y + trect.height / 2 - 19.5}px`;
} else if (pos === "top") {
tooltip.style.left = `${nrect.x - trect.width / 2 + nrect.width / 2}px`;
tooltip.style.top = `${nrect.y - trect.height - 5}px`;
} else if (pos === "bot") {
tooltip.style.left = `${nrect.x - trect.width / 2 + nrect.width / 2}px`;
tooltip.style.top = `${nrect.y + trect.height + 5}px`;
}
tooltip.style.visibility = "visible";
}
@@ -37,6 +46,10 @@ export default function tooltip(node: HTMLElement, opts: ToolTipOptions) {
node.addEventListener("click", hide);
return {
update(opts: ToolTipOptions) {
text = opts.text;
condition = opts.condition ?? true;
},
destroy() {
node.removeEventListener("mouseover", show);
node.removeEventListener("touchstart", show);
+154
View File
@@ -0,0 +1,154 @@
<script lang="ts">
import type { ContentType, PublicUser, WatchedStatus } from "@/types";
import HorizontalList from "../HorizontalList.svelte";
import Modal from "../Modal.svelte";
import axios from "axios";
import Spinner from "../Spinner.svelte";
import Error from "../Error.svelte";
import Icon from "../Icon.svelte";
import { watchedStatuses } from "../util/helpers";
interface FollowThoughts {
followedUser: PublicUser;
thoughts: string;
status: WatchedStatus;
rating: number;
}
export let mediaType: ContentType | "game";
// The tmdbId for movie/tv, igdbId for games.
export let mediaId: number;
let modalShownFor: FollowThoughts | undefined = undefined;
async function getFollowsThoughts() {
return (await axios.get<FollowThoughts[]>(`/follow/thoughts/${mediaType}/${mediaId}`)).data;
}
</script>
{#await getFollowsThoughts()}
<Spinner />
{:then fts}
{#if fts?.length > 0}
<HorizontalList title="Followed Thoughts">
{#each fts as ft}
<button
class={["thoughts-card plain", ft.thoughts ? "" : "no-thoughts"].join(" ")}
on:click={() => (modalShownFor = ft)}
>
<div>
<h4 title={ft.followedUser.username}>{ft.followedUser.username}</h4>
{#if ft.status}
<div class="status-icon">
<Icon i={watchedStatuses[ft.status]} wh={22} />
</div>
{/if}
{#if ft.rating}
<span class="rating">
<span>*</span>
{ft.rating}
</span>
{/if}
</div>
<div class="thought">
{ft.thoughts || "No thoughts yet."}
</div>
</button>
{/each}
</HorizontalList>
{/if}
{:catch err}
<Error error={err} pretty="Failed to load followed thoughts!" />
{/await}
{#if modalShownFor}
<Modal
title={`${modalShownFor.followedUser.username}'s Thoughts`}
onClose={() => (modalShownFor = undefined)}
>
<span>{modalShownFor.thoughts}</span>
</Modal>
{/if}
<style lang="scss">
.thoughts-card {
display: flex;
flex-flow: column;
padding: 15px 20px;
background-color: $accent-color;
fill: $text-color;
border-radius: 10px;
min-width: 250px;
max-width: 250px;
font-size: 16px;
transition: background-color 200ms ease;
text-align: unset;
overflow: hidden;
cursor: pointer;
& > div {
display: flex;
flex-flow: row;
align-items: center;
gap: 8px;
margin-bottom: 3px;
h4 {
overflow: hidden;
text-overflow: ellipsis;
}
.rating {
display: flex;
align-items: start;
justify-content: center;
gap: 5px;
font-size: 18px;
font-weight: bolder;
span {
font-family: "Rampart One";
-webkit-text-stroke: 1px $text-color;
font-size: 32px;
line-height: 0.55;
margin-top: 7px;
}
}
.status-icon {
margin-left: auto;
margin-right: 2px;
width: 20px;
height: 20px;
min-width: 20px;
min-height: 20px;
}
}
.thought {
display: -webkit-box;
-webkit-line-clamp: 9;
-webkit-box-orient: vertical;
hyphens: auto;
overflow: hidden;
}
&.no-thoughts {
pointer-events: none;
.thought {
font-weight: lighter;
}
}
&:hover {
color: $bg-color;
fill: $bg-color;
background-color: $accent-color-hover;
.rating span {
-webkit-text-stroke: 1px $bg-color;
}
}
}
</style>
-4
View File
@@ -21,9 +21,5 @@
gap: 15px;
margin-top: auto;
padding-top: 10px;
& span {
margin-bottom: 2px;
}
}
</style>
+24
View File
@@ -0,0 +1,24 @@
<script lang="ts">
import type { ContentType, TMDBMovieSimilar, TMDBShowSimilar } from "@/types";
import HorizontalList from "../HorizontalList.svelte";
import { watchedList } from "@/store";
import { getWatchedDependedProps } from "@/lib/util/helpers";
import Poster from "../poster/Poster.svelte";
$: wList = $watchedList;
export let type: ContentType;
export let similar: TMDBShowSimilar | TMDBMovieSimilar;
</script>
{#if similar?.results?.length > 0}
<HorizontalList title="Similar">
{#each similar.results as content}
<Poster
media={{ ...content, media_type: type }}
{...getWatchedDependedProps(content.id, type, wList)}
small={true}
/>
{/each}
</HorizontalList>
{/if}
+13 -7
View File
@@ -1,17 +1,22 @@
<script lang="ts">
export let homepage: string;
export let homepage: string | undefined;
export let title: string;
export let releaseDate: string;
export let releaseYear: string | number;
export let voteAverage: number;
export let voteCount: number;
const vote = Math.round(voteAverage * 10) / 10;
// if voteAvg bigger than 10, it is out of 100, so no need to * by 10
const vote = Math.round(voteAverage > 10 ? voteAverage : voteAverage * 10) / 10;
</script>
<span class="title-container">
<span class="title">
<a href={homepage} target="_blank">{title}</a>
<span>{new Date(Date.parse(releaseDate)).getFullYear()}</span>
{#if homepage}
<a href={homepage} target="_blank">{title}</a>
{:else}
<span class="t">{title}</span>
{/if}
<span class="year">{releaseYear}</span>
</span>
<span class="rating" title={`TMDB Rating: ${vote} out of 10 (based on ${voteCount} votes)`}>
<span>*</span>
@@ -25,7 +30,8 @@
gap: 10px;
.title {
a {
a,
span.t {
color: white;
text-decoration: none;
font-size: 30px;
@@ -33,7 +39,7 @@
padding-right: 3px;
}
span {
span.year {
font-size: 20px;
color: rgba($color: #fff, $alpha: 0.7);
}
+1 -1
View File
@@ -49,7 +49,7 @@
width: 100dvw;
height: 100dvh;
background-color: rgba($color: #000000, $alpha: 0.5);
z-index: 9999999;
z-index: 99998;
.wrapper {
width: 100%;
+95
View File
@@ -0,0 +1,95 @@
<script lang="ts">
import { decode } from "blurhash";
import Icon from "../Icon.svelte";
import { baseURL } from "../util/api";
import { onMount } from "svelte";
import type { Image } from "@/types";
/**
* Users avatar.
*/
export let img: Image | undefined;
export let avatarDropped: ((ev: Event) => void) | undefined = undefined;
let bhCanvas: HTMLCanvasElement;
let avatarInput: HTMLInputElement;
function avatarLoaded() {
console.log("avatar loaded.. removing canvas");
bhCanvas?.remove();
}
$: {
if (img?.path && img?.blurHash && bhCanvas) {
const pixels = decode(img.blurHash, 80, 80);
const ctx = bhCanvas.getContext("2d");
if (ctx) {
const imageData = ctx.createImageData(80, 80);
imageData.data.set(pixels);
ctx.putImageData(imageData, 0, 0);
}
}
}
onMount(() => {
// Ignore rest if avatarDropped not defined
if (typeof avatarDropped !== "function") return;
avatarInput?.addEventListener("input", avatarDropped);
return () => {
avatarInput?.removeEventListener("input", avatarDropped!);
};
});
</script>
<div class={["img-ctr", typeof avatarDropped === "function" ? "" : "no-click"].join(" ")}>
{#if img?.path}
<canvas bind:this={bhCanvas} />
<img src={`${baseURL}/${img.path}`} alt="" on:load={avatarLoaded} />
{:else}
<Icon i="person" wh="100%" />
{/if}
{#if typeof avatarDropped === "function"}
<input bind:this={avatarInput} type="file" title="" accept=".jpg,.png,.gif,.webp" />
{/if}
</div>
<style lang="scss">
.img-ctr {
width: 80px;
min-width: 80px;
height: 80px;
min-height: 80px;
border-radius: 50%;
position: relative;
overflow: hidden;
fill: $text-color;
img {
width: 80px;
min-width: 80px;
height: 80px;
min-height: 80px;
object-fit: cover;
}
canvas {
position: absolute;
left: 0;
}
&:not(.no-click):hover {
opacity: 0.8;
}
input[type="file"] {
opacity: 0;
width: 100%;
height: 100%;
left: 0;
position: absolute;
cursor: pointer;
}
}
</style>
+88
View File
@@ -0,0 +1,88 @@
<script lang="ts">
import { wlDetailedView } from "@/store";
import type { WLDetailedViewOption } from "@/types";
import { get } from "svelte/store";
function detailClicked(d: WLDetailedViewOption) {
let dv = get(wlDetailedView);
if (dv.includes(d)) {
dv = dv.filter((a) => a !== d);
} else {
dv.push(d);
}
wlDetailedView.update((a) => (a = dv));
}
$: dve = $wlDetailedView;
</script>
<div class="menu">
<div class="inner">
<h4 class="norm sm-caps">Shown Details</h4>
<button
class={`plain ${dve?.includes("statusRating") ? "on" : ""}`}
on:click={() => detailClicked("statusRating")}
>
Status & Rating
</button>
<button
class={`plain ${dve?.includes("lastWatched") ? "on" : ""}`}
on:click={() => detailClicked("lastWatched")}
>
Watching Season
</button>
<button
class={`plain ${dve?.includes("dateAdded") ? "on" : ""}`}
on:click={() => detailClicked("dateAdded")}
>
Date Added
</button>
<button
class={`plain ${dve?.includes("dateModified") ? "on" : ""}`}
on:click={() => detailClicked("dateModified")}
>
Date Modified
</button>
</div>
</div>
<style lang="scss">
div.menu {
width: 200px;
right: 58px;
&:before {
left: 3px;
}
}
div.inner {
h4 {
margin-bottom: 8px;
&:not(:first-of-type) {
margin-top: 8px;
}
}
& > button {
text-transform: capitalize;
position: relative;
&.on::before {
content: "\2713";
}
&::before {
position: absolute;
top: 4px;
left: 12px;
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont;
font-size: 18px;
}
}
}
</style>
+148
View File
@@ -0,0 +1,148 @@
<script lang="ts">
import { activeFilters, serverFeatures } from "@/store";
import type { Filters } from "@/types";
import { get } from "svelte/store";
function filterClicked(type: keyof Filters, f: string) {
const af = get(activeFilters);
if (af[type]?.includes(f)) {
af[type] = af[type]?.filter((a) => a !== f);
} else {
af[type]?.push(f);
}
activeFilters.update((a) => (a = af));
}
$: filter = $activeFilters;
$: features = $serverFeatures;
</script>
<div class="menu">
<div class="inner">
<h4 class="norm sm-caps">type</h4>
<div class="type-filter">
<button
class={`${filter.type.includes("tv") ? "active" : ""}`}
on:click={() => filterClicked("type", "tv")}
>
SHOW
</button>
<button
class={`${filter.type.includes("movie") ? "active" : ""}`}
on:click={() => filterClicked("type", "movie")}
>
MOVIE
</button>
{#if features.games}
<button
class={`${filter.type.includes("game") ? "active" : ""}`}
on:click={() => filterClicked("type", "game")}
>
GAME
</button>
{/if}
</div>
<h4 class="norm sm-caps">status</h4>
<button
class={`plain ${filter.status.includes("planned") ? "on" : ""}`}
on:click={() => filterClicked("status", "planned")}
>
planned
</button>
<button
class={`plain ${filter.status.includes("watching") ? "on" : ""}`}
on:click={() => filterClicked("status", "watching")}
>
watching
{#if features.games}
(playing)
{/if}
</button>
<button
class={`plain ${filter.status.includes("finished") ? "on" : ""}`}
on:click={() => filterClicked("status", "finished")}
>
finished
{#if features.games}
(played)
{/if}
</button>
<button
class={`plain ${filter.status.includes("hold") ? "on" : ""}`}
on:click={() => filterClicked("status", "hold")}
>
on hold
</button>
<button
class={`plain ${filter.status.includes("dropped") ? "on" : ""}`}
on:click={() => filterClicked("status", "dropped")}
>
dropped
</button>
</div>
</div>
<style lang="scss">
div.menu {
width: 200px;
right: 35px;
&:before {
left: 23px;
}
}
div.inner {
h4 {
margin-bottom: 8px;
&:not(:first-of-type) {
margin-top: 8px;
}
}
& > button {
text-transform: capitalize;
position: relative;
&.on::before {
content: "\2713";
}
&::before {
position: absolute;
top: 4px;
left: 7.5px;
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont;
font-size: 18px;
}
}
.type-filter {
display: flex;
flex-flow: row;
width: 100%;
button {
border-radius: 0;
padding: 8px 0;
width: 100%;
&:first-of-type {
border-radius: 5px 0 0 5px;
}
&:not(:first-of-type) {
border-left: unset;
}
&:last-of-type {
border-radius: 0 5px 5px 0;
}
}
}
}
</style>
+54
View File
@@ -0,0 +1,54 @@
<script lang="ts">
import { follows } from "@/store";
export let close: () => {};
$: following = $follows;
</script>
<div class="menu">
<div>
{#if following?.length > 0}
<h4 class="norm sm-caps">following</h4>
<div class="list">
{#each following as f}
<a href="/lists/{f.followedUser.id}/{f.followedUser.username}" on:click={() => close()}>
{f.followedUser.username}
</a>
{/each}
</div>
{:else}
<span style="margin-top: 0;">You are not following anyone.</span>
{/if}
</div>
</div>
<style lang="scss">
div {
width: 180px;
&:before {
right: 53px;
}
h4 {
position: sticky;
top: -10px;
background-color: $bg-color;
}
.list {
list-style: none;
display: flex;
flex-flow: column;
width: 100%;
height: 100%;
a {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
}
</style>
+100
View File
@@ -0,0 +1,100 @@
<script lang="ts">
import { activeSort } from "@/store";
import { get } from "svelte/store";
function sortClicked(type: string, modeType: string = "UPDOWN") {
const af = get(activeSort);
let mode: string;
if (modeType === "UPDOWN") {
mode = "UP";
if (af[0] == type) {
if (af[1] === "UP") {
mode = "DOWN";
} else if (af[1] === "DOWN") {
mode = "";
}
}
} else if (modeType === "TOGGLE") {
mode = "ON";
if (af[0] == type) {
if (af[1] === "ON") {
mode = "OFF";
}
}
} else {
console.error("filterClicked() ran without a valid modeType:", modeType);
return;
}
activeSort.update((af) => (af = [type, mode]));
}
$: sort = $activeSort;
</script>
<div class="menu sort-menu">
<div>
<button
class={`plain ${sort[0] == "DATEADDED" ? sort[1].toLowerCase() : ""}`}
on:click={() => sortClicked("DATEADDED")}
>
Date Added
</button>
<button
class={`plain ${sort[0] == "LASTCHANGED" ? sort[1].toLowerCase() : ""}`}
on:click={() => sortClicked("LASTCHANGED")}
>
Last Changed
</button>
<button
class={`plain ${sort[0] == "RATING" ? sort[1].toLowerCase() : ""}`}
on:click={() => sortClicked("RATING")}
>
Rating
</button>
<button
class={`plain ${sort[0] == "ALPHA" ? sort[1].toLowerCase() : ""}`}
on:click={() => sortClicked("ALPHA")}
>
Alphabetical
</button>
</div>
</div>
<style lang="scss">
div {
width: 180px;
&:before {
left: 21px;
}
& > div {
& > button {
position: relative;
&.down::before {
content: "\2193";
}
&.up::before {
content: "\2191";
}
&.on::before {
content: "\2713";
}
&::before {
position: absolute;
top: 4px;
left: 12px;
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont;
font-size: 18px;
}
}
}
}
</style>
+412
View File
@@ -0,0 +1,412 @@
<script lang="ts">
import type { ExtraDetails, ExtraDetailsGame, Image, WatchedStatus } from "@/types";
import Icon from "../Icon.svelte";
import {
addClassToParent,
calculateTransformOrigin,
getOrdinalSuffix,
isTouch,
monthsShort,
watchedStatuses
} from "@/lib/util/helpers";
import { goto } from "$app/navigation";
import { baseURL, removeWatched, updatePlayed } from "../util/api";
import { notify } from "../util/notify";
import { onMount } from "svelte";
import PosterStatus from "./PosterStatus.svelte";
import PosterRating from "./PosterRating.svelte";
import { wlDetailedView } from "@/store";
import { page } from "$app/stores";
import { decode } from "blurhash";
export let id: number | undefined = undefined; // Watched list id
export let media: {
id: number;
coverId: string;
firstReleaseDate?: string | number;
name: string;
summary?: string;
poster?: Image;
};
export let rating: number | undefined = undefined;
export let status: WatchedStatus | undefined = undefined;
export let small = false;
export let disableInteraction = false;
export let hideButtons = false;
export let extraDetails: ExtraDetailsGame | undefined = undefined;
// When provided, default click handlers will instead run this callback.
export let onClick: (() => void) | undefined = undefined;
$: dve = $wlDetailedView;
// If poster is active (scaled up)
let posterActive = false;
let containerEl: HTMLDivElement;
let bhCanvas: HTMLCanvasElement;
const title = `${media.name}`;
const poster = media.poster?.path
? `${baseURL}/${media.poster.path}`
: `https://images.igdb.com/igdb/image/upload/t_cover_big/${media.coverId}.jpg`;
const link = media.id ? `/game/${media.id}` : undefined;
const dateStr = media.firstReleaseDate;
const year = dateStr ? new Date(dateStr).getFullYear() : undefined;
function handleStarClick(r: number) {
if (r == rating) return;
updatePlayed(media.id, undefined, r);
}
function handleStatusClick(type: WatchedStatus | "DELETE") {
if (type === "DELETE") {
if (!id) {
notify({ text: "Content has no watched list id, can't delete.", type: "error" });
return;
}
removeWatched(id);
return;
}
if (type == status) return;
updatePlayed(media.id, type);
}
function handleInnerKeyUp(e: KeyboardEvent) {
console.log(e.target);
if (e.key === "Enter" && (e.target as HTMLElement)?.id === "ilikemoviessueme") {
if (typeof onClick !== "undefined") {
onClick();
return;
}
if (link) {
goto(link);
}
}
}
function formatDate(e: number) {
if (!e) {
return "Unknown";
}
const d = new Date(e);
return `${d.getDate()}${getOrdinalSuffix(d.getDate())} ${monthsShort[d.getMonth()]} '${String(
d.getFullYear()
).substring(2, 4)}`;
}
$: {
if (media.poster?.path && media.poster?.blurHash && bhCanvas) {
const pixels = decode(media.poster.blurHash, 170, 256);
const ctx = bhCanvas.getContext("2d");
if (ctx) {
const imageData = ctx.createImageData(170, 256);
imageData.data.set(pixels);
ctx.putImageData(imageData, 0, 0);
}
}
}
onMount(() => {
if (small && containerEl) {
containerEl.classList.add("small");
}
});
</script>
<!-- HACK: disabled this issue for now, it should probably be fixed properly -->
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<li
on:mouseenter={(e) => {
if (!posterActive) calculateTransformOrigin(e);
if (!isTouch()) {
posterActive = true;
}
}}
on:focusin={(e) => {
if (!posterActive) calculateTransformOrigin(e);
}}
on:mouseleave={() => (posterActive = false)}
on:click={() => (posterActive = true)}
on:keypress={() => console.log("on kpress")}
class={`${posterActive ? "active " : ""}`}
>
<div
class={`container${!poster || (!media.coverId && !media.poster?.path) ? " details-shown" : ""}`}
bind:this={containerEl}
>
{#if poster && (media.coverId || media.poster?.path)}
{#if media?.poster?.blurHash}
<canvas width="170" height="256" bind:this={bhCanvas} class="img-loader" />
{:else}
<div class="img-loader"></div>
{/if}
<img
loading="lazy"
src={poster}
alt=""
on:load={(e) => {
addClassToParent(e, "img-loaded");
}}
on:error={(e) => {
addClassToParent(e, "details-shown");
}}
/>
{/if}
{#if $page.url?.pathname === "/" && extraDetails && dve && dve.length > 0}
<div class="extra-details">
<!--
This is one line because svelte leaves whitespace,
which causes the :empty css tag to not work.
Can be reverted when its possible to trim whitespace in svelte
OR when :empty tag is updated in browsers to new spec and counts whitespace as empty.
So ye this is probably gonna be one line until the end of time.
-->
<!-- prettier-ignore -->
<div>{#if dve.includes("dateAdded")}<span title="Date added to watch list"><i><Icon i="calendar" /></i><span>{formatDate(Date.parse(extraDetails.dateAdded))}</span></span>{/if}{#if dve.includes("dateModified")}<span title="Date last modified"><i><Icon i="pencil" wh={15} /></i><span>{formatDate(Date.parse(extraDetails.dateModified))}</span></span>{/if}{#if dve.includes("statusRating")}<span class="status-rating" title="Status and Rating"><i><Icon i="star" /></i><span>{rating}</span>{#if status}<i><Icon i={watchedStatuses[status]} wh={15} /></i>{/if}</span>{/if}</div>
</div>
{/if}
<div
on:click={() => {
if (typeof onClick !== "undefined") {
onClick();
return;
}
if (posterActive && link) goto(link);
}}
on:keyup={handleInnerKeyUp}
id="ilikemoviessueme"
class="inner"
role="button"
tabindex="0"
>
<h2>
{#if typeof onClick === "undefined" && link}
<a data-sveltekit-preload-data="tap" href={link}>
{title}
</a>
{:else}
{title}
{/if}
{#if year}
<time>{year}</time>
{/if}
</h2>
<span>{media.summary}</span>
{#if !hideButtons}
<div class="buttons">
<PosterRating {rating} {handleStarClick} {disableInteraction} />
<PosterStatus {status} {handleStatusClick} {disableInteraction} isForGame={true} />
</div>
{/if}
</div>
</div>
</li>
<style lang="scss">
li.active {
cursor: pointer;
}
.container {
display: flex;
flex-flow: column;
background-color: rgb(48, 45, 45);
overflow: hidden;
flex: 1 1;
border-radius: 5px;
width: 170px;
height: 100%;
min-height: 256.367px;
position: relative;
// aspect-ratio: 2/3;
transition: transform 150ms ease;
img {
width: 100%;
height: 100%;
}
&.img-loaded .img-loader,
&.details-shown .img-loader {
display: none;
}
.img-loader {
position: absolute;
width: 100%;
height: 100%;
}
div.img-loader {
background-color: gray;
background: linear-gradient(359deg, #5c5c5c, #2c2929, #2c2424);
background-size: 400% 400%;
animation: imgloader 4s ease infinite;
@keyframes imgloader {
0% {
background-position: 50% 0%;
}
50% {
background-position: 50% 100%;
}
100% {
background-position: 50% 0%;
}
}
}
canvas.img-loader {
animation: cimgloader 4s ease infinite;
@keyframes cimgloader {
0% {
opacity: 1;
}
50% {
opacity: 0.7;
}
100% {
opacity: 1;
}
}
}
.extra-details {
position: absolute;
bottom: 5px;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
font-size: 14px;
width: 160px;
color: white;
background-color: $poster-extra-detail-bg-color;
border-radius: 10px;
transition: opacity 100ms ease-out;
& > div {
padding: 8px 3px;
&:empty {
padding: 0px;
}
& > span {
display: flex;
flex-flow: row;
align-items: center;
gap: 8px;
height: 15px;
font-weight: bold;
&:not(:last-child) {
margin-bottom: 5px;
}
i {
display: flex;
width: 15px;
fill: white;
}
}
}
.status-rating i:last-of-type {
margin-left: auto;
}
}
.inner {
position: absolute;
opacity: 0;
display: flex;
flex-flow: column;
top: 0;
height: 100%;
width: 100%;
padding: 10px;
background-color: transparent;
transition: opacity 150ms cubic-bezier(0.19, 1, 0.22, 1);
h2 {
font-family:
sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont;
font-size: 18px;
color: white;
word-wrap: break-word;
a {
color: white;
}
time {
font-size: 14px;
font-weight: 400;
color: rgba(255, 255, 255, 0.7);
}
}
span {
color: white;
margin: 5px 0 5px 0;
font-size: 9px;
display: -webkit-box;
-webkit-line-clamp: 5;
-webkit-box-orient: vertical;
hyphens: auto;
overflow: hidden;
}
.buttons {
display: flex;
flex-flow: row;
margin-top: auto;
gap: 10px;
height: 35px;
}
}
&.small .inner span {
font-size: 11px;
}
&:hover,
&:focus-within {
transform: scale(1.3);
z-index: 99;
.extra-details {
opacity: 0;
}
}
&.small:hover,
&.small:focus-within {
transform: scale(1.1);
}
&:hover,
&:focus-within,
&:global(.details-shown) {
img {
filter: blur(4px) grayscale(80%);
// This makes the background very dark,
// but atleast the text is visible.. may want to change later.
mix-blend-mode: multiply;
}
.inner {
color: white;
opacity: 1;
}
}
}
</style>
@@ -12,6 +12,8 @@
const link = id ? `/person/${id}` : undefined;
</script>
<!-- Quick fix to ignore error, should be fixed -->
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<li
on:mouseenter={(e) => calculateTransformOrigin(e)}
on:focusin={(e) => calculateTransformOrigin(e)}
@@ -89,7 +91,7 @@
background-size: 400% 400%;
animation: imgloader 4s ease infinite;
@-webkit-keyframes imgloader {
@keyframes imgloader {
0% {
background-position: 50% 0%;
}
@@ -1,17 +1,23 @@
<script lang="ts">
import type { MediaType, WatchedStatus } from "@/types";
import Icon from "./Icon.svelte";
import type { ExtraDetails, MediaType, WLDetailedViewOption, WatchedStatus } from "@/types";
import Icon from "../Icon.svelte";
import {
addClassToParent,
calculateTransformOrigin,
getOrdinalSuffix,
isTouch,
monthsShort,
watchedStatuses
} from "@/lib/util/helpers";
import { goto } from "$app/navigation";
import tooltip from "./actions/tooltip";
import { removeWatched, updateWatched } from "./util/api";
import { notify } from "./util/notify";
import tooltip from "../actions/tooltip";
import { baseURL, removeWatched, updateWatched } from "../util/api";
import { notify } from "../util/notify";
import { onMount } from "svelte";
import PosterStatus from "./PosterStatus.svelte";
import PosterRating from "./PosterRating.svelte";
import { wlDetailedView } from "@/store";
import { page } from "$app/stores";
export let id: number | undefined = undefined; // Watched list id
export let media: {
@@ -29,20 +35,24 @@
export let small = false;
export let disableInteraction = false;
export let hideButtons = false;
export let extraDetails: ExtraDetails | undefined = undefined;
// When provided, default click handlers will instead run this callback.
export let onClick: (() => void) | undefined = undefined;
$: dve = $wlDetailedView;
// If poster is active (scaled up)
let posterActive = false;
// If ratings are shown
let ratingsShown = false;
// If statuses are shown
let statusesShown = false;
let containerEl: HTMLDivElement;
const title = media.title || media.name;
const poster = `https://image.tmdb.org/t/p/w500${media.poster_path}`;
// For now, if the content is on watched list, we can assume we have a local
// cached image. Could be improved, since we could have a cached image for
// show not on someone elses watched list.
const poster = id
? `${baseURL}/img${media.poster_path}`
: `https://image.tmdb.org/t/p/w500${media.poster_path}`;
const link = media.id ? `/${media.media_type}/${media.id}` : undefined;
const dateStr = media.release_date || media.first_air_date;
const year = dateStr ? new Date(dateStr).getFullYear() : undefined;
@@ -50,7 +60,6 @@
function handleStarClick(r: number) {
if (r == rating) return;
updateWatched(media.id, media.media_type, undefined, r);
ratingsShown = false;
}
function handleStatusClick(type: WatchedStatus | "DELETE") {
@@ -62,6 +71,7 @@
removeWatched(id);
return;
}
if (type == status) return;
updateWatched(media.id, media.media_type, type);
}
@@ -78,6 +88,16 @@
}
}
function formatDate(e: number) {
if (!e) {
return "Unknown";
}
const d = new Date(e);
return `${d.getDate()}${getOrdinalSuffix(d.getDate())} ${monthsShort[d.getMonth()]} '${String(
d.getFullYear()
).substring(2, 4)}`;
}
onMount(() => {
if (small && containerEl) {
containerEl.classList.add("small");
@@ -100,10 +120,13 @@
on:mouseleave={() => (posterActive = false)}
on:click={() => (posterActive = true)}
on:keypress={() => console.log("on kpress")}
class={`${posterActive ? "active " : ""}${disableInteraction ? "interaction-disabled" : ""}`}
class={`${posterActive ? "active " : ""}`}
>
<div class={`container${!poster ? " details-shown" : ""}`} bind:this={containerEl}>
{#if poster}
<div
class={`container${!poster || !media.poster_path ? " details-shown" : ""}`}
bind:this={containerEl}
>
{#if poster && media.poster_path}
<div class="img-loader" />
<img
loading="lazy"
@@ -117,6 +140,19 @@
}}
/>
{/if}
{#if $page.url?.pathname === "/" && extraDetails && dve && dve.length > 0}
<div class="extra-details">
<!--
This is one line because svelte leaves whitespace,
which causes the :empty css tag to not work.
Can be reverted when its possible to trim whitespace in svelte
OR when :empty tag is updated in browsers to new spec and counts whitespace as empty.
So ye this is probably gonna be one line until the end of time.
-->
<!-- prettier-ignore -->
<div>{#if dve.includes("dateAdded")}<span title="Date added to watch list"><i><Icon i="calendar" /></i><span>{formatDate(Date.parse(extraDetails.dateAdded))}</span></span>{/if}{#if dve.includes("dateModified")}<span title="Date last modified"><i><Icon i="pencil" wh={15} /></i><span>{formatDate(Date.parse(extraDetails.dateModified))}</span></span>{/if}{#if extraDetails.lastWatched && dve.includes("lastWatched")}<span title="Latest season watched"><i><Icon i="play" wh={15} /></i><span>{extraDetails.lastWatched}</span></span>{/if}{#if dve.includes("statusRating")}<span class="status-rating" title="Status and Rating"><i><Icon i="star" /></i><span>{rating}</span>{#if status}<i><Icon i={watchedStatuses[status]} wh={15} /></i>{/if}</span>{/if}</div>
</div>
{/if}
<div
on:click={() => {
if (typeof onClick !== "undefined") {
@@ -147,76 +183,8 @@
{#if !hideButtons}
<div class="buttons">
<button
class="rating"
on:click={(ev) => {
ev.stopPropagation();
ratingsShown = !ratingsShown;
}}
on:mouseleave={(ev) => {
ratingsShown = false;
ev.currentTarget.blur();
}}
>
<span>*</span>
<span class={!rating && disableInteraction ? "unrated-text" : ""}>
{rating ? rating : disableInteraction ? "Unrated" : "Rate"}
</span>
{#if ratingsShown}
<div>
{#each [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] as v}
<button
class="plain{rating === v ? ' active' : ''}"
on:click={(ev) => {
ev.stopPropagation();
handleStarClick(v);
}}
>
{v}
</button>
{/each}
</div>
{/if}
</button>
<button
class="status"
on:click={(ev) => {
ev.stopPropagation();
statusesShown = !statusesShown;
}}
on:mouseleave={(ev) => {
statusesShown = false;
ev.currentTarget.blur();
}}
>
{#if status}
<Icon i={watchedStatuses[status]} />
{:else}
<span class="no-icon">+</span>
{/if}
{#if statusesShown}
<div>
{#each Object.entries(watchedStatuses) as [statusName, icon]}
<button
class="plain{status && status !== statusName ? ' not-active' : ''}"
on:click={() => handleStatusClick(statusName)}
use:tooltip={{ text: statusName }}
>
<Icon i={icon} />
</button>
{/each}
{#if status}
<button
class="plain not-active"
on:click={() => handleStatusClick("DELETE")}
use:tooltip={{ text: "Delete" }}
>
<Icon i="trash" />
</button>
{/if}
</div>
{/if}
</button>
<PosterRating {rating} {handleStarClick} {disableInteraction} />
<PosterStatus {status} {handleStatusClick} {disableInteraction} />
</div>
{/if}
</div>
@@ -228,27 +196,6 @@
cursor: pointer;
}
li.interaction-disabled {
button {
pointer-events: none;
cursor: default;
background-color: transparent;
border: unset;
fill: white;
color: white;
span {
color: white !important;
}
.unrated-text {
display: flex;
align-items: center;
font-size: 15px !important;
}
}
}
.container {
display: flex;
flex-flow: column;
@@ -295,6 +242,54 @@
}
}
.extra-details {
position: absolute;
bottom: 5px;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
font-size: 14px;
width: 160px;
color: white;
background-color: $poster-extra-detail-bg-color;
border-radius: 10px;
transition: opacity 100ms ease-out;
& > div {
padding: 8px 3px;
&:empty {
padding: 0px;
}
& > span {
display: flex;
flex-flow: row;
align-items: center;
gap: 8px;
height: 15px;
font-weight: bold;
&:not(:last-child) {
margin-bottom: 5px;
}
i {
display: flex;
width: 15px;
fill: white;
}
}
}
.status-rating i:last-of-type {
margin-left: auto;
}
}
.inner {
position: absolute;
opacity: 0;
@@ -345,95 +340,6 @@
margin-top: auto;
gap: 10px;
height: 35px;
button {
padding: 3px;
position: relative;
font-family: "Rampart One";
/** Rating */
&.rating {
span {
&:first-child {
color: $text-color;
font-size: 39px;
letter-spacing: 10px;
line-height: 52px;
height: 42px;
}
&:nth-child(2) {
color: $text-color;
font-size: 22px;
height: 35px; // quick fix to make the rating num look centered - text-stroke makes it look not centered
}
}
&:hover span,
&:focus-visible span {
color: gold;
}
div button {
font-size: 20px;
}
}
/** Status */
&.status {
width: 40%;
.no-icon {
color: $text-color;
font-size: 30px;
height: 52px;
}
&:hover,
&:hover .no-icon,
&:focus-visible .no-icon {
color: white;
fill: white;
}
}
div {
display: flex;
flex-flow: column;
position: absolute;
width: 100%;
height: 200px;
background-color: $bg-color;
top: calc(-100% - 170px);
list-style: none;
border-radius: 4px 4px 0 0;
overflow: auto;
scrollbar-width: thin;
button {
width: 100%;
color: $text-color;
fill: $text-color;
-webkit-text-stroke: 0.5px $text-color;
& :global(svg) {
width: 100%;
padding: 0 2px;
}
&:hover,
&:focus-visible {
background-color: rgb(100, 100, 100, 0.25);
}
}
}
&:hover,
&:focus-visible {
background-color: black;
border-color: black;
}
}
}
}
@@ -445,6 +351,10 @@
&:focus-within {
transform: scale(1.3);
z-index: 99;
.extra-details {
opacity: 0;
}
}
&.small:hover,

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