Compare commits

...

346 Commits

Author SHA1 Message Date
IRHM fa34f1ead1 v4.2.1 CHANGELOG 2026-08-04 02:01:51 +01:00
IRHM cefed53c7f v4.2.1 CHANGELOG 2026-08-04 02:00:29 +01:00
IRHM 0d8b050615 v4.2.1 2026-08-04 01:36:44 +01:00
IRHM 63988f833f v4.2.1-dev1 2026-08-04 01:12:56 +01:00
IRHM e391d5dc69 (fix) ProvidersList: Duplicate key error. 2026-08-04 00:11:20 +00:00
IRHM cba3d11f64 v4.2.0 CHANGELOG 2026-08-03 09:02:17 +01:00
IRHM 5d95aa4b41 v4.2.0 2026-08-03 08:39:05 +01:00
IRHM 41dff624bb README: Add link to FEATURES document. 2026-08-03 07:40:44 +01:00
IRHM 39a77b4428 v4.2.0-dev2 2026-08-03 07:05:06 +01:00
IRHM 9b74728afb SeasonsListEpisode: Fix info box alignment
Also fixed the episode rating text getting cut off at certain dimensions by enforcing its minimum width at which a double digit rating is still visible (eg 7.1)
2026-08-03 07:04:06 +01:00
IRHM 113ccbbbfd v4.2.0-dev1 2026-08-03 03:30:47 +01:00
IRHM 87033f423d upgrade server dependencies 2026-08-03 02:25:54 +00:00
IRHM 3a52a9a592 Update FEATURES.md 2026-08-03 01:14:02 +00:00
IRHM 9b39617650 search: Add filters help button opening a modal with examples 2026-08-03 01:14:02 +00:00
IRHM dd1503846d igdb: SearchOptions: Add note comment 2026-08-03 01:14:02 +00:00
IRHM 92edb75de9 Games: Support searching with Year or FirstYear filters 2026-08-03 01:14:02 +00:00
IRHM dc2b9a1a63 tmdb: Remove olf *WithWatched structs
These are not used and are a remnant from before the server restructure (it was another solution i was cooking up, but didn't end up going with).
2026-08-03 01:14:02 +00:00
IRHM 7b65c8af0f tmdb: Strip TMDB prefix from all struct names
This prefix is a remnant from when the structs where in the "main" package (from before the server refactor).
2026-08-03 01:14:02 +00:00
IRHM cf3168d59c content: GetOrCacheContent: Use Movie/ShowDetails funcs instead of manually using APIRequest func
Because this makes more sense to reuse the logic and also because APIRequest is now only locally accessible in the tmdb package, to stop me from using anywhere else, should always use an exposed function from the package so it can be reused.
2026-08-03 01:14:02 +00:00
IRHM fb1017f551 tmdb: Make req local, Movie/Show details funcs now accept struct options 2026-08-03 01:14:02 +00:00
IRHM bff354fcc3 organize tmdb api request logic into tmdb package AND support inline search filters 2026-08-03 01:14:02 +00:00
IRHM 0be6fdb346 content: Improve search function formatting 2026-08-03 01:14:02 +00:00
IRHM a73651808e Update CHANGELOG.md 2026-08-01 03:48:44 +00:00
IRHM 9da0913d48 Add Status & ReleaseDateLast to Media, show end year for tv shows 2026-08-01 03:48:44 +00:00
IRHM 0a38171836 doc: installation/for-development: update outdated commands
we switched to using make a while ago, forgot to update this doc
2026-07-30 22:50:38 +01:00
IRHM d009528388 Update CHANGELOG.md 2026-07-30 21:33:41 +00:00
IRHM cd34ecba61 changelog: correct the new stuff and put it under new instead of changed 2026-07-30 21:33:41 +00:00
IRHM 769e30c9c7 import: Support rating column decimals 2026-07-30 21:33:41 +00:00
IRHM ba961bf5c3 Update CHANGELOG.md 2026-07-30 21:33:41 +00:00
IRHM efddcaed07 doc: importing/text-file: Update to show support for providing a rating 2026-07-30 21:33:41 +00:00
IRHM 76fdbe3cd0 import: Remove "Try refreshing" text from the successfully imported notification
It is no longer very pertinent since all watched data isn't stored in the browser. When we redirect the user to their list, fresh data is already fetched.
2026-07-30 21:33:41 +00:00
IRHM f4b7f66104 import->text list: Support providing a rating in square brackets 2026-07-30 21:33:41 +00:00
IRHM 12ceb13bcb import: Add rating column (validated to be 0-10) and set import item state to FAILED if request fails 2026-07-30 21:33:41 +00:00
IRHM 5a5ae0ad83 Show Aired Date for episodes. 2026-07-30 03:46:29 +00:00
IRHM 05e24e42c6 Show air date with toRelativeDate, hide star when unaired and no votes, make airDate logic a bit more robust 2026-07-30 03:32:32 +00:00
mkarpats e5d93fd8a2 feat: Display air date for unaired episodes
- Show air date for episodes that are in the future.
2026-07-30 03:32:32 +00:00
IRHM bf5d44f404 fix lock closed color dark theme 2026-07-30 02:42:35 +00:00
IRHM 5abbb47fbf only show PosterImage in media pages if we have a extPosterPath 2026-07-30 02:42:35 +00:00
IRHM 40b54c1065 Fix crew each to use unique key 2026-07-30 02:42:35 +00:00
IRHM 3967a3f13f api: Update prod baseURL to be absolute
Only an absolute baseURL will work with our new Reqer class.
2026-07-30 02:42:35 +00:00
IRHM 1f4b917661 docker-compose.dev.yml: Change container name and port to be different than prod container test 2026-07-30 02:42:35 +00:00
IRHM 2202b11e39 fix all linting issues and upgrade the rest of devDependencies
now i should probably test the whole app waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaauuuuuuuuuugugghghghghghghghghg
2026-07-30 02:42:35 +00:00
IRHM d32a1ecb39 format files (new prettier version changes some formatting)
I'm upset that the textarea closing tag is being put on the same line instead of new lined, but I couldn't figure out what changed, so I'll cry in silence and hope it gets fixed one day.
2026-07-30 02:42:35 +00:00
IRHM 347113be68 ESLint: Migrate to flat config 2026-07-30 02:42:35 +00:00
IRHM 68150b38ec fix lint script - only look in src folder 2026-07-30 02:42:35 +00:00
IRHM dc9e7e9309 test-pr-server: Correct go-version-file path? 2026-07-30 02:42:35 +00:00
IRHM 6457146214 Workflows: test-pr-server: Set go-version-file for setup-go action. 2026-07-30 02:42:35 +00:00
IRHM baba8c8c60 Dockerfile: Upgrade node steps to use version 24. 2026-07-30 02:42:35 +00:00
IRHM 31ddcacf47 Workflows: Upgrade action versions and use node 24. 2026-07-30 02:42:35 +00:00
IRHM be94f1d2b7 Replace axios with native Fetch API & some maintenance 2026-07-30 02:42:35 +00:00
IRHM d7449642ba v4.1.1 changelog 2026-07-26 03:26:00 +01:00
IRHM dbc8b74893 v4.1.1 2026-07-26 02:47:48 +01:00
IRHM 9d5e489675 plex: Stop after 10 redirects
Since the default CheckRedirect has been replaced with ours, we won't get the default protection of erroring after 10 redirects, so i've copied that back in from the std implementation
2026-07-26 01:27:30 +00:00
tonghuaroot 4e6e71687b fix(plex): strip X-Plex-Token on cross-host redirect
The Plex integration used bare http.Client values with no CheckRedirect
policy, so they followed redirects automatically. net/http strips the
standard sensitive headers on a cross-host redirect but not custom-named
headers, so the Plex token carried in X-Plex-Token was forwarded verbatim
to any host the configured PLEX_HOST redirected to, disclosing the
credential.

Route all Plex outbound calls through a shared client whose CheckRedirect
policy deletes X-Plex-Token when the redirect target host differs from the
original request host. Includes a regression test.

Signed-off-by: tonghuaroot <tonghuaroot@gmail.com>
2026-07-26 01:27:30 +00:00
IRHM 8c8d604bc6 v4.1.1-dev1 2026-07-26 01:34:45 +01:00
IRHM 39b82335eb Plex: Add Accept: "application/json" header so plex returns json again
I think the plex api default used to be JSON, which is why it worked, but I guess they changed it to XML. Adding this header asks for JSON response again.
2026-07-26 00:33:23 +00:00
IRHM 217be719e4 Revert "README: Open demo/track links in new tab"
This reverts commit 0da32164a3.
2026-07-21 09:38:20 +01:00
IRHM 0da32164a3 README: Open demo/track links in new tab 2026-07-21 09:36:49 +01:00
IRHM db72d05d79 README: Add instructions to demo instance login
I'm sure the extra clarity may be appreciated
2026-07-21 09:31:49 +01:00
IRHM 88a7542064 update readme and contributing text 2026-07-21 09:20:33 +01:00
IRHM 19c773976d CHANGELOG: v4.1.0 2026-07-19 14:40:44 +01:00
IRHM a16c769273 v4.1.0 2026-07-19 14:15:42 +01:00
IRHM f022dc702c v4.1.0-dev1 2026-07-18 13:05:20 +01:00
IRHM c2f72dbd9c Remove dependabot.yml. 2026-07-18 12:58:30 +01:00
IRHM d777630e84 CHANGELOG: Add credit to SeasonsListEpisode change 2026-07-18 12:51:03 +01:00
IRHM f5bfa29877 SeasonsListEpisode: Show spoilers when status is set to FINISHED and allow changing status while spoilers are hidden
Based on PR by goestav: https://github.com/sbondCo/Watcharr/pull/1055

Different in these ways:
- Using $derived here for `ws` variable
- Using z-index to allow status button to be clicked while spoilers are hidden
- Don't hide spoilers again (if they are shown) when episode is deleted

Also refactored `handleStatusClick()` a bit by removing the redundant `ws` lookup (it can now just use `we` set at the top of the component).

Co-Authored-By: Goestav <27970303+goestav@users.noreply.github.com>
2026-07-18 11:48:52 +00:00
IRHM 9b64932af1 watched_refine: refineFilterStatus: Remove parenthesis around WHERE query.
It looks like GORM already adds the parenthesis around this for us in the final query, so ours was unnecessary
2026-07-18 09:50:53 +00:00
IRHM bf0594c1e8 Fix Include Previously Watched regression and update profile stats to not use the setting
Index also added to

Fixes https://github.com/sbondCo/Watcharr/issues/1027
2026-07-18 09:50:53 +00:00
IRHM fee82df59d CHANGELOG: v4.0.1 2026-07-16 10:29:15 +01:00
IRHM 61382de4d2 v4.0.1 2026-07-16 10:07:58 +01:00
IRHM e65ba9d1d9 v4.0.1-dev1 2026-07-16 09:40:47 +01:00
IRHM 6654d85448 testing workflow - no longer testing workflow cuz it works now yippee 2026-07-16 08:36:22 +00:00
IRHM eabdb47cfa testing workflow - gofmt 2026-07-16 08:36:22 +00:00
IRHM 643ca0fd38 testing workflow - go test 2026-07-16 08:36:22 +00:00
IRHM a08b19675a test-pr-server.yml: Set working directory to server to fix commands not running against our go code 2026-07-16 08:36:22 +00:00
IRHM 38fba0ac10 Watched: Also log the error on the "failed to restore existing watched entry" log. 2026-07-16 08:36:22 +00:00
IRHM f23552c170 Use an svg for the favicon and change its fill to white for dark themed browsers. 2026-07-16 08:36:22 +00:00
IRHM 448fdd9df3 SpinnerTiny: Fix circle animation appearing to skip 2026-07-16 08:36:22 +00:00
IRHM ca428327e2 Move notifications to its own component. 2026-07-16 08:36:22 +00:00
IRHM f7cca74a41 SpinnerTiny: Use svg instead of the css border trick to create the spinner fixing it looking more like a horseshoe than a circle on different browser scales (also added animation on the svg circle).
also: Fix color being wrong on dark theme.

svg fix inspired by mui :)
2026-07-16 08:36:22 +00:00
IRHM 86286b967f workflows/test-pr-server: Add test step 2026-07-16 08:36:22 +00:00
IRHM 8243838bfb Update CHANGELOG.md 2026-07-11 03:55:10 +01:00
IRHM 5bebb754ed v4.0.0 2026-07-11 03:28:19 +01:00
IRHM c8920c911d migrate: Change debug log to info
and add an info migration not been applied before log.
2026-07-11 03:27:31 +01:00
IRHM dd0bae137f migrations: Remove comment TODO
Should be okay with them there.
2026-07-10 22:08:04 +01:00
IRHM d5baee0df7 v4.0.0-dev1 2026-07-10 21:42:03 +01:00
IRHM 764a25be6c Changelog: Add youtube-nocookie change 2026-07-10 21:36:15 +01:00
IRHM c019162994 Update CHANGELOG.md 2026-07-10 20:30:23 +00:00
IRHM 05f9813be8 image: validate: Don't log whole image config 2026-07-10 20:30:23 +00:00
IRHM f285d1a8f4 image: Move new download/save methods to a Saver struct 2026-07-10 20:30:23 +00:00
IRHM 4cc9bd3edb make image module way more robust
- Create a better (more) re-usable flow for downloading images to disk and inserting images into the db
- Validate images properly by reading them fully and using DecodeConfig
- Fix some security issues by re-encoding images
- Always outputs one format `jpeg`, which keeps everything "normalized" and adds compression to images (mainly user uploads which might be big).
2026-07-10 20:30:23 +00:00
IRHM 34f7f54e72 fix: Add headers to requests for files in img/ folder to prevent stored xss attacks
A modern browser will see these headers and protect the user by not allowing any code to run.
2026-07-10 20:30:23 +00:00
hilmer 3fe2d2b155 Fix(ViewTrailerButton): Use youtube-nocookie.com 2026-07-05 17:49:12 +00:00
IRHM 3461a4ec74 db: Add duration to log for optimization queries 2026-07-05 17:39:42 +00:00
IRHM 475c9b6ab4 CHANGELOG: Add link for unreleased 2026-07-05 17:39:42 +00:00
IRHM 325666c30d CHANGELOG: Add credit to unreleased change 2026-07-05 17:39:42 +00:00
IRHM 92816b02a0 doc: Backup: Also note that watcharr.db-wal should be backed up along with the .db file since v3. 2026-07-05 17:39:42 +00:00
IRHM 363c648964 changelog/README: Fix the link to changelog... 2026-07-05 17:39:42 +00:00
IRHM 2f929e99d5 Move all old github release notes into new CHANGELOG
Having the changelog file is one more step to no vendor lock-in. It's also more easily searched through and in a standard format everyone is probably used to.

Just so you know, this was painful and I wanted nothing but death for myself throughout this whole process.
2026-07-05 17:39:42 +00:00
IRHM f14be89680 Update CHANGELOG.md 2026-07-05 17:39:42 +00:00
IRHM ecd027f603 Create CHANGELOG.md 2026-07-05 17:39:42 +00:00
IRHM f80f237143 plays support for frontend
soz did this so long ago
2026-07-05 17:39:42 +00:00
IRHM dbfc354353 GetWatchedPage: Put filter scope on one line 2026-07-05 17:39:42 +00:00
IRHM 28a6d85672 Update watched.go 2026-07-05 17:39:42 +00:00
IRHM b861cfcec3 separate watched_refine funcs 2026-07-05 17:39:42 +00:00
IRHM 08e0021535 refineSort: Filter by user_id AND use count_as_play instead of doing text search for LastFinished sort 2026-07-05 17:39:42 +00:00
IRHM b3bf111f82 Replace Fatal log with more direct Error and os.Exit 2026-07-05 17:39:42 +00:00
IRHM 23ed5ffca8 Add separator log for log files so a new server starting is easier to find/notice 2026-07-05 17:39:42 +00:00
IRHM cc9f246c9a update watched_util_test with new model name 2026-07-05 17:39:42 +00:00
IRHM 75d75248e1 Remove AddActivity endpoint
it isn't used and is only a way for others to potentially add activity to other peoples watched entries since user owning the watched entry is not validated on the endpoint.

Co-Authored-By: Dreddy <24421368+dredsen@users.noreply.github.com>
2026-07-05 17:39:42 +00:00
IRHM c34a0878b2 New Deref helper for using pointers safely with default values 2026-07-05 17:39:42 +00:00
IRHM 681212566b activity: Change AddRequest name to Props. Add CountAsPlay param to AddActivity()
and some formatting
2026-07-05 17:39:42 +00:00
IRHM df37de00e1 manually validate WatchedUpdateRequest struct and add plays count to watcheddto 2026-07-05 17:39:42 +00:00
IRHM fc900d8e93 db: Optimize when opening and new optimize task ran every 24hr server is running to keep it running best 2026-07-05 17:39:42 +00:00
IRHM 57ce143ebe migrate db to WAL journal_mode 2026-07-05 17:39:42 +00:00
IRHM 3eb2810a31 db: Configure sqlite connection when open. Currently set synchronous to FULL
(did this work a long time ago now so commits are in weird order)
2026-07-05 17:39:42 +00:00
IRHM b8598ba404 Remove deleted_at columns for watched episode/season tables
We don't use these columns and won't in the foreseeable future. Query speed seems be to be faster now that we aren't filtering for the extra deleted_at cols.
2026-07-05 17:39:42 +00:00
IRHM 579428d86b migrate: Backfill media plays data from existing activity 2026-07-05 17:39:42 +00:00
IRHM 4da8730b6f Activity: Add CountAsPlay property 2026-07-05 17:39:42 +00:00
IRHM e980a1f70e db: Create custom migrations support 2026-07-05 17:39:42 +00:00
IRHM f73105e9c7 v3.0.2-dev1 2026-03-19 01:30:26 +00:00
IRHM 755b08b746 Nav: Fix logo link being clickable through whole left side of nav
The logo link on nav to go to home page was clickable through the whole left side of the nav, now it is only clickable over the actual link text.
2026-03-19 01:29:16 +00:00
IRHM 5e412f67b9 Status: Fix button sizes now that icons have a width/height set 2026-03-19 01:29:16 +00:00
IRHM 4ee38a2625 Icon: Fix status icons not having width and height properties not set 2026-03-19 01:29:16 +00:00
IRHM dc6ead0fb3 fix safari: Shrikhand font
The font-style in the @font-face declaration was set to italic, but we use the font without using that style, which Safari is very strict about and wont match.
2026-03-19 01:29:16 +00:00
IRHM a12faf8e72 v3.0.1 2026-03-09 11:14:19 +00:00
IRHM eb1b8b86c7 v3.0.1-dev2 2026-03-09 10:48:51 +00:00
IRHM dca1acbbd8 Modal: Specify color
Fixes WatchedDeleteModal for light theme because of inherited css from content pages and this is the easiest fix for now
2026-03-09 10:47:24 +00:00
IRHM 664caa6ba2 v3.0.1-dev1 2026-03-09 09:14:26 +00:00
IRHM a425abcdf2 Poster: Grayscale poster if deleted from watched list through poster button
After deleting from your watched list through the poster, we didn't have any real indication to the user that this poster is for a deleted entry (other than the notification and removing the watched status from poster).

Now we grayscale and blur the poster slightly so it's more obvious that it is a deleted entry and won't be there next time you refresh.
2026-03-09 09:12:06 +00:00
IRHM 13b15e03d0 Poster: Add check for watched before calling removeWatched 2026-03-09 09:12:06 +00:00
IRHM 3b4a5a27e6 Add confirmation modal when deleting from your list
to avoid accidental data loss (thoughts, rating status)
2026-03-09 08:46:03 +00:00
IRHM 13bd37c32c doc: Fix old license being referenced and update some of the simple features list on the homepage. 2026-03-09 07:01:22 +00:00
IRHM 2d6d3c005c Activity: Fix automation icon not showing for mobile 2026-03-09 07:01:22 +00:00
IRHM f72f950871 Icon: Fix 'sparkles' svg path on dark theme by using currentColor fill for the path 2026-03-09 07:01:22 +00:00
IRHM e4e015daf8 age->GetAge: If we don't have a birthday skip processing
Otherwise eg: we get current year - 1 as someones age if their birthday isn't listed on tmdb
2026-03-09 07:01:22 +00:00
IRHM 3db89f3214 SpinnerTiny: Fix color for dark theme 2026-03-09 03:34:57 +00:00
IRHM d379d3f147 igdb: Fix some logs, only log req on Debug because it could be sensitive 2026-03-09 03:34:57 +00:00
IRHM ac8d8769af import: Support games importing
Fixing watcharr import from watcharr export not importing users games.

Also works if user edits the table in import/process to change the type of something to a game (and multi results works too).

Added warning message if user tries importing a watcharr export that has games when `!serverFeatures.games`
2026-03-09 03:34:57 +00:00
IRHM 7a7bd4f566 jellyfin sync: Fix addWatched params formatting 2026-03-06 18:33:12 +00:00
IRHM ca82a36d23 sync: Update err soft deleted comments 2026-03-06 18:33:12 +00:00
IRHM 1e6a97202b tag: GetTagPage: Remove debug call 2026-03-06 18:33:12 +00:00
IRHM 0e54a8c44a sync: Fix already on list handling by using new add watched func AND no longer auto restore soft deleted records
no longer auto restoring soft deleted records means if the user (soft) deletes a show (default behavior), the next sync job wont add it back.
2026-03-06 18:33:12 +00:00
IRHM 5c4c7be115 import: Fix already on list handling by using new add watched func 2026-03-06 18:33:12 +00:00
IRHM f458eec732 watched: abide by new api in router 2026-03-06 18:33:12 +00:00
IRHM 8ad2208162 watched: Restore can be skipped with flag and now returns a new error if watched just plain exists 2026-03-06 18:33:12 +00:00
IRHM 28c373173b v3.0.0 2026-03-04 09:08:01 +00:00
ImgBotApp d637e04ba4 [ImgBot] Optimize images
*Total -- 12,324.41kb -> 10,332.72kb (16.16%)

/screenshot/discover-page.png -- 1,064.08kb -> 804.68kb (24.38%)
/screenshot/content-details-page.png -- 665.72kb -> 510.47kb (23.32%)
/screenshot/content-details-page-dark.png -- 674.65kb -> 519.95kb (22.93%)
/screenshot/user-profile.png -- 75.25kb -> 60.43kb (19.69%)
/screenshot/person-page.png -- 1,362.18kb -> 1,096.48kb (19.51%)
/screenshot/retired-04-03-26/content-details-page-dark.png -- 487.52kb -> 393.40kb (19.31%)
/screenshot/retired-04-03-26/content-details-page.png -- 342.39kb -> 278.55kb (18.65%)
/screenshot/homepage-poster-change-status.png -- 1,048.82kb -> 899.79kb (14.21%)
/screenshot/homepage-poster-hover.png -- 1,064.36kb -> 913.21kb (14.2%)
/screenshot/retired-04-03-26/discover-page.png -- 900.18kb -> 777.06kb (13.68%)
/screenshot/homepage.png -- 1,126.26kb -> 989.01kb (12.19%)
/screenshot/devices-mock.png -- 2,379.62kb -> 2,092.85kb (12.05%)
/screenshot/homepage-dark.png -- 1,133.39kb -> 996.83kb (12.05%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
2026-03-04 08:57:22 +00:00
IRHM 5fb92daf0c WatchedDto: Add comment to thoughts 2026-03-04 08:49:43 +00:00
IRHM 7f4da2d90e v3.0.0-dev5 2026-03-04 08:41:45 +00:00
IRHM 199a97e3a7 (fix) Thoughts modal not closing after clicking close first time because contentChanged funcs no longer return bool
so updated the funcs to return bools
2026-03-04 08:37:02 +00:00
IRHM af04698625 (fix) Add thoughts to watchedDto for Content Page responses 2026-03-04 08:22:09 +00:00
IRHM a9f928a44c doc: Homepage: Add person page image and update the rest to latest version
Updating v to reset anyones cache
2026-03-04 07:57:15 +00:00
IRHM 485408390b new screens for content, person & discover pages 2026-03-04 07:52:11 +00:00
IRHM 2bad7bc272 docs: Update workflows to use nodejs v20 2026-03-04 07:34:23 +00:00
IRHM 8d0642086c doc: importing/trakt: Add section on the optional api key field 2026-03-04 07:30:09 +00:00
IRHM 3b0b99ad9a doc: Update all deps 2026-03-04 07:29:52 +00:00
IRHM c16e0af3b2 v3.0.0-dev4 2026-03-04 06:54:57 +00:00
IRHM e0f49f25b2 (bug) filter/sort: Scroll to top of page after changing 2026-03-04 06:53:36 +00:00
IRHM 7561b59037 v3.0.0-dev3 2026-03-04 03:46:48 +00:00
IRHM 72932f7acd search: Fix from-my-list-msg width responsiveness 2026-03-04 03:45:28 +00:00
IRHM e7751807f6 search: Disable MediaTypeFilter if showingResultsFrom 2026-03-04 03:45:28 +00:00
IRHM cb97aa3914 search->searchMyList: Add a lil commento 2026-03-04 03:45:28 +00:00
IRHM d1e9a60beb watched: Remove leftover debug call on query 2026-03-04 03:45:28 +00:00
IRHM 0a09e71af7 search: Improve 'do a full search' text 2026-03-04 03:45:28 +00:00
IRHM 404b7c680f search: Return resp directly when we fetched the data FromMyList
to avoid extra unnecessary db queries
2026-03-04 03:45:28 +00:00
IRHM 9bb4f3f948 (feat) Search your own list for results before external search 2026-03-04 03:45:28 +00:00
IRHM 52bb995937 Replace PageError with just Error component and make it look nicer 2026-03-04 03:45:28 +00:00
IRHM 624a3b1bbf v3.0.0-dev2 2026-03-03 18:23:00 +00:00
IRHM a314231780 search: multi: Only get games for first page 2026-03-03 18:21:17 +00:00
IRHM ba6ae06a5f search: Keep the searchbar truly centered 2026-03-03 18:21:17 +00:00
IRHM fc4d65ccbc tv seasons: Fix release date 2026-03-03 18:21:17 +00:00
IRHM d5f8644554 Poster: Fix details-shown class not added when img errors when loading 2026-03-03 18:21:17 +00:00
IRHM 4b0abd13cc Poster: Fix creating poster urls with undefined extPosterPath
This fixes the details-shown class not being added because were constructing a string with undefined at the end
2026-03-03 18:21:17 +00:00
IRHM c62c2cdfc0 Update twitch config and fix possible undefined issues 2026-03-03 18:21:17 +00:00
IRHM 8955cacee6 search: Don't attempt game search if twitch is not configured 2026-03-03 18:21:17 +00:00
IRHM 8fbf4ddc6d config: Create TwitchEnabled func 2026-03-03 18:21:17 +00:00
IRHM 70f59697d3 Dockerfile: Add comment to server copy command 2026-03-01 22:38:51 +00:00
IRHM 22f77aa142 build: Fix dockerfile server job not copying in packages 2026-03-01 22:38:01 +00:00
IRHM 532d3f49c7 v3.0.0-dev1 2026-03-01 22:20:28 +00:00
momi 3ff325cda9 Merge pull request #1019 from sbondCo/list-pagination-2
Watcharr v3.0.0
2026-03-01 22:16:19 +00:00
IRHM 4e40a9fdb5 config: Fix generateConfig not setting our cfg var
Altered the read func to return a ServerConfig pointer instead of taking one in
2026-03-01 22:12:27 +00:00
IRHM 81a67404d3 Fix setup
authProvider wasn't being passed in
2026-03-01 21:47:29 +00:00
IRHM 307f5324f0 image->DownloadAndInsertImage: Replace fatal log with err response 2026-03-01 21:05:34 +00:00
IRHM 4a922df7e4 user->UploadUserAvatar: Replace fatal log with err response 2026-03-01 21:03:45 +00:00
IRHM d89252c4fe Dockerfile: Update backend base image to golang 1.25
going to update to 1.26 another day
2026-03-01 20:58:41 +00:00
IRHM 749808cd70 Dockerfile: Fix COPY requiring trailing slash on dest dir 2026-03-01 20:57:34 +00:00
IRHM 0e4249ee42 AddWatched: Keep support for the 'contentId' property for now
Instead of completely removing it, I've added it back so third party scripts can migrate to the new property 'tmdbId'.

I realised I don't want to break any ones experience, this should allow for a painfree path to migration.
2026-03-01 20:44:26 +00:00
IRHM ce264cbf4a TraktImport: Add a log for when a custom api key is provided 2026-03-01 20:27:51 +00:00
IRHM 47388d327d Setting: Remove margin.
if a margin is wanted, we can add it outside the component on a wrapper element.
2026-03-01 20:21:49 +00:00
IRHM 26dfad19bc TraktImport: Renew default api-key and support bringing your own key
Resolves #1014
2026-03-01 20:21:11 +00:00
IRHM dce22cf8e8 profile: Mark 'Include Previously Watched' as due to be removed
and ask for feedback if anyone actually uses this or prefers it off.

Incase people do actually find this setting useful, I'm leaving it intact and not creating a db migration to drop it yet until I hear any feedback.. otherwise I'll just delete it in one of the updates after 3.0.
2026-03-01 19:24:42 +00:00
IRHM 230ea306ce Create safe dtos for get Arr servers public 2026-03-01 01:03:31 +00:00
IRHM 36159f5792 tag: Update page to work as others do 2026-02-27 15:54:35 +00:00
IRHM 50c265de24 tag: Fix GetTagPage returning whole watched list if tag is empty 2026-02-27 15:54:22 +00:00
IRHM d408cee754 tag: Update response to match other watched responses (Media) 2026-02-27 15:53:34 +00:00
IRHM 24f5ea19f5 UpdateWatchedLastViewedSeason: improve format 2026-02-27 15:18:52 +00:00
IRHM 9c26b6b1d7 TestGetLatestWatchedInTv
made a lil test, should probably make more these when i have time
2026-02-26 22:21:33 +00:00
IRHM 7f1c2f2e26 watched: move public list response to its own type
If we add stuff that should never be on a public list to the other type, we can't leak it now on public ones.
2026-02-26 21:43:42 +00:00
IRHM b2c24761e0 Move watching season logic to server, move to master WatchedDto, ...
Remove WatchedList component and create PosterLists directly on watched list and other users list pages.

Get Watched endpoints now return Media with watched inside them, same structure as search, etc. This makes the client logic easier and means we can always expect the same data response no matter how we request data.

Fix race cond in paginatedLoader & abort previous request inside reset func.
2026-02-26 21:33:19 +00:00
IRHM 65d5a581f8 game: Add itchio provider 2026-02-26 03:10:18 +00:00
IRHM 9c17a5fbe7 SeasonsListEpisode: Remove bindable from watchedItem prop 2026-02-25 23:01:30 +00:00
IRHM c9b3f26dfe tv: fix SeasonsList
using derived to make a web request = slap on hand

and it was causing a bug where it would request the season twice after selecting another tv series from the similar list
2026-02-25 22:59:41 +00:00
IRHM e54a99cedd tv: Add similar results 2026-02-25 22:07:16 +00:00
IRHM d4faaa2e85 Create ExpandableText component from Bio and use it on all content pages 2026-02-25 22:03:48 +00:00
IRHM 5cb0a6c666 games: Display steam/gog providers 2026-02-25 20:16:12 +00:00
IRHM 0ac70349b4 style: Fix mask for PageBackdrop on dark theme 2026-02-24 19:50:09 +00:00
IRHM 181ce99746 norm.scss: Use global blocks unformly
Use the global blocks everywhere without having an argument.

Simpler using this everywhere instead of mix and matching + it will work when we have styles underneath so we dont have to keep adding global tag in each selector inside a global tag
2026-02-24 19:29:29 +00:00
IRHM 42dd90579f fix import typing 2026-02-24 17:27:15 +00:00
IRHM ad51f36a0e ExportList modal 2026-02-24 17:25:07 +00:00
IRHM 0d4fc8a9df fix arr component errors 2026-02-24 04:52:11 +00:00
IRHM 0921282de6 WatchedList: New Date Released sort option
Implements #1016
2026-02-24 02:08:27 +00:00
IRHM e785a9a92b content/page.scss: Improve responsiveness 2026-02-24 01:55:08 +00:00
IRHM 2e6acf12e4 person: remove duplicate styles in page 2026-02-24 01:54:47 +00:00
IRHM 94c43b1aac Make dto for person response and add age 2026-02-24 00:33:18 +00:00
IRHM c900ea7f0a fix person page and update styling 2026-02-24 00:01:12 +00:00
IRHM e8ec1c36d1 use Poster component for games too, add watched works for games too in one endpoint
use media in content pages, remove canvas from dom after img loaded in poster, fix filter menu buttons active style, view trailer btn is a component now, show justwatch attribution (didnt realise we had to until i saw the api docs to check providers data), no longer need to use copier for detail responses, move and make tranformproviders more resilient
2026-02-22 19:59:27 +00:00
IRHM e454f6845b Discover->FilterDropDown: Keep disabled until user selects a content filter
I think it may be less confusing this way to users, since on the main multi page there is only the trending filter, so when they change the content filter it may not be obvious that more options are added, this way it is disabled until there are options that do something for the type of content selected.
2026-02-18 16:58:06 +00:00
IRHM 86735e5093 make pagetitle more responsive for mobile for discovery page 2026-02-18 16:42:35 +00:00
IRHM bd049e75e2 discover: add comment to DiscoverMulti 2026-02-17 20:56:41 +00:00
IRHM 69a66e2183 discover games - trending and upcoming support 2026-02-17 20:50:32 +00:00
IRHM bf6f87246b discover page rework
adding games back later, got the new page working 1000x better for movies, tv and people (new!).

Some slight refactoring to other stuff I touched when getting the discover package up and running.
2026-02-16 23:49:18 +00:00
IRHM 85bb71758e game: Remove search endpoints 2026-02-15 10:42:19 +00:00
IRHM 333912c694 search: Fix back btn not updating query and dont search if no query 2026-02-15 10:38:20 +00:00
IRHM 0c287e0bfa search: Fix restore of search query not being decoded 2026-02-15 10:25:27 +00:00
IRHM e9a7898be5 content pages redesign of details section and separated some parts into components to reduce duplication 2026-02-14 22:54:41 +00:00
IRHM bdf7e0199d scss comment typo 2026-02-14 21:18:06 +00:00
IRHM b6def6f43d Replace import with use for sass and reduce css output bundle by only prepending partials
- Moved main scss files to src/styles.
- Instead of prepending all our global styles in svelte.config.js, we now only prepend our sass logic that doesn't build to css, which reduces the output css massively by avoiding duplicative imports. Our norm.scss is now imported in the root +layout file.
- Update sass package
- Renamed mixins and vars scss files to start with an underscore, which indicates they are partial files
2026-02-14 21:17:05 +00:00
IRHM dbb96177e8 watched: Refactor AddWatched and move restoration logic to new func 2026-02-11 06:33:34 +00:00
IRHM 42ac57b0a6 movie: Fix updateWatched call 2026-02-11 06:20:53 +00:00
IRHM c421f63977 GetWatchedPage: Return with a new DTO type that includes Media 2026-02-10 09:27:44 +00:00
IRHM 91a2aa9648 content pages: Show details div at 100% width always
Fixes case where we have no overview text that stretches the div out to 100% usually, so width is very small
2026-02-09 13:24:47 +00:00
IRHM f12e7d8f17 Title: Only show release year if we have it 2026-02-09 13:23:45 +00:00
IRHM f77bc1c125 tmdb: Correct ExtPosterPaths for people 2026-02-09 13:14:21 +00:00
IRHM da2a7e3952 search: correct logs 2026-02-09 13:07:43 +00:00
IRHM e5a0609f5b content: Add mem caching to SearchPeople 2026-02-09 13:06:40 +00:00
IRHM 1f216e512c content: Remove search endpoints
main search endpoint to be used instead
2026-02-09 13:06:22 +00:00
IRHM bff92b8bce logging: AddSource to logs 2026-02-09 12:49:33 +00:00
IRHM f7898326f0 igdb: add mem caching 2026-02-09 12:49:01 +00:00
IRHM efbb1078d6 search: correct logs 2026-02-08 11:14:18 +00:00
IRHM d25692577d search by igdb id or url/slug 2026-02-08 11:12:29 +00:00
IRHM 01619e1da0 search by external id or by url 2026-02-08 10:48:15 +00:00
IRHM 7008e69a90 search: Reactively access type search param 2026-02-07 11:04:35 +00:00
IRHM e666d5f332 search and media type in decent place 2026-02-07 01:02:34 +00:00
IRHM 897cc8a044 search service wip 2026-02-02 23:16:18 +00:00
IRHM 6db6149e6b pagination: Change 'q' and 'l' query parameters into 'query' and 'limit'
I don't want this api to become a confusing behemoth so lets use full words where it makes sense.

'p' and 'l' also didn't fit in with our other query params that are already just the full word like 'type', etc.
2026-01-29 19:43:57 +00:00
IRHM 1310c6e996 watched->GetPublicWatched: Replace panic with error reponse
some good old legacy code ;()
2026-01-29 17:48:34 +00:00
IRHM 5ea51c7257 content: fix nil pointer deref 2026-01-29 17:46:17 +00:00
IRHM ec280dbc20 support games getting watched data 2026-01-29 17:42:45 +00:00
IRHM d454b9ff57 Create reusable paginated loader helper and use it for main list loading
This helper will stop us having so much "duplicated" logic for loading pages of data
2026-01-26 16:26:27 +00:00
IRHM 978aab0804 tags: Get tag page endpoint
Support added to our main GetWatchedPage service so we can use it in our tags service
2026-01-26 16:24:00 +00:00
IRHM 0d648372b8 Fix SeasonsList and SeasonsListEpisode 2026-01-05 03:45:58 +00:00
IRHM 9d25406652 watched_refine: Fix alpha sort 2026-01-04 02:10:27 +00:00
IRHM 68d15dbd5c watched_refine: Sort pinned items to top 2026-01-03 21:07:11 +00:00
IRHM 69d6f44cc5 loadWatchedList: Set page/maxpage vars before results.len check
This fixed spamming of get page requests when resizing, etc for next page when the list is empty (because max page wont be set to 0)
2026-01-02 23:48:57 +00:00
IRHM a996ab9767 WatchedList: Show only error when no results and error, update no results because filters message 2026-01-02 23:47:53 +00:00
IRHM 4b48d849a5 getWatchedPage: Preload watched Seasons and Episodes
Because the UI currently relies on this information for displaying the Last Watched extra detail for posters.

At some point, it'd likely be best that that logic is migrated to the backend, but for now doesn't really matter.
2026-01-02 23:04:08 +00:00
IRHM 941fab4b0e fix some formatting 2026-01-02 23:02:40 +00:00
IRHM ce845b5bdb server: getWatchedPage: Remove debug from query 2026-01-02 22:45:20 +00:00
IRHM 693904a1ba server: GetWatched: Implement filters 2026-01-01 21:34:15 +00:00
IRHM 53306bad48 server: Upgrade gin 2026-01-01 20:56:54 +00:00
IRHM 26bcf3491f tag: Add spinner while getting tag
im a 10x engineer got damn
2025-11-24 02:51:05 +00:00
IRHM 8f4cf90589 tags working 2025-11-23 21:10:48 +00:00
IRHM 727a8244f4 watched: Remove comment where watchedRefine is used, no longer true 2025-11-20 00:06:15 +00:00
IRHM a1810a1f75 store->updateSortAndFiltersForQueryParams: Make logic more robust and only add properties if they will have a value 2025-11-19 23:57:49 +00:00
IRHM 808cd50599 SortMenu->sortClicked: If mode is empty, reset activeSort 2025-11-19 23:54:54 +00:00
IRHM bfd404cdce SortMenu->sortClicked: Remove unused modeType parameter and related unused logic 2025-11-19 23:54:21 +00:00
IRHM 927b04acaf watched_refine: Fix query for watchedSortLastFinished sort
The query works as intended now (i think), gonna test it more later.

Not sure if performance has improved much, but without adjusting how our data looks I'm not sure how it could be solved. Going to worry about this specific sorts performance later though if it arises as an issue (its only a few ms more in my dev env on 1000 watched items, testing on beta site will give me a better idea since it has a lot more records).
2025-11-19 23:25:59 +00:00
IRHM 3384e6f8b5 server: Update gorm 2025-11-19 22:15:43 +00:00
IRHM a73e99f2dc main: Add version to startup slog
unlike the startup graphic, this will actually be logged to file so it can be referenced
2025-11-19 22:15:10 +00:00
IRHM 7d5427e656 Fix watched list loading forever if zero results 2025-11-16 02:36:18 +00:00
IRHM 14b6be0d64 tag: Create GetTag 2025-11-16 02:23:34 +00:00
IRHM 391534dc77 fix Activity and ActivityEditor 2025-11-16 01:45:12 +00:00
IRHM 142fef5f43 fix person view and add watched data 2025-11-16 00:45:42 +00:00
IRHM e28aea4497 Make: Fix version target by stopping newline from echo into VERSION file 2025-11-14 20:13:52 +00:00
IRHM 05855571e1 contentRouter: Add error checks to all addedtocontent calls 2025-11-14 19:52:05 +00:00
IRHM a1b35fa70b search: Show multi search errors with the specific request that failed 2025-11-14 19:51:34 +00:00
IRHM e69bf8c2ab addedtocontent->AddList: Check 's' length before any other logic 2025-11-14 19:32:57 +00:00
IRHM 407e6a5a35 addedtocontent: Return errors from all funcs 2025-11-14 19:32:27 +00:00
IRHM 64404eb3a8 addedtocontent: Remove unused WatchedAddedToContent struct 2025-11-14 19:22:50 +00:00
IRHM 7dc956ff89 contentRouter->GetSearchByExternalId: Add watched data to response
Likely will never hit a case where the frontend will need this, but added anyways incase anyone making third party scripts want this functionality in the future
2025-11-14 19:15:22 +00:00
IRHM 1ed24be195 content->SearchByExternalId: Add cache to func level 2025-11-14 19:14:15 +00:00
IRHM ba5e690a3d Addable: Change GetMediaType return type to ContentType 2025-11-14 18:58:48 +00:00
IRHM 581cbb9917 tmdb: Fix TMDBMovieDetailsBase type methods 2025-11-14 18:54:59 +00:00
IRHM 7395b3b034 watched data for content requests 2025-11-14 03:19:40 +00:00
IRHM 234120f6eb Create FEATURES.md 2025-11-14 02:59:30 +00:00
IRHM 4596c34ffd season: Fix routes 2025-11-14 02:58:48 +00:00
IRHM 2e53997f9e (refactor) Move db from service function parameters to service structs
Now that we have everything encapsulated in Services, we can move the db parameters of each function into the service struct itself which:
1. Simplified calling and reduces us passing around the db in random funcs that just pass it to a service func
2. probably other stuff
3. looks nicer now
2025-11-07 00:46:07 +00:00
IRHM fd309c44bb Make: Disable git commit for npm version command 2025-11-06 22:48:42 +00:00
IRHM 40ec711f71 Create Makefile for updating version numbers 2025-11-06 22:44:44 +00:00
IRHM ad643e6641 main: Embed version and show it in startup log 2025-11-06 22:44:19 +00:00
IRHM 62e0911b85 main: Move startup art one line over, looks a bit better in my terminal 2025-11-06 20:54:23 +00:00
IRHM 8320d379f7 beautiful startup art 2025-11-06 01:13:41 +00:00
IRHM 29a207ed10 fix tag import 2025-11-05 01:52:43 +00:00
IRHM df3ac430da LICENSE: We are now part of the gpl gang
couldn't decide between v2 and v3, but i don't think any downsides of v3 apply to our app here so v3 seems safest
2025-11-05 01:50:04 +00:00
IRHM 14eba564cb uniformize feature and plex routers 2025-10-26 18:12:56 +00:00
IRHM 37a37b83c1 servicize tag 2025-10-26 18:07:24 +00:00
IRHM 1a6aa30d67 move image, task, job mods up a folder
because this differenciates them better from the more user-facing features inside the 'features' folder.
2025-10-26 18:03:39 +00:00
IRHM f2f2cf4d23 arr init all struct props 2025-10-26 17:38:22 +00:00
IRHM bf7a001f26 servicize imprt 2025-10-26 17:35:37 +00:00
IRHM cff7debdad servicize follow 2025-10-26 17:32:48 +00:00
IRHM 8a271122e9 servicize user 2025-10-26 17:29:47 +00:00
IRHM 9019413d81 servicize profile 2025-10-26 17:14:26 +00:00
IRHM 4775505653 servicize activity 2025-10-26 17:10:34 +00:00
IRHM cbdf926392 main: Move img static ep to below router starts again 2025-10-25 18:27:59 +01:00
IRHM 66e2d6a41d PageError: Correct if on error detail para
So it only shows the para when there is actually an error to show
2025-10-25 18:16:43 +01:00
IRHM e3029ff558 plug in existing services
i say "plug in" because that sounds cool, im just initializing them and the routers (the ones I have made so far)
2025-10-25 18:11:11 +01:00
IRHM 8f2a76e9a8 (wip) server restructure/refactor 2025-10-24 18:37:20 +01:00
IRHM 61fa88167c game watched data 2025-07-27 20:44:07 +01:00
IRHM 84e86cc256 movie page 2025-07-19 14:10:03 +01:00
IRHM 1a56660523 FilterMenu: Fix type btn overflow and style to be pills 2025-07-19 13:28:51 +01:00
IRHM 7b24ff619d wip: Watched sorting, fixed watcheds loader 2025-07-19 13:28:51 +01:00
IRHM 2f17d9fcea fix search person (use PaginatedRequest) 2025-07-19 13:28:51 +01:00
IRHM bb0d89b25f add watched to discover data and fix search pagination 2025-07-19 13:28:51 +01:00
IRHM ddebe11ddc getWatchedItemsByTmdbIds: Update log to comment out all watcheds 2025-07-19 13:28:51 +01:00
IRHM f3f182a26c getWatched: return err instead of panicking 2025-07-19 13:28:51 +01:00
IRHM 031ae7cf03 Support poster adding/removing watched, and make watched prop bindable to update parent data too 2025-07-19 13:28:51 +01:00
IRHM b094abe69b fix get watched caching and move addWatched to content stuff to functions 2025-07-19 13:28:51 +01:00
IRHM ed32101a76 removeWatched: Make notify call success when successfully removed 2025-07-19 13:28:51 +01:00
IRHM 43da0f82d2 Update WatchedList.svelte 2025-07-19 13:28:51 +01:00
IRHM 26eadb10b3 forgot what i did but progressed 2025-07-19 13:28:51 +01:00
IRHM f9dd7c6c73 infScroll: Add callback isloading requirement for implementing in comment 2025-07-19 13:28:51 +01:00
IRHM 78b7f85bd0 infScroll: Create dataLoaded func for ensuring full page of data is present after page loads 2025-07-19 13:28:51 +01:00
IRHM 4285a51d5a Create go-cache GetCache helper func
Easier to use this method so we can simply pass a pointer of our var in and let it do everything for us, relieves us of our manual type assertion duty everywhere we get from cache.
2025-07-19 13:28:51 +01:00
IRHM 0546faeb6c tv: remove old comment 2025-07-19 13:28:51 +01:00
IRHM 345a28fcc1 wip: getting show watched data in request 2025-07-19 13:28:51 +01:00
IRHM b1d5da0451 wip: content: move watched entry to inside content object
instead of separating both, should be easier to work with this way and enable it to work for search results without complex mapping etc to find related watched entries
2025-07-19 13:28:51 +01:00
IRHM 0115b3f238 wip: content: returning watched along with tv response 2025-07-19 13:28:51 +01:00
IRHM 9be0420534 main page: show spinner while loading next list page 2025-07-19 13:28:51 +01:00
IRHM 4748e891db watched list pagination in ui 2025-07-19 13:28:51 +01:00
IRHM 6e4356ca0a search: Use infScroll 2025-07-19 13:28:51 +01:00
IRHM 14c54ce92d Create infScroll helper with reusable logic
based on the infinite scroll code from search page
2025-07-19 13:28:51 +01:00
IRHM 5ed2650a39 finalize PaginationResponse, get count in watchedpage 2025-07-19 13:28:51 +01:00
IRHM c1e81cbab4 watched: Create getWatchedPage for paginated response 2025-07-19 13:28:51 +01:00
IRHM a0ab7d8413 v2.1.1 2025-07-15 23:21:29 +01:00
IRHM 282255dbea 2.1.1-dev3 2025-07-15 22:44:24 +01:00
JoshF fa69639123 fix bug on return from blurhash.Encode (#922) 2025-07-15 21:41:30 +00:00
JoshF e177562c5a fix Twitch init error logging bug (#921) 2025-07-15 21:35:40 +00:00
IRHM 6d0203c6e1 2.1.1-dev2 2025-07-14 23:30:58 +01:00
IRHM 45921a0c94 StarRating: Still save rating if scroll change is less than 10px in either direction
This fixes firefox mobile.

Chromium on mobile stops the page from scrolling with a grace area while dragging the stars, but firefox doesn't do this, which breaks the (if scrolled dont save logic), so added the 10px grace into logic.

Future fix could be to stop the scrolling to mimic chromium behaviour for firefox mobile too, but that sound hard. Maybe firefox can fix this.
2025-07-14 23:30:32 +01:00
IRHM 18ab577662 StarRating: Fix rating change saved twice on chromium mobile when a star is clicked
without being dragged first.
2025-07-14 23:28:12 +01:00
IRHM acb388e271 2.1.1-dev1 2025-07-14 18:53:15 +01:00
IRHM d7dafc8d67 import: Remove returning of only the perfect matches if more than 1
Just had an epiphany that it'd be better to return all results in this case, the frontend still sorts for best matches to be shown first, but then we keep all other options incase the users import data had a slight typo that matched other content etc.
2025-07-14 18:52:33 +01:00
IRHM 77f73bd03b 2.1.1-dev 2025-07-14 18:46:56 +01:00
Mr a47952e61d StarRating: Ignore star presses if scroll position changes from start to end of click (#916)
* StarRating: Ignore star presses if scroll position changes from start to end of click

This should help us avoid accidental clicks of stars being saved when the user is just trying to scroll down the page.

* StarRating: Make scrollLocAtStart a normal variable

doesnt need to be $state
2025-07-13 18:42:34 +00:00
Mr 72f8ddc8e6 import: Perfect matching now takes Year into account if provided, avoiding muli result responses (#915)
perfect matches are also collected (before only one was allowed to perfect match) and all are returned if multiple

#914
2025-07-13 15:59:52 +00:00
363 changed files with 44371 additions and 30915 deletions
+2
View File
@@ -0,0 +1,2 @@
server/data/
server/Makefile
-15
View File
@@ -1,15 +0,0 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
/doc
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
-27
View File
@@ -1,27 +0,0 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
extends: ["plugin:svelte/recommended"],
plugins: ["@typescript-eslint"],
ignorePatterns: ["*.cjs", "*.config.js"],
overrides: [
{
files: ["*.svelte"],
parser: "svelte-eslint-parser",
parserOptions: {
parser: "@typescript-eslint/parser",
},
},
],
parserOptions: {
project: "./tsconfig.json",
extraFileExtensions: [".svelte"],
sourceType: "module",
ecmaVersion: 2020,
},
env: {
browser: true,
es2017: true,
node: false,
},
};
+2
View File
@@ -1,5 +1,7 @@
<!-- Make sure your code is formatted by running `npm run format` or using prettier manually. -->
<!-- AI Disclosure: <If you used AI to write the code, please disclose it by uncommenting this line and describing the usage. If AI wrote any of the code, do you fully understand it?> -->
### Changes made
<!-- Describe changes made here. If changes are visual a screenshot could be useful! -->
-27
View File
@@ -1,27 +0,0 @@
# 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"
+6 -6
View File
@@ -19,29 +19,29 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v4.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4.2.0
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
uses: docker/login-action@v4.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
uses: docker/login-action@v4.4.0
with:
username: sbondco
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7.3.0
with:
context: .
file: ./Dockerfile
+7 -7
View File
@@ -18,37 +18,37 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v4.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4.2.0
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
uses: docker/login-action@v4.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
uses: docker/login-action@v4.4.0
with:
username: sbondco
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@v6.2.0
with:
images: |
${{ env.image }}
ghcr.io/${{ env.image }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7.3.0
with:
context: .
file: ./Dockerfile
+4 -4
View File
@@ -21,10 +21,10 @@ jobs:
run:
working-directory: doc
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v7.0.0
- uses: actions/setup-node@v7.0.0
with:
node-version: 18
node-version: 24
cache: npm
- name: Install dependencies
@@ -35,7 +35,7 @@ jobs:
# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
uses: peaceiris/actions-gh-pages@v4.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Build output to publish to the `gh-pages` branch:
+3 -3
View File
@@ -16,10 +16,10 @@ jobs:
run:
working-directory: doc
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v7.0.0
- uses: actions/setup-node@v7.0.0
with:
node-version: 18
node-version: 24
cache: npm
- name: Install dependencies
+13 -3
View File
@@ -11,12 +11,22 @@ on:
- "server/**"
jobs:
format_check_go:
test_and_format_check_go:
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v7.0.0
- uses: actions/setup-go@v7.0.0
with:
go-version-file: "server/go.mod"
- name: go test all packages
run: go test ./...
- name: gofmt test
run: |
+3 -3
View File
@@ -21,12 +21,12 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Setup Node
uses: actions/setup-node@v4
uses: actions/setup-node@v7.0.0
with:
node-version: "20"
node-version: 24
cache: "npm"
- name: Get dependencies
+2
View File
@@ -1 +1,3 @@
engine-strict=true
ignore-scripts=true
min-release-age=14
+1912
View File
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -4,8 +4,14 @@ First of all, thank you for looking into contributing! 🫡
Feel free to contribute in any way: 🐞 bug reports, 💡 ideas, 🥖 new features etc - everything is welcome!
For big PRs (lots of changes/big change in the way something works), if you'd like, it can be discussed first in an issue (dont want to waste anyones time!).
Big pull requests (anything more than a few lines) should be discussed first in an issue (dont want to waste anyones time!).
## Project Board
We have a [board to organize new features and bug fixes](https://github.com/orgs/sbondCo/projects/9/views/2) to be worked on. If you see something you'd like to work on, just ask in the issue and it can be assigned to you. Even if it isn't set for the next milestone already, it can be.
## AI
If you use AI, please disclose the usage in your pull request.
Fully understanding any code that is submitted is a must because someone's gotta understand it!
+8 -7
View File
@@ -1,12 +1,13 @@
#
# Backend
#
FROM golang:1.24-alpine AS server
FROM golang:1.26-alpine AS server
WORKDIR /server
COPY server/*.go server/go.* ./
COPY server/arr/*.go ./arr/
COPY server/game/*.go ./game/
# We can copy the whole server folder, since our .dockerignore file
# will filter out stuff we don't want in the final image.
COPY server/ ./
# Required so we can build with cgo
RUN apk update && apk add --no-cache musl-dev gcc build-base
@@ -17,7 +18,7 @@ RUN go mod download && GOOS=linux CGO_ENABLED=1 CGO_CFLAGS="-D_LARGEFILE64_SOURC
#
# Frontend
#
FROM node:20-alpine AS ui
FROM node:24-alpine AS ui
WORKDIR /app
COPY package*.json vite.config.ts svelte.config.js tsconfig.json ./
@@ -29,11 +30,11 @@ RUN npm install && npm run build
#
# Production
#
FROM node:20-alpine AS runner
FROM node:24-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
COPY --from=ui /app/package.json /app/package-lock.json /ui/
# Install just the prod dependencies for final step.
# We --ignore-scripts, to stop the `prepare` script from auto-
+59
View File
@@ -0,0 +1,59 @@
# Watcharr Features
A basic top-level view of the features included in Watcharr.
When the word `watched` is used, assume it can be `played` for games too.
**NOTE:** Have a look at when this document was last updated, it may have missing features. This document was made years after starting the project, so I have no doubt I've missed some stuff, this is a good overview anyways.
- Watched List
- Supported Content:
- Movies
- TV Shows / Anime
- Seasons
- Episodes
- Games
- Filtering
- Sorting
- Pinning
- Thoughts (for writing a review, etc)
- Activity (detailed list of modifications made to each watched item)
- Importing from other services
- Content detail pages
- Basic overview
- Watch trailer
- Available streaming providers in your region
- Cast
- Similar content
- List of all seasons and their episodes (for tv shows).
- Person detail pages
- Basic overview
- All credits (movies & tv they appear in or worked on)
- Searching for media
- Inline filters (ex: `y:2008` to get media released in 2008)
- Custom tags
- Discovery page
- Following other users
- Simple user stats (movies watched, time spent watching, etc)
- User Settings
- Dark & Light themes
- Privacy
- Hide Spoilers
- Rating System
- Out of 5
- Out of 10
- Out of 100
- Rating Step
- And more generic settings..
- Server dashboard
- Basic stats
- Configuration editing
- User management (including permissions)
- Jellyfin Integration
- Auth
- 'Play On Jellyfin' buttons
- Plex Integration
- Trusted Header Authentication (for auth via proxy)
- Basic Sonarr & Radarr integration
- Let users Request content (users can be given an auto approve permission)
- Manage content requests
+670 -17
View File
@@ -1,21 +1,674 @@
MIT License
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (c) 2023 IRHM
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Preamble
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+16
View File
@@ -0,0 +1,16 @@
.PHONY: dev version
dev:
./node_modules/.bin/vite dev
dev_host:
./node_modules/.bin/vite dev --host
# Don't judge me.
version:
@$(eval VER := $(filter-out $@,$(MAKECMDGOALS)))
@echo "Updating version to $(VER)"
echo -n "$(VER)" > ./server/VERSION
npm version $(VER) --git-tag-version false
%:
@:
+19 -2
View File
@@ -16,9 +16,19 @@ With [some extra configuration](https://watcharr.app/docs/server_config/game-sup
I am built with Go and Svelte(Kit).
Feel free to abuse this demo instance (nicely), which runs on the latest `dev` build (there may be bugs, as new features are tested on here too): [https://beta.watcharr.app/](https://beta.watcharr.app/)
### Demo
[Track progress for the next version](https://github.com/orgs/sbondCo/projects/9/views/3).
Feel free to abuse this demo instance (nicely). It runs on the latest `dev` build so there may be bugs, as new features are tested on here too. The demo is a worst-case scenario for speed (which is why I like it as a testing ground), if you host it yourself the app will be snappy.
Demo: [https://beta.watcharr.app/](https://beta.watcharr.app/)
**NOTE:** There is no demo account, just type in a random username/password (smashing hand into keyboard is supported), then click `Not a user?` at the bottom and a `Sign Up` button will appear.
### Track new features
Most patches are tracked through [our project board](https://github.com/orgs/sbondCo/projects/9/views/3), though I am very unorganised so expect surprise updates (or don't, if you like surprises)!
You can also [view a list of all current features](FEATURES.md).
### Contents
@@ -26,6 +36,7 @@ Feel free to abuse this demo instance (nicely), which runs on the latest `dev` b
- [Set Up](#set-up)
- [Community Made Tools](#community-made-tools)
- [Getting Help](#getting-help)
- [License](#license)
- [Contributing](#contributing)
# Screenshots
@@ -72,6 +83,12 @@ If something isn't working for you or you are stuck, [creating an issue](https:/
You can also [join our space on Matrix](https://matrix.to/#/#watcharr:matrix.org) for support.
I'll do my best to reply!
# License
This project is licensed under the GPLv3 license. You should see the [LICENSE](LICENSE) file located in the root folder of this project for the full license text, if not, see <https://www.gnu.org/licenses/>.
# Contributing
Please continue to our [contributing guide](CONTRIBUTING.md).
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

+5
View File
@@ -0,0 +1,5 @@
## Changelog Data
Changelog images, etc go in this folder.
[View the real changelog for Watcharr.](../CHANGELOG.md)
+6 -1
View File
@@ -14,7 +14,12 @@ Hopefully it is useful for others with similar files or in scenarios where its t
## Format
Each line is a new entry. The name of the content (show/movie) must be provided, the year can be optionally provided surrounded by brackets. Doesn't support specifying if name is for a show or movie, the importer will only automatically match on full search matches, if there are multiple results, you will be asked to pick the correct one.
Each line is a new entry. The name of the content (show/movie) must be provided. Doesn't support specifying if name is for a show or movie, the importer will only automatically match on full search matches, if there are multiple results, you will be asked to pick the correct one.
Optionally provide:
- The year in brackets (eg: `(1983)`)
- A rating (out of 10) in square brackets (eg: `[4]` or `[6.9]`)
```
<name> [(<year>)]
+14 -1
View File
@@ -11,6 +11,19 @@ You may consider a backup of your server before starting any import. They are no
**Note:** Your Trakt profile must be public _during_ this process. You are free to private it again once it completes.
1. Provide your Trakt username in the text box.
2. Press `Start Import`.
2. (Optional) [Provide your own api key](#optional-api-key).
3. Press `Start Import`.
This will be a long process, possibly a couple hours depending on how large of a Trakt history you have. If you think it has frozen or isn't working, try checking your server logs to see if it is doing anything.
### (Optional) API Key
This step is optional because Watcharr comes built in with its own API Key that it can use for your import, however, if you encounter any issues where imports cannot start or keep failing and you see any `403` errors in your server logs, providing your own key may fix the problem.
#### Getting an API Key
1. [Visit this link to create a new Trakt API App](https://trakt.tv/oauth/applications/new).
2. Fill out all required fields (`Name` and `Redirect uri`) with any random data.
1. You can set the `Redirect uri` to any value the input accepts since we don't use it (eg: `http://localhost`)
3. Click `Save App`.
4. You should now be redirected to your new app. Copy the `Client ID` into the `API Key` textbox in Watcharr.
+7 -5
View File
@@ -17,7 +17,7 @@ This section assumes you will be forking the repo on Github, of course you can a
![Fork button](./img/forking-repo.png)
2. Get the code by cloning your fork
2. Get the code by cloning your fork (edit the command and replace `<your username>` with your GitHub username or replace the whole url with the correct one pointing to your fork).
```bash
git clone https://github.com/<your username>/Watcharr.git && \
@@ -34,7 +34,7 @@ You only need to do this once after pulling the codebase for the first time, and
npm i
```
2. Install server dependencies (in the `server` folder)
2. Install server dependencies (in the `server` folder). Go does this automatically if you try starting the server and it notices you don't have them.
```
go get .
@@ -44,16 +44,18 @@ You only need to do this once after pulling the codebase for the first time, and
To run the code, you will need to open up two terminals, one for the frontend and the other for the backend.
We have `Makefile`s for the frontend and server, so you can simply call `make` in each directory. Most Linux distros (as far as I know) include `make`, so you don't need to install anything. If you don't have `make`, you can either install it (lookup how to get "GNU Make" for your specific OS) OR you can just look inside the Makefiles and manually run the first command in each.
1. Run the frontend (first terminal, in the project root folder)
```bash
npm run dev
make
```
2. Run the server (second terminal, in the project root folder)
2. Run the server (second terminal, in the `server` folder)
```bash
npm run server
make
```
**Note:** If you're using Windows, running the server can be a little more complicated. You can follow this: https://github.com/sbondCo/Watcharr/discussions/430#discussioncomment-8894110 which amounts to these steps (the first 3 steps only need to be done once):
+1 -1
View File
@@ -35,7 +35,7 @@ Backing up this way is discouraged because new important files could be added la
If you don't care about the warning not to backup this way, here are the "important" files that you can single out for backup:
- `watcharr.db` Your database, holds all users, their watchlists, etc.
- `watcharr.db` & `watcharr.db-wal` Your database, holds all users, their watchlists, etc.
- `watcharr.json` Server config.
- `img/up` Profile picture uploads.
- `img/games` Game posters (not exactly important, but scenarios in which this folder is not backed up have not been tested, only relevant for servers with game support enabled).
+17164 -14662
View File
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -14,17 +14,17 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@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"
"@docusaurus/core": "3.9.2",
"@docusaurus/preset-classic": "3.9.2",
"@mdx-js/react": "^3.1.1",
"clsx": "^2.1.1",
"prism-react-renderer": "^2.4.1",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"viewerjs": "^1.11.7"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.1.1"
"@docusaurus/module-type-aliases": "3.9.2"
},
"browserslist": {
"production": [
@@ -39,6 +39,6 @@
]
},
"engines": {
"node": ">=18.0"
"node": ">=20.0"
}
}
+7 -8
View File
@@ -1,4 +1,3 @@
import React from "react";
import clsx from "clsx";
import styles from "./styles.module.css";
@@ -8,18 +7,18 @@ const FeatureList = [
Svg: require("@site/static/img/icon/code-slash.svg").default,
description: (
<>
Watcharr is free and open source software distributed under the MIT
license. Feel free to browse, modify or contribute!
Free and open source, distributed under the GPLv3 license. Feel free to
browse, modify or contribute!
</>
),
},
{
title: "Simple",
title: "Simple & Intuitive",
Svg: require("@site/static/img/icon/happy.svg").default,
description: (
<>
Watcharr is incredibly easy to dive into. Install without hassle and get
started with the seamless and intuitive user experience.
Incredibly easy to dive into. Install within the minute and get started
with the seamless experience.
</>
),
},
@@ -28,8 +27,8 @@ const FeatureList = [
Svg: require("@site/static/img/icon/go.svg").default,
description: (
<>
Don't know what else to add here, so now you know Watcharr is built with
Go and Svelte.
Don't know what else to add here, so now you know I'm built with Go and
Svelte.
</>
),
},
+11 -6
View File
@@ -39,32 +39,37 @@ export function HomepageTwoColFeats() {
<TwoColFeat
title="Neat UI"
description="We just look lightweight."
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/homepage.png?v=2"
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/homepage.png?v=3"
/>
<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?v=2"
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/homepage-poster-change-status.png?v=3"
/>
<TwoColFeat
title="In-Depth Details"
description="About your favourite content."
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/content-details-page.png?v=2"
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/content-details-page.png?v=3"
/>
<TwoColFeat
title="Personal Stats and Configuration"
description="Make it how you like."
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/user-profile.png?v=2"
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/user-profile.png?v=3"
/>
<TwoColFeat
title="Discovery"
description="Find the latest trending content."
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/discover-page.png?v=2"
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/discover-page.png?v=3"
/>
<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?v=2"
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/content-details-page-dark.png?v=3"
/>
<TwoColFeat
title="Cast & Crew"
description="What are your favorite actors up to?"
imgSrc="https://github.com/sbondCo/Watcharr/raw/dev/screenshot/person-page.png?v=3"
/>
</section>
);
+2 -2
View File
@@ -4,8 +4,8 @@ services:
build:
context: .
dockerfile: Dockerfile
container_name: watcharr
container_name: watcharr-dev
ports:
- 3080:3080
- 3081:3080
volumes:
- ./container_data:/data
+60
View File
@@ -0,0 +1,60 @@
import prettier from "eslint-config-prettier";
import path from "node:path";
import js from "@eslint/js";
import svelte from "eslint-plugin-svelte";
import { defineConfig, includeIgnoreFile } from "eslint/config";
import globals from "globals";
import ts from "typescript-eslint";
import svelteConfig from "./svelte.config.js";
const gitignorePath = path.resolve(import.meta.dirname, ".gitignore");
export default defineConfig(
includeIgnoreFile(gitignorePath),
js.configs.recommended,
ts.configs.recommended,
svelte.configs.recommended,
prettier,
svelte.configs.prettier,
{
languageOptions: {
globals: { ...globals.browser /* ...globals.node */ },
parserOptions: {
projectService: true,
parser: ts.parser,
ecmaVersion: "latest",
},
},
rules: {
// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
"no-undef": "off",
},
},
{
files: ["**/*.svelte", "**/*.svelte.ts", "**/*.svelte.js"],
languageOptions: {
parserOptions: {
extraFileExtensions: [".svelte"],
svelteConfig,
},
},
},
{
// Override or add rule settings here.
rules: {
"@typescript-eslint/no-empty-object-type": [
"error",
{
// Allowing this because it's nice to create an empty
// interface that extends a base interface for specific
// use, even if it is currently empty, incase i add stuff
// to it in the future. It's also less confusing to read
// the actual type name I want instead of the base type
// everywhere in certain scenarios.
allowInterfaces: "with-single-extends",
},
],
},
},
);
+3390 -3255
View File
File diff suppressed because it is too large Load Diff
+25 -25
View File
@@ -1,6 +1,7 @@
{
"name": "watcharr",
"version": "2.1.0",
"license": "GPL-3.0-only",
"version": "4.2.1",
"private": true,
"scripts": {
"dev": "vite dev",
@@ -9,34 +10,33 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"prepare": "svelte-kit sync",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"server": "cd ./server && MODE=DEV go run ."
"lint": "prettier --check ./src/ && eslint ./src/",
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/adapter-node": "^5.2.12",
"@sveltejs/kit": "^2.21.0",
"@types/papaparse": "^5.3.15",
"@typescript-eslint/eslint-plugin": "^8.32.1",
"@typescript-eslint/parser": "^8.32.1",
"@vite-pwa/sveltekit": "^0.6.6",
"eslint": "^8.57.0",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-svelte": "^2.45.1",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.4.0",
"sass": "^1.89.0",
"svelte": "^5.17.3",
"svelte-check": "^4.1.3",
"svelte-eslint-parser": "^0.42.0",
"svelte-preprocess": "^6.0.3",
"typescript": "^5.8.3",
"vite": "^6.3.5"
"@eslint/js": "10.0.1",
"@sveltejs/adapter-node": "5.5.7",
"@sveltejs/kit": "2.69.3",
"@types/papaparse": "5.3.15",
"@vite-pwa/sveltekit": "1.1.0",
"eslint": "10.7.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-svelte": "3.20.0",
"globals": "17.7.0",
"prettier": "3.9.5",
"prettier-plugin-svelte": "4.1.1",
"sass": "1.101.0",
"svelte": "5.56.4",
"svelte-check": "4.7.2",
"svelte-eslint-parser": "1.8.0",
"svelte-preprocess": "6.0.5",
"typescript": "6.0.3",
"typescript-eslint": "8.63.0",
"vite": "8.1.4"
},
"type": "module",
"dependencies": {
"axios": "^1.9.0",
"blurhash": "^2.0.5",
"papaparse": "^5.4.1"
"blurhash": "2.0.5",
"papaparse": "5.4.1"
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 488 KiB

After

Width:  |  Height:  |  Size: 520 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 KiB

After

Width:  |  Height:  |  Size: 510 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 900 KiB

After

Width:  |  Height:  |  Size: 805 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 997 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 900 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 913 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 989 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 60 KiB

+8
View File
@@ -0,0 +1,8 @@
run:
MODE=DEV go run .
plainrun:
go run .
test:
go test ./...
+1
View File
@@ -0,0 +1 @@
4.2.1
-130
View File
@@ -1,130 +0,0 @@
package main
import (
"errors"
"log/slog"
"time"
"gorm.io/gorm"
)
type ActivityType string
// _AUTO activities are for when logic updates something for the user (automations basically).
var (
ADDED_WATCHED ActivityType = "ADDED_WATCHED"
REMOVED_WATCHED ActivityType = "REMOVED_WATCHED"
RATING_CHANGED ActivityType = "RATING_CHANGED"
STATUS_CHANGED ActivityType = "STATUS_CHANGED"
STATUS_CHANGED_AUTO ActivityType = "STATUS_CHANGED_AUTO"
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_AUTO ActivityType = "SEASON_ADDED_AUTO"
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"
SEASON_STATUS_CHANGED_AUTO ActivityType = "SEASON_STATUS_CHANGED_AUTO"
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 {
GormModel
// ID of user this activity is linked to, so it can be easily
// secured (users can only view their own activities).
UserID uint `json:"-" gorm:"not null"`
// ID of watched list item this activity is linked to.
WatchedID uint `json:"watchedId" gorm:"not null"`
// Type of activity.
Type ActivityType `json:"type" gorm:"not null"`
// 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"`
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) {
activity := new([]Activity)
res := db.Model(&Activity{}).Where("user_id = ? AND watched_id = ?", userId, watchedId).Find(&activity)
if res.Error != nil {
slog.Error("Failed getting activity from database", "error", res.Error.Error())
return []Activity{}, errors.New("failed getting activity")
}
return *activity, nil
}
func addActivity(db *gorm.DB, userId uint, ar ActivityAddRequest) (Activity, error) {
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, CustomDate: ar.CustomDate}
res := db.Create(&activity)
if res.Error != nil {
slog.Error("Error adding activity to database", "error", res.Error.Error())
return Activity{}, errors.New("failed adding new activity to database")
}
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
}
-206
View File
@@ -1,206 +0,0 @@
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"`
}
// Response given to users with PERM_REQUEST_CONTENT - should never include sensitive info
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
}
// Response given to users with PERM_REQUEST_CONTENT - should never include sensitive info
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
}
+70
View File
@@ -0,0 +1,70 @@
package cache
import (
"log/slog"
"reflect"
"strconv"
"github.com/robfig/go-cache"
)
// Extension of the `.Get` method for `go-cache`.
// This method will simplify our usage so we don't need
// to type assert everywhere, this method will handle
// everything related to getting the value from cache.
// Returns `true` if `rv` was set to the cached value.
// Returns `false` if we couldn't get anything from cache.
func GetCache(c *cache.Cache, k string, rv any) bool {
if val, found := c.Get(k); found {
v := reflect.ValueOf(rv)
if v.Type().Kind() == reflect.Ptr && v.Elem().CanSet() {
v.Elem().Set(reflect.ValueOf(val))
slog.Debug("cachefunc: Cache found.", "key", k)
return true
}
slog.Error("cachefunc: Cache not set", "key", k)
return false
}
slog.Debug("cachefunc: Cache not found", "key", k)
return false
}
// Create a cache key for our in-mem cache.
//
// `name` should be the name of the function response we are caching.
//
// `...u` can be any amount of values that will make this key unique.
// Currently supports types:
// - `string`
// - `map[string]string`
// - `int`
func CreateCacheKey(name string, u ...any) string {
str := name
appnd := func(s string) {
str += "-" + s
}
for _, v := range u {
switch vv := v.(type) {
case string:
appnd(vv)
case map[string]string:
for k, e := range vv {
appnd(k + "_" + e)
}
case int:
appnd(strconv.Itoa(vv))
case bool:
if vv {
appnd("1")
} else {
appnd("0")
}
default:
// This should never happen, but incase of unknown
// value passed, hopefully this should make it easier
// to catch in logs.
str = str + "KEYTYPEERR"
}
}
return str
}
+24
View File
@@ -0,0 +1,24 @@
package cfgmodel
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)
}
type RadarrSettings struct {
ArrSettings
QualityProfile int `json:"qualityProfile,omitempty"`
RootFolder int `json:"rootFolder,omitempty"`
AutomaticSearch bool `json:"automaticSearch"`
}
+135 -177
View File
@@ -1,4 +1,4 @@
package main
package config
import (
"encoding/json"
@@ -9,8 +9,10 @@ import (
"path"
"time"
"github.com/sbondCo/Watcharr/game"
"gorm.io/gorm"
"github.com/sbondCo/Watcharr/config/cfgmodel"
"github.com/sbondCo/Watcharr/logging"
"github.com/sbondCo/Watcharr/media/igdb"
"github.com/sbondCo/Watcharr/util"
)
var DataPath = func() string {
@@ -21,6 +23,24 @@ var DataPath = func() string {
return path
}()
type TrustedHeaderAuthSetting struct {
// Required: Should header auth be enabled?
// This bool exists so header auth can be toggled
// easily without having to remove configuration.
// To be actually enabled, HEADER_NAME must also
// be set.
Enabled bool `json:"enabled"`
// Required: What is the name of the trusted header
// that will contain the logged in users username?
HeaderName string `json:"headerName"`
// Should the frontend attempt auto login if
// trusted header auth is enabled.
AutoLogin bool `json:"autoLogin"`
// Where can we redirect the user to logout
// of the auth service?
LogoutUrl string `json:"logoutUrl"`
}
type ServerConfig struct {
// Used to sign JWT tokens. Make sure to make
// it strong, just like a very long, complicated password.
@@ -28,6 +48,7 @@ type ServerConfig struct {
// Default country for new users. This is used to set the default
// region to get correct content streaming providers.
// TODO Enforce iso_3166_1 validity (same as tmdb)
DEFAULT_COUNTRY string `json:",omitempty"`
// Optional: Point to your Jellyfin install
@@ -58,9 +79,9 @@ type ServerConfig struct {
// VERY DANGEROUS if access is not controlled correctly!
HEADER_AUTH TrustedHeaderAuthSetting `json:",omitempty"`
SONARR []SonarrSettings `json:",omitempty"`
RADARR []RadarrSettings `json:",omitempty"`
TWITCH game.IGDB `json:",omitempty"`
SONARR []cfgmodel.SonarrSettings `json:",omitempty"`
RADARR []cfgmodel.RadarrSettings `json:",omitempty"`
TWITCH igdb.IGDB `json:",omitzero"`
// Optional: Schedule for tasks.
TASK_SCHEDULE map[string]int `json:",omitempty"`
@@ -90,7 +111,7 @@ func (c *ServerConfig) GetSafe() ServerConfig {
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{
TWITCH: igdb.IGDB{
ClientID: c.TWITCH.ClientID,
ClientSecret: c.TWITCH.ClientSecret,
}, // Dont act safe, this contains twitch secrets, needed for config
@@ -126,47 +147,117 @@ func (c *ServerConfig) Get(s string) (ServerConfigGetByName, error) {
return ServerConfigGetByName{}, errors.New("invalid setting")
}
var (
// Our server config.. `readConfig` will overwrite from watcharr.json cfg file.
Config = ServerConfig{}
)
// Read config file
// Calls generateConfig if file doesn't exist
func readConfig() error {
cfg, err := os.Open(path.Join(DataPath, "watcharr.json"))
// Update server config property
func (c *ServerConfig) UpdateConfig(k string, v any) error {
slog.Debug("updateConfig", "k", k, "v", v)
if v == nil {
return errors.New("invalid value")
}
if k == "JELLYFIN_HOST" {
c.JELLYFIN_HOST = v.(string)
} else if k == "USE_EMBY" {
c.USE_EMBY = v.(bool)
} else if k == "SIGNUP_ENABLED" {
c.SIGNUP_ENABLED = v.(bool)
} else if k == "TMDB_KEY" {
c.TMDB_KEY = v.(string)
} else if k == "DEBUG" {
c.DEBUG = v.(bool)
logging.SetLevel(c.DEBUG)
} else if k == "DEFAULT_COUNTRY" {
c.DEFAULT_COUNTRY = v.(string)
} else {
return errors.New("invalid setting")
}
err := c.Write()
if err != nil {
if os.IsNotExist(err) {
slog.Info("Config file doesn't exist... generating.")
if err = generateConfig(); err == nil {
return nil
}
}
return err
slog.Error("updateConfig: Failed to write updated config!", "error", err)
return errors.New("failed to write config")
}
defer cfg.Close()
jsonParser := json.NewDecoder(cfg)
if err = jsonParser.Decode(&Config); err != nil {
return err
}
initFromConfig()
return nil
}
// Ensure required config is provided
func initFromConfig() error {
if Config.JWT_SECRET == "" {
log.Fatal("JWT_SECRET missing from config!")
// Write current Config to file
func (c *ServerConfig) Write() error {
barej, err := json.MarshalIndent(*c, "", "\t")
if err != nil {
return err
}
return os.WriteFile(path.Join(DataPath, "watcharr.json"), barej, 0755)
}
func (c *ServerConfig) SaveTwitchConfig(newt igdb.IGDB) error {
// If existing client id and secret are same.. just return here
if (c.TWITCH.ClientID != nil && newt.ClientID != nil && c.TWITCH.ClientSecret != nil && newt.ClientSecret != nil) &&
*c.TWITCH.ClientID == *newt.ClientID && *c.TWITCH.ClientSecret == *newt.ClientSecret {
slog.Info("SaveTwitchConfig: New ClientID and ClientSecret match old ClientID and ClientSecret.. ignoring request to update.")
return nil
}
// Update our config
c.TWITCH.ClientID = newt.ClientID
c.TWITCH.ClientSecret = newt.ClientSecret
c.TWITCH.AccessToken = ""
c.TWITCH.AccessTokenExpires = time.Time{}
// Try to init again
err := c.TWITCH.Init()
if err != nil {
slog.Error("SaveTwitchConfig failed to initialize TWITCH", "error", err)
return errors.New("initialization with credentials failed")
}
err = c.Write()
if err != nil {
slog.Error("SaveTwitchConfig failed to write config", "error", err)
return errors.New("failed to save config")
}
return nil
}
func (c *ServerConfig) TwitchEnabled() bool {
if c.TWITCH.ClientID != nil && c.TWITCH.ClientSecret != nil {
return true
}
return false
}
// Read config file
// Calls generateConfig if file doesn't exist
func read() (*ServerConfig, error) {
cfgFile, err := os.Open(path.Join(DataPath, "watcharr.json"))
if err != nil {
if os.IsNotExist(err) {
slog.Info("Config file doesn't exist... generating.")
if genCfg, err := generateConfig(); err == nil {
return genCfg, nil
}
}
return nil, err
}
defer cfgFile.Close()
c := new(ServerConfig)
dec := json.NewDecoder(cfgFile)
if err = dec.Decode(c); err != nil {
return nil, err
}
initFromConfig(c)
return c, nil
}
// Ensure required config is provided
func initFromConfig(c *ServerConfig) {
if c.JWT_SECRET == "" {
log.Fatal("JWT_SECRET missing from config!")
}
}
// Generate new barebones watcharr.json config file.
// Generates a JWT_SECRET and set default config.
func generateConfig() error {
key, err := generateString(64)
func generateConfig() (*ServerConfig, error) {
key, err := util.GenerateString(64)
if err != nil {
return err
return nil, err
}
cfg := ServerConfig{
JWT_SECRET: key,
@@ -176,150 +267,17 @@ func generateConfig() error {
}
barej, err := json.MarshalIndent(cfg, "", "\t")
if err != nil {
return err
return nil, err
}
Config = cfg
return os.WriteFile(path.Join(DataPath, "watcharr.json"), barej, 0755)
return &cfg, os.WriteFile(path.Join(DataPath, "watcharr.json"), barej, 0755)
}
// Update server config property
func updateConfig(k string, v any) error {
slog.Debug("updateConfig", "k", k, "v", v)
if v == nil {
return errors.New("invalid value")
}
if k == "JELLYFIN_HOST" {
Config.JELLYFIN_HOST = v.(string)
} else if k == "USE_EMBY" {
Config.USE_EMBY = v.(bool)
} else if k == "SIGNUP_ENABLED" {
Config.SIGNUP_ENABLED = v.(bool)
} else if k == "TMDB_KEY" {
Config.TMDB_KEY = v.(string)
} else if k == "DEBUG" {
Config.DEBUG = v.(bool)
setLoggingLevel()
} else if k == "DEFAULT_COUNTRY" {
Config.DEFAULT_COUNTRY = v.(string)
} else {
return errors.New("invalid setting")
}
err := writeConfig()
// Get server config.
// Reads from config file.
func Get() (*ServerConfig, error) {
cfg, err := read()
if err != nil {
slog.Error("updateConfig: Failed to write updated config!", "error", err)
return errors.New("failed to write config")
return nil, err
}
return nil
}
// Write current Config to file
func writeConfig() error {
barej, err := json.MarshalIndent(Config, "", "\t")
if err != nil {
return err
}
return os.WriteFile(path.Join(DataPath, "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
}
if hasPermission(userPerms, PERM_REQUEST_CONTENT) {
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
return cfg, nil
}
-485
View File
@@ -1,485 +0,0 @@
package main
import (
"encoding/json"
"errors"
"log/slog"
"path"
"strconv"
"time"
"github.com/gin-contrib/cache/persistence"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
type ContentType string
const (
MOVIE ContentType = "movie"
SHOW ContentType = "tv"
// Show episode
SHOW_EPISODE ContentType = "tv_episode"
)
var ContentStore = persistence.NewInMemoryStore(time.Hour * 24)
// For storing cached content, so we can serve the basic local data for watched list to work
type Content struct {
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
TmdbID int `json:"tmdbId" gorm:"uniqueIndex:contentidtotypeidx;not null"`
Title string `json:"title"`
PosterPath string `json:"poster_path"`
Overview string `json:"overview"`
Type ContentType `json:"type" gorm:"uniqueIndex:contentidtotypeidx;not null"`
ReleaseDate *time.Time `json:"release_date,omitempty"`
Popularity float32 `json:"popularity"`
VoteAverage float32 `json:"vote_average"`
VoteCount uint32 `json:"vote_count"`
ImdbID string `json:"imdb_id"`
Status string `json:"status"`
Budget uint32 `json:"budget"`
Revenue uint32 `json:"revenue"`
Runtime uint32 `json:"runtime"`
NumberOfEpisodes uint32 `json:"numberOfEpisodes"`
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(DataPath, "img", c.PosterPath), false)
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
}
// Get content from our cache, or cache it if it doesn't exist.
func getOrCacheContent(db *gorm.DB, contentType ContentType, tmdbId int) (Content, error) {
var content Content
// Look in db for content.
db.Where("type = ? AND tmdb_id = ?", contentType, tmdbId).Find(&content)
// Create content if not found from our db.
if content == (Content{}) {
slog.Debug("Content not in db, fetching...", "type", contentType, "tmdbId", tmdbId)
resp, err := tmdbAPIRequest("/"+string(contentType)+"/"+strconv.Itoa(tmdbId), map[string]string{})
if err != nil {
slog.Error("getOrCacheContent: content tmdb api request failed", "error", err)
return Content{}, errors.New("failed to find requested media")
}
if contentType == "movie" {
c := new(TMDBMovieDetails)
err := json.Unmarshal([]byte(resp), &c)
if err != nil {
slog.Error("Failed to unmarshal movie details", "error", err)
return Content{}, errors.New("failed to process movie details response")
}
content, err = cacheContentMovie(db, *c, false)
if err != nil {
slog.Error("getOrCacheContent: failed to cache movie content", "type", contentType, "content_id", tmdbId, "err", err)
return Content{}, errors.New("failed to cache content")
}
} else {
c := new(TMDBShowDetails)
err := json.Unmarshal(resp, &c)
if err != nil {
slog.Error("Failed to unmarshal tv details", "error", err)
return Content{}, errors.New("failed to process tv details response")
}
content, err = cacheContentTv(db, *c, false)
if err != nil {
slog.Error("getOrCacheContent: failed to cache tv content", "type", contentType, "content_id", tmdbId, "err", err)
return Content{}, errors.New("failed to cache content")
}
}
}
return content, 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.
func transformProviders(c *interface{}, country string) {
slog.Debug("transformProviders called", "country", country)
if cmap, ok := (*c).(map[string]interface{}); ok {
if rmap, ok := cmap["results"].(map[string]interface{}); ok {
if val, ok := rmap[country]; ok {
slog.Debug("transformProviders: Found country.. overwriting whole object", "new_obj", val)
if rvmap, ok := val.(map[string]interface{}); ok {
rvmap["country"] = country
}
*c = val
} else {
slog.Warn("transformProviders: Couldn't find country..", "country", country)
}
} else {
slog.Warn("transformProviders: Couldn't find results property..")
}
} else {
slog.Error("transformProviders: Assertion failed")
}
}
func searchContent(query string, pageNum int) (TMDBSearchMultiResponse, error) {
resp := new(TMDBSearchMultiResponse)
if pageNum == 0 {
pageNum = 1
}
err := tmdbRequest("/search/multi", map[string]string{"query": query, "page": strconv.Itoa(pageNum)}, &resp)
if err != nil {
slog.Error("Failed to complete multi search request!", "error", err.Error())
return TMDBSearchMultiResponse{}, errors.New("failed to complete multi search request")
}
return *resp, nil
}
func searchMovies(query string, pageNum int) (TMDBSearchMoviesResponse, error) {
resp := new(TMDBSearchMoviesResponse)
if pageNum == 0 {
pageNum = 1
}
err := tmdbRequest("/search/movie", map[string]string{"query": query, "page": strconv.Itoa(pageNum)}, &resp)
if err != nil {
slog.Error("Failed to complete movie search request!", "error", err.Error())
return TMDBSearchMoviesResponse{}, errors.New("failed to complete movie search request")
}
for i := range resp.Results {
resp.Results[i].MediaType = "movie"
}
return *resp, nil
}
func searchTv(query string, pageNum int) (TMDBSearchShowsResponse, error) {
resp := new(TMDBSearchShowsResponse)
if pageNum == 0 {
pageNum = 1
}
err := tmdbRequest("/search/tv", map[string]string{"query": query, "page": strconv.Itoa(pageNum)}, &resp)
if err != nil {
slog.Error("Failed to complete tv search request!", "error", err.Error())
return TMDBSearchShowsResponse{}, errors.New("failed to complete tv search request")
}
for i := range resp.Results {
resp.Results[i].MediaType = "tv"
}
return *resp, nil
}
func searchPeople(query string, pageNum int) (TMDBSearchPeopleResponse, error) {
resp := new(TMDBSearchPeopleResponse)
if pageNum == 0 {
pageNum = 1
}
err := tmdbRequest("/search/person", map[string]string{"query": query, "page": strconv.Itoa(pageNum)}, &resp)
if err != nil {
slog.Error("Failed to complete people search request!", "error", err.Error())
return TMDBSearchPeopleResponse{}, errors.New("failed to complete people search request")
}
for i := range resp.Results {
resp.Results[i].MediaType = "person"
}
return *resp, nil
}
// Search for content by an external id (imdb, etc).
// Defaults to imdb if no source if provided (probably most common).
func searchByExternalId(id string, source string) (TMDBSearchMultiResponse, error) {
resp := new(TMDBFindByExternalIdResponse)
if source == "" {
source = "imdb"
}
err := tmdbRequest("/find/"+id, map[string]string{"external_source": source + "_id"}, &resp)
if err != nil {
slog.Error("Failed to complete find/external_id request!", "error", err.Error())
return TMDBSearchMultiResponse{}, errors.New("failed to complete find/external_id request")
}
comb := []TMDBSearchMultiResults{}
comb = append(comb, resp.MovieResults...)
comb = append(comb, resp.TvResults...)
comb = append(comb, resp.PersonResults...)
comb = append(comb, resp.TvSeasonResults...)
comb = append(comb, resp.TvEpisodeResults...)
return TMDBSearchMultiResponse{TMDBSearchResponse: TMDBSearchResponse[TMDBSearchMultiResults]{
Results: comb,
TotalResults: len(comb),
// Just providing these so we don't break frontend pagination logic.
TotalPages: 1,
Page: 1,
}}, nil
}
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 {
slog.Error("Failed to complete movie details request!", "error", err.Error())
return TMDBMovieDetails{}, errors.New("failed to complete movie details request")
}
transformProviders(&resp.WatchProviders, country)
go cacheContentMovie(db, *resp, true)
return *resp, nil
}
func movieCredits(id string) (TMDBContentCredits, error) {
resp := new(TMDBContentCredits)
err := tmdbRequest("/movie/"+id+"/credits", map[string]string{}, &resp)
if err != nil {
slog.Error("Failed to complete movie cast request!", "error", err.Error())
return TMDBContentCredits{}, errors.New("failed to complete movie cast request")
}
return *resp, nil
}
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 {
slog.Error("Failed to complete tv details request!", "error", err.Error())
return TMDBShowDetails{}, errors.New("failed to complete tv details request")
}
transformProviders(&resp.WatchProviders, country)
go cacheContentTv(db, *resp, true)
return *resp, nil
}
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!", "error", err.Error())
return TMDBContentCredits{}, errors.New("failed to complete tv cast request")
}
return *resp, nil
}
// This method is manually cached, so it can be easily used in other places (on the server) with cache benefits
func seasonDetails(tvId string, seasonNumber string) (TMDBSeasonDetails, error) {
var cacheKey = "contentstore-seasondetails-" + tvId + "-" + seasonNumber
resp := new(TMDBSeasonDetails)
if err := ContentStore.Get(cacheKey, &resp); err != nil {
if err != persistence.ErrCacheMiss {
slog.Error("seasonDetails: Cache failed for some reason", "error", err)
}
} else {
slog.Debug("seasonDetails: Returning cache.")
return *resp, nil
}
err := tmdbRequest("/tv/"+tvId+"/season/"+seasonNumber, map[string]string{}, &resp)
if err != nil {
slog.Error("seasonDetails: Failed to complete season details request!", "error", err.Error())
return TMDBSeasonDetails{}, errors.New("failed to complete season details request")
}
if err := ContentStore.Set(cacheKey, resp, time.Hour*24); err != nil {
slog.Error("seasonDetails: Failed to set cache!", "error", err)
}
return *resp, nil
}
func personDetails(id string) (TMDBPersonDetails, error) {
resp := new(TMDBPersonDetails)
err := tmdbRequest("/person/"+id, map[string]string{}, &resp)
if err != nil {
slog.Error("Failed to complete person details request!", "error", err.Error())
return TMDBPersonDetails{}, errors.New("failed to complete person details request")
}
return *resp, nil
}
func personCredits(id string) (TMDBPersonCombinedCredits, error) {
resp := new(TMDBPersonCombinedCredits)
err := tmdbRequest("/person/"+id+"/combined_credits", map[string]string{}, &resp)
if err != nil {
slog.Error("Failed to complete person details request!", "error", err.Error())
return TMDBPersonCombinedCredits{}, errors.New("failed to complete person details request")
}
return *resp, nil
}
func discoverMovies() (TMDBDiscoverMovies, error) {
resp := new(TMDBDiscoverMovies)
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")
}
return *resp, nil
}
func discoverTv() (TMDBDiscoverShows, error) {
resp := new(TMDBDiscoverShows)
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")
}
return *resp, nil
}
func allTrending() (TMDBTrendingAll, error) {
resp := new(TMDBTrendingAll)
err := tmdbRequest("/trending/all/day", map[string]string{}, &resp)
if err != nil {
slog.Error("Failed to complete all trending request!", "error", err.Error())
return TMDBTrendingAll{}, errors.New("failed to complete all trending request")
}
return *resp, nil
}
func upcomingMovies() (TMDBUpcomingMovies, error) {
resp := new(TMDBUpcomingMovies)
err := tmdbRequest("/movie/upcoming", map[string]string{"page": "1"}, &resp)
if err != nil {
slog.Error("Failed to complete upcoming movies request!", "error", err.Error())
return TMDBUpcomingMovies{}, errors.New("failed to complete upcoming movies request")
}
return *resp, nil
}
// Theres no upcoming endpoint for tv ;( - using discover with future dates
func upcomingTv() (TMDBUpcomingShows, error) {
resp := new(TMDBUpcomingShows)
dFmt := "2006-01-02"
mind := time.Now().Format(dFmt)
maxd := time.Now().AddDate(0, 0, 15).Format(dFmt)
err := tmdbRequest("/discover/tv", map[string]string{"page": "1", "first_air_date.gte": mind, "first_air_date.lte": maxd, "sort_by": "popularity.desc", "with_type": "2|3"}, &resp)
if err != nil {
slog.Error("Failed to complete upcoming tv request!", "error", err.Error())
return TMDBUpcomingShows{}, errors.New("failed to complete upcoming tv request")
}
return *resp, nil
}
func regions() (TMDBRegions, error) {
resp := new(TMDBRegions)
err := tmdbRequest("/watch/providers/regions", map[string]string{}, &resp)
if err != nil {
slog.Error("Failed to complete regions request!", "error", err.Error())
return TMDBRegions{}, errors.New("failed to complete regions request")
}
return *resp, nil
}
+190
View File
@@ -0,0 +1,190 @@
package database
import (
"log/slog"
"path"
"time"
"github.com/sbondCo/Watcharr/config"
"github.com/sbondCo/Watcharr/database/entity"
"github.com/sbondCo/Watcharr/database/migrate"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
// Create a new database connection.
// Also runs migrations, etc, before returning connection.
// Any error returned from this func should always make our app Exit (caller
// handled).
//
// NOTE: Our mock db used in tests mimics this function, so if this func is
// changed, you should look at the mock db to make it match if it makes
// sense, so our tests stay accurate to prod.
func New() (*gorm.DB, error) {
slog.Info("New: Opening new database connection")
// Open the database.
db, err := gorm.Open(
sqlite.Open(path.Join(config.DataPath, "watcharr.db")),
&gorm.Config{TranslateError: true},
)
if err != nil {
slog.Error("New: Opening database failed.")
return nil, err
}
// Setup the db (migrations, etc)
if err := Setup(db); err != nil {
slog.Error("New: Setting up connection failed!", "error", err)
return nil, err
}
return db, nil
}
// Setup configures our db connection and applies migrations.
//
// NOTE: This exists as a separate function so it can be reused by our testutil
// package that we want to have configured in the same way as the main db so
// that tests reflect real life.
func Setup(db *gorm.DB) error {
if err := configure(db); err != nil {
slog.Error("Setup: Configuring connection failed!", "error", err)
return err
}
// Perform auto migration.
slog.Info("Setup: AutoMigrating")
err := db.AutoMigrate(
&migrate.MigrationRecord{},
&entity.User{},
&entity.UserServices{},
&entity.Content{},
&entity.Watched{},
&entity.WatchedSeason{},
&entity.WatchedEpisode{},
&entity.Activity{},
&entity.Token{},
&entity.Follow{},
&entity.Image{},
&entity.Game{},
&entity.ArrRequest{},
&entity.Tag{},
)
if err != nil {
slog.Error("Setup: Auto migration failed.")
return err
}
slog.Info("Setup: AutoMigrated")
// Perform our manual migrations.
if err := migrate.Now(db); err != nil {
slog.Error("Setup: Manual migrations failed.", "error", err)
return err
}
// Optimize database.
if err := optimize(db); err != nil {
slog.Error("Setup: Optimizing database failed.", "error", err)
return err
}
return nil
}
// Configure our SQLite database connection.
// Some PRAGMAs need to be defined per-connection, so we do that here.
func configure(db *gorm.DB) error {
slog.Info("configure: Configuring connection.")
// Synchronous: https://sqlite.org/pragma.html#pragma_synchronous
// Configured to `FULL` because I'm slightly confused.
// `NORMAL` is recommended for most apps with WAL, but you
// lose "durability", which doesn't sound like a good thing to me...
// personally I'm okay with less performance for the best durability.
if res := db.Exec("PRAGMA synchronous=2"); res.Error != nil {
slog.Error("configure: Configuring synchronous failed!")
return res.Error
}
slog.Info("configure: Configured synchronous.")
return nil
}
// Optimize the database.
func optimize(db *gorm.DB) error {
slog.Info("optimize: Running optimizations.")
// WAL Checkpoint (aka commit anything in the WAL to the main db).
// Seems best to do this to make sure it has happened, especially since
// we are running vacuum next.
// https://sqlite.org/pragma.html#pragma_wal_checkpoint
timeBeforeQuery := time.Now()
if res := db.Exec("PRAGMA wal_checkpoint(TRUNCATE)"); res.Error != nil {
slog.Error("optimize: Checkpoint failed!")
return res.Error
}
slog.Info("optimize: Checkpointed.", "took", time.Since(timeBeforeQuery))
// Optimize pragma.
// Running with recommended argument for our new long-living connection.
// https://sqlite.org/pragma.html#pragma_optimize
timeBeforeQuery = time.Now()
if res := db.Exec("PRAGMA optimize=0x10002"); res.Error != nil {
slog.Error("optimize: Optimize pragma failed!")
return res.Error
}
slog.Info("optimize: Optimize pragma succeeded.",
"took", time.Since(timeBeforeQuery))
// Vacuum.
// > VACUUM rebuilds the database file, repacking it into a minimal amount
// > of disk space.
// https://sqlite.org/lang_vacuum.html
timeBeforeQuery = time.Now()
if res := db.Exec("VACUUM"); res.Error != nil {
slog.Error("optimize: Vacuum failed!")
return res.Error
}
slog.Info("optimize: Vacuumed successfully.",
"took", time.Since(timeBeforeQuery))
// WAL Checkpoint (aka commit anything in the WAL to the main db).
// Do this after vacuum too to ensure we have a clean slate for this
// startup.
// https://sqlite.org/pragma.html#pragma_wal_checkpoint
timeBeforeQuery = time.Now()
if res := db.Exec("PRAGMA wal_checkpoint(TRUNCATE)"); res.Error != nil {
slog.Error("optimize: Checkpoint failed!")
return res.Error
}
slog.Info("optimize: Checkpointed.", "took", time.Since(timeBeforeQuery))
slog.Info("optimize: Done.")
return nil
}
// Optimize task that is scheduled and ran every whenever.
// So this func is for optimzations that we want to re-run every time the
// task is scheduled for.
func TaskOptimize(db *gorm.DB) error {
slog.Info("TaskOptimize: Running optimizations.")
// WAL Checkpoint (aka commit anything in the WAL to the main db).
// To avoid our WAL file becoming huge, we checkpoint regularly.
// https://sqlite.org/pragma.html#pragma_wal_checkpoint
timeBeforeQuery := time.Now()
if res := db.Exec("PRAGMA wal_checkpoint(TRUNCATE)"); res.Error != nil {
slog.Error("TaskOptimize: Checkpoint failed!")
return res.Error
}
slog.Info("TaskOptimize: Checkpointed.",
"took", time.Since(timeBeforeQuery))
// Optimize pragma.
// No args for our task as recommended.
// https://sqlite.org/pragma.html#pragma_optimize
timeBeforeQuery = time.Now()
if res := db.Exec("PRAGMA optimize"); res.Error != nil {
slog.Error("TaskOptimize: Optimize pragma failed!")
return res.Error
}
slog.Info("TaskOptimize: Optimize pragma succeeded.",
"took", time.Since(timeBeforeQuery))
slog.Info("TaskOptimize: Done.")
return nil
}
+22
View File
@@ -0,0 +1,22 @@
package dbmodel
import (
"time"
"gorm.io/gorm"
)
type GormModel struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"`
}
// Same as GormModel, but without the DeletedAt field,
// so use this for tables where we don't need soft deletion.
type GormModelNoDel struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
+71
View File
@@ -0,0 +1,71 @@
package entity
import (
"time"
"github.com/sbondCo/Watcharr/database/dbmodel"
)
type ActivityType string
// _AUTO activities are for when logic updates something for the user (automations basically).
var (
ADDED_WATCHED ActivityType = "ADDED_WATCHED"
REMOVED_WATCHED ActivityType = "REMOVED_WATCHED"
RATING_CHANGED ActivityType = "RATING_CHANGED"
STATUS_CHANGED ActivityType = "STATUS_CHANGED"
STATUS_CHANGED_AUTO ActivityType = "STATUS_CHANGED_AUTO"
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_AUTO ActivityType = "SEASON_ADDED_AUTO"
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"
SEASON_STATUS_CHANGED_AUTO ActivityType = "SEASON_STATUS_CHANGED_AUTO"
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 {
dbmodel.GormModel
// ID of user this activity is linked to, so it can be easily
// secured (users can only view their own activities).
UserID uint `json:"-" gorm:"not null"`
// ID of watched list item this activity is linked to.
WatchedID uint `json:"watchedId" gorm:"not null;index"`
// Type of activity.
Type ActivityType `json:"type" gorm:"not null"`
// 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"`
// Count this Activity as a Play?
// Currently this was the best way I could see forward for implementing
// counting plays of media that doesn't involve inefficient querying of
// the actitivties table (or a whole new table, which would create extra
// complexities itself, ie, plays/activity showing different records).
// We write to this field when creating the activity to count is as a play
// or not (ie when we create STATUS CHANGE activities with status of
// FINISHED, imports, etc).
// We won't support the user (or the system) modifying this value after
// creation; if the user wants to delete a 'Play', they should delete the
// activity.
// Indexed (check migrations) to make search faster, since we frequently
// do it over the whole table for watched sorting at the moment.
CountAsPlay bool `json:"countAsPlay"`
}
+40
View File
@@ -0,0 +1,40 @@
package entity
import "time"
type ArrRequestStatus string
const (
// Pending approval from an admin.
ARR_REQUEST_PENDING ArrRequestStatus = "PENDING"
// Request has been approved and should be added to sonarr/radarr.
ARR_REQUEST_APPROVED ArrRequestStatus = "APPROVED"
ARR_REQUEST_AUTO_APPROVED ArrRequestStatus = "AUTO_APPROVED"
// Request has been denied, not adding content.
ARR_REQUEST_DENIED ArrRequestStatus = "DENIED"
// Content was found on sonarr/radarr already, nothing needs to be done.
ARR_REQUEST_FOUND ArrRequestStatus = "FOUND"
)
type ArrRequest struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
UserID uint `json:"-" gorm:"not null"`
User User `json:"-"`
// Username of `User`.
// We don't want to send back the entire user object, just their name.
// Not stored in DB, only used for our response from api.
Username string `json:"username" gorm:"-"`
ContentID *int `json:"-" gorm:"uniqueIndex:sn_to_cid;not null"`
Content *Content `json:"content,omitempty"`
// Server names are used as an identifier
ServerName string `json:"serverName" gorm:"uniqueIndex:sn_to_cid;not null"`
// Sonarr/Radarrs seriesId/movieId
ArrID int `json:"arrId"`
// Tracked request status
Status ArrRequestStatus `json:"status" gorm:"default:PENDING"`
// Full request made by user (arr.SonarrRequest / arr.RadarrRequest)
// so we know how to fulfil the request if approved.
RequestJson string `json:"requestJson"`
}
+77
View File
@@ -0,0 +1,77 @@
package entity
import (
"time"
"github.com/golang-jwt/jwt/v5"
)
type UserType uint8
var (
WATCHARR_USER UserType = 0
JELLYFIN_USER UserType = 1
PLEX_USER UserType = 2
// Registered via trusted header auth
PROXY_USER UserType = 3
)
// User Perms
// iota auto increments for us so when adding new
// perms, add to bottom as to not change other perm
// values.
const (
PERM_NONE int = 1 << iota
PERM_ADMIN
PERM_REQUEST_CONTENT
PERM_REQUEST_CONTENT_AUTO_APPROVE
)
// 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:"-"`
}
type ArgonParams struct {
Memory uint32
Iterations uint32
Parallelism uint8
SaltLength uint32
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"`
Type UserType `json:"type"`
jwt.RegisteredClaims
}
+52
View File
@@ -0,0 +1,52 @@
package entity
import (
"time"
"github.com/sbondCo/Watcharr/util"
)
type ContentType string
const (
MOVIE ContentType = "movie"
SHOW ContentType = "tv"
// Show episode
SHOW_EPISODE ContentType = "tv_episode"
)
// For storing cached content, so we can serve the basic local data for watched list to work
type Content struct {
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
TmdbID int `json:"tmdbId" gorm:"uniqueIndex:contentidtotypeidx;not null"`
Title string `json:"title"`
PosterPath string `json:"poster_path"`
Overview string `json:"overview"`
Type ContentType `json:"type" gorm:"uniqueIndex:contentidtotypeidx;not null"`
ReleaseDate *time.Time `json:"release_date,omitempty"`
Popularity float32 `json:"popularity"`
VoteAverage float32 `json:"vote_average"`
VoteCount uint32 `json:"vote_count"`
ImdbID string `json:"imdb_id"`
Status string `json:"status"`
Budget uint32 `json:"budget"`
Revenue uint32 `json:"revenue"`
Runtime uint32 `json:"runtime"`
NumberOfEpisodes uint32 `json:"numberOfEpisodes"`
NumberOfSeasons uint32 `json:"numberOfSeasons"`
}
// NOTE: Can return empty string, so use only when we know that a valid option
// will be returned or we are okay with that.
func (c *Content) GetTypeSupportedMedia() util.SupportedMedia {
if c == nil {
return ""
}
switch c.Type {
case MOVIE:
return util.SupportedMediaMovie
case SHOW:
return util.SupportedMediaShow
}
return ""
}
+13
View File
@@ -0,0 +1,13 @@
package entity
import "time"
// 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:"-"`
}
+27
View File
@@ -0,0 +1,27 @@
package entity
import "time"
// 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"`
}
+15
View File
@@ -0,0 +1,15 @@
package entity
import "time"
// 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"`
}
+17
View File
@@ -0,0 +1,17 @@
package entity
import "github.com/sbondCo/Watcharr/database/dbmodel"
type Tag struct {
dbmodel.GormModel
// ID of user that own this tag.
UserID uint `json:"-" gorm:"not null"`
// Name of the tag.
Name string `json:"name" gorm:"not null"`
// Hex of text color.
Color string `json:"color"`
// Hex of background color.
BgColor string `json:"bgColor"`
// All watched items.
Watched []Watched `json:"watched,omitempty" gorm:"many2many:watched_tags;"`
}
+17
View File
@@ -0,0 +1,17 @@
package entity
import "time"
type TokenType string
var (
TOKENTYPE_ADMIN TokenType = "ADMIN"
)
type Token struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time `json:"createdAt"`
Value string `gorm:"not null"`
Type TokenType `gorm:"not null"`
UserID uint `gorm:"not null"`
}
+85
View File
@@ -0,0 +1,85 @@
package entity
import (
"github.com/sbondCo/Watcharr/database/dbmodel"
)
// uniqueIndex applied between Username and UserType, so same usernames can exist, but only with different types.
// This is incase different users with same name from different services try to signup.
type User struct {
dbmodel.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"`
// ID of user from the third party service, this will be used purely for lookup of user at signin.
ThirdPartyID string `json:"-"`
// Auth token from third party (jellyfin)
ThirdPartyAuth string `json:"-"`
// Users third party integrations (minus jellyfin for now)
UserServices []UserServices `json:"-"`
Watched []Watched
// All Tags
Tags []Tag `json:"-"`
// Users permissions
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"`
// 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"`
// User's country to get correct content streaming providers.
// TODO Enforce iso_3166_1 validity (same as tmdb)
Country *string `gorm:"default:'US'" json:"country"`
// Does the user want show, season and episode automations enabled.
AutomateShowStatuses *bool `gorm:"default:true" json:"automateShowStatuses"`
// Rating system user wants to use (frontend only).
// RatingSystem enum in frontend maxes out at 3, so just max=3 on this and we should be gut.
RatingSystem *int `json:"ratingSystem" binding:"omitempty,max=3"`
// Rating step for supported rating systems (frontend only, enum goes up to 2).
RatingStep *int `json:"ratingStep" binding:"omitempty,max=2"`
}
// Public user details for search results
type PublicUser struct {
ID uint `json:"id"`
Username string `json:"username"`
AvatarID uint `json:"-"`
Avatar Image `json:"avatar,omitzero"`
Bio string `json:"bio,omitempty"`
}
// Private user details, for returning users details to themselves
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"`
}
+48
View File
@@ -0,0 +1,48 @@
package entity
import "github.com/sbondCo/Watcharr/database/dbmodel"
type WatchedStatus string
const (
FINISHED WatchedStatus = "FINISHED"
WATCHING WatchedStatus = "WATCHING"
PLANNED WatchedStatus = "PLANNED"
HOLD WatchedStatus = "HOLD"
DROPPED WatchedStatus = "DROPPED"
)
func (r WatchedStatus) IsValid() bool {
switch r {
case FINISHED,
WATCHING,
PLANNED,
HOLD,
DROPPED:
return true
}
return false
}
type Watched struct {
dbmodel.GormModel
Status WatchedStatus `json:"status"`
// float so we can support decimal ratings.
// Ratings should still always be saved as out of 10.0,
// so they can be viewed with any ratings setting in the client.
Rating float64 `json:"rating" gorm:"type:numeric(2,1)"`
Thoughts string `json:"thoughts"`
Pinned bool `json:"pinned" gorm:"default:false;not null"`
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
Tags []Tag `json:"tags,omitempty" gorm:"many2many:watched_tags;"`
// The last season that was viewed by the user for this watched entry.
// Only applies to tv shows of course.
LastViewedSeason *int `json:"lastViewedSeason,omitempty"`
}

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