Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3de15af
feat(episodes): add episode availability tracking and sync
0xSysR3ll Apr 25, 2026
424686c
chore(tv): removed the wrong parameter.
0xSysR3ll Sep 3, 2025
08f9291
feat(settings): make the feature optionnal
0xSysR3ll Apr 25, 2026
5150495
fix(ui): only display availability if provider is tvdb
0xSysR3ll Apr 25, 2026
ec2da54
fix(api): only mark episode as available if provider is tvdb
0xSysR3ll Apr 25, 2026
341fc67
fix(cypress): add missing newline
0xSysR3ll Apr 25, 2026
b0fbdaa
fix(tv): rely on provider type instead of setting
0xSysR3ll Apr 25, 2026
d1575af
feat(settings): add metadata settings for TV and anime
0xSysR3ll Apr 25, 2026
87367d0
refactor(tv): simplify episode availability checks
0xSysR3ll Apr 25, 2026
7511054
fix(settings): missing metadata settings
0xSysR3ll Apr 25, 2026
32b513f
feat(availability): implement episode caching
0xSysR3ll Apr 25, 2026
bf4b330
refactor(season): make episodes property optional and remove eager lo…
0xSysR3ll Apr 25, 2026
9bc7ef6
refactor(api): remove getEpisodesBySeriesId method and update availab…
0xSysR3ll Apr 25, 2026
c865f88
chore: apply linting
0xSysR3ll Apr 25, 2026
25334fa
refactor(tv): change getSettings to synchronous call
0xSysR3ll Apr 25, 2026
2708293
refactor(availability): enhance episode tracking logic in availabilit…
0xSysR3ll Apr 25, 2026
3750dde
chore: restore old changes
0xSysR3ll Apr 25, 2026
fc42626
chore: reapply linting
0xSysR3ll Apr 25, 2026
0bfba86
feat(migration): add episode table migrations
0xSysR3ll Apr 25, 2026
b0207ae
feat(episode): add index on season
0xSysR3ll Apr 25, 2026
8cfa30e
feat(settings): add warning for episode availability without TVDB set
0xSysR3ll Apr 25, 2026
813ae1e
refactor(migration): replace old episode table migration with to incl…
0xSysR3ll Apr 25, 2026
26f9390
refactor(episode): move index on ManyToOne relationship with Season
0xSysR3ll Apr 25, 2026
fae2ae6
refactor(Episode): we shouldn't use onUpdate
0xSysR3ll Apr 25, 2026
48de4fc
feat: update migrations
0xSysR3ll Apr 25, 2026
371dc7a
chore: remove old migrations
0xSysR3ll Apr 25, 2026
713da44
chore: upgrade migrations
0xSysR3ll May 7, 2026
047e60d
chore: update db migrations
0xSysR3ll Jun 7, 2026
3cc7551
fix: omit episode availability when tracking is disabled
0xSysR3ll Jun 13, 2026
b17f2a5
fix(tv): handle episode number mismatches in availability checks
0xSysR3ll Jun 13, 2026
2b9bb5d
fix: clarify tracking message in settings
0xSysR3ll Jun 13, 2026
68da743
refactor: load episode relations only in the season route
0xSysR3ll Aug 6, 2026
270b450
fix: keep episode availability out of availability sync
0xSysR3ll Aug 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cypress/config/settings.cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"mediaServerType": 1,
"partialRequestsEnabled": true,
"enableSpecialEpisodes": false,
"enableEpisodeAvailability": false,
"locale": "en"
},
"plex": {
Expand Down
5 changes: 5 additions & 0 deletions seerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ components:
enableSpecialEpisodes:
type: boolean
example: false
enableEpisodeAvailability:
type: boolean
example: false
versionCheck:
type: boolean
example: false
Expand Down Expand Up @@ -1072,6 +1075,8 @@ components:
type: number
voteCount:
type: number
available:
type: boolean
Season:
type: object
properties:
Expand Down
2 changes: 1 addition & 1 deletion server/api/servarr/sonarr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface SonarrSeason {
percentOfEpisodes: number;
};
}
interface EpisodeResult {
export interface EpisodeResult {
seriesId: number;
episodeFileId: number;
seasonNumber: number;
Expand Down
50 changes: 50 additions & 0 deletions server/entity/Episode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { MediaStatus } from '@server/constants/media';
import { DbAwareColumn, resolveDbType } from '@server/utils/DbColumnHelper';
import {
Column,
Entity,
Index,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import Season from './Season';

@Entity()
class Episode {
@PrimaryGeneratedColumn()
public id: number;

@Column()
public episodeNumber: number;

@Column({ type: 'int', default: MediaStatus.UNKNOWN })
public status: MediaStatus;

@Column({ type: 'int', default: MediaStatus.UNKNOWN })
public status4k: MediaStatus;

@Index()
@ManyToOne(() => Season, (season: Season) => season.episodes, {
onDelete: 'CASCADE',
nullable: true,
})
public season?: Promise<Season>;
Comment thread
0xSysR3ll marked this conversation as resolved.

@DbAwareColumn({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' })
public createdAt: Date;

@UpdateDateColumn({
type: resolveDbType('datetime'),
default: () => 'CURRENT_TIMESTAMP',
})
public updatedAt: Date;

constructor(init?: Partial<Episode>) {
if (init) {
Object.assign(this, init);
}
}
}

export default Episode;
7 changes: 7 additions & 0 deletions server/entity/Season.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import {
Entity,
Index,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import Episode from './Episode';
import Media from './Media';

@Entity()
Expand All @@ -30,6 +32,11 @@ class Season {
@Index()
public media: Promise<Media>;

@OneToMany(() => Episode, (episode) => episode.season, {
cascade: true,
})
public episodes?: Episode[];
Comment thread
0xSysR3ll marked this conversation as resolved.

@DbAwareColumn({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' })
public createdAt: Date;

Expand Down
5 changes: 5 additions & 0 deletions server/interfaces/api/settingsInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface PublicSettingsResponse {
mediaServerType: number;
partialRequestsEnabled: boolean;
enableSpecialEpisodes: boolean;
enableEpisodeAvailability: boolean;
cacheImages: boolean;
vapidPublic: string;
enablePushRegistration: boolean;
Expand All @@ -49,6 +50,10 @@ export interface PublicSettingsResponse {
newPlexLogin: boolean;
youtubeUrl: string;
versionCheck: boolean;
metadataSettings: {
tv: string;
anime: string;
};
plexClientIdentifier: string;
}

Expand Down
39 changes: 19 additions & 20 deletions server/lib/availabilitySync.ts
Comment thread
0xSysR3ll marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,25 @@ class AvailabilitySync {
let showExists = false;
let showExists4k = false;

// Fetch TMDB details once for season enrichment
let tvShow: TmdbTvDetails | undefined;
try {
if (media.tmdbId) {
tvShow = await this.tmdb.getTvShow({
tvId: Number(media.tmdbId),
});
} else if (media.tvdbId) {
tvShow = await this.tmdb.getShowByTvdbId({
tvdbId: Number(media.tvdbId),
});
}
} catch (e) {
logger.debug(
`Failed to fetch TMDB data for show [TMDB ID ${media.tmdbId}]. Skipping season enrichment.`,
{ label: 'AvailabilitySync', errorMessage: e.message }
);
}

//plex

const { existsInPlex, seasonsMap: plexSeasonsMap = new Map() } =
Expand Down Expand Up @@ -360,26 +379,6 @@ class AvailabilitySync {
...sonarrSeasonsMap4k,
]);
}

// We need to fetch from TMDB to get the episode count for each season
let tvShow: TmdbTvDetails | undefined;
try {
if (media.tmdbId) {
tvShow = await this.tmdb.getTvShow({
tvId: Number(media.tmdbId),
});
} else if (media.tvdbId) {
tvShow = await this.tmdb.getShowByTvdbId({
tvdbId: Number(media.tvdbId),
});
}
} catch (e) {
logger.debug(
`Failed to fetch TMDB data for show [TMDB ID ${media.tmdbId}]. Skipping season enrichment.`,
{ label: 'AvailabilitySync', errorMessage: e.message }
);
}

if (tvShow) {
// fill the finalSeasons and finalSeasons4k maps with false for missing seasons
media.seasons.forEach((season) => {
Expand Down
6 changes: 6 additions & 0 deletions server/lib/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export interface MainSettings {
mediaServerType: number;
partialRequestsEnabled: boolean;
enableSpecialEpisodes: boolean;
enableEpisodeAvailability: boolean;
locale: string;
youtubeUrl: string;
versionCheck: boolean;
Expand Down Expand Up @@ -207,6 +208,7 @@ interface FullPublicSettings extends PublicSettings {
jellyfinServerName?: string;
partialRequestsEnabled: boolean;
enableSpecialEpisodes: boolean;
enableEpisodeAvailability: boolean;
cacheImages: boolean;
vapidPublic: string;
enablePushRegistration: boolean;
Expand All @@ -216,6 +218,7 @@ interface FullPublicSettings extends PublicSettings {
newPlexLogin: boolean;
youtubeUrl: string;
versionCheck: boolean;
metadataSettings: MetadataSettings;
plexClientIdentifier: string;
}

Expand Down Expand Up @@ -429,6 +432,7 @@ class Settings {
mediaServerType: MediaServerType.NOT_CONFIGURED,
partialRequestsEnabled: true,
enableSpecialEpisodes: false,
enableEpisodeAvailability: false,
locale: 'en',
youtubeUrl: '',
versionCheck: true,
Expand Down Expand Up @@ -728,6 +732,7 @@ class Settings {
mediaServerType: this.main.mediaServerType,
partialRequestsEnabled: this.data.main.partialRequestsEnabled,
enableSpecialEpisodes: this.data.main.enableSpecialEpisodes,
enableEpisodeAvailability: this.data.main.enableEpisodeAvailability,
cacheImages: this.data.main.cacheImages,
vapidPublic: this.vapidPublic,
enablePushRegistration: this.data.notifications.agents.webpush.enabled,
Expand All @@ -738,6 +743,7 @@ class Settings {
newPlexLogin: this.data.main.newPlexLogin,
youtubeUrl: this.data.main.youtubeUrl,
versionCheck: this.data.main.versionCheck,
metadataSettings: this.data.metadataSettings,
plexClientIdentifier: this.data.clientId,
};
}
Expand Down
27 changes: 27 additions & 0 deletions server/migration/postgres/1780843263648-AddEpisodeTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class AddEpisodeTable1780843263648 implements MigrationInterface {
name = 'AddEpisodeTable1780843263648';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "episode" ("id" SERIAL NOT NULL, "episodeNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT '1', "status4k" integer NOT NULL DEFAULT '1', "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "seasonId" integer, CONSTRAINT "PK_7258b95d6d2bf7f621845a0e143" PRIMARY KEY ("id"))`
);
await queryRunner.query(
`CREATE INDEX "IDX_e73d28c1e5e3c85125163f7c9c" ON "episode" ("seasonId") `
);
await queryRunner.query(
`ALTER TABLE "episode" ADD CONSTRAINT "FK_e73d28c1e5e3c85125163f7c9cd" FOREIGN KEY ("seasonId") REFERENCES "season"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "episode" DROP CONSTRAINT "FK_e73d28c1e5e3c85125163f7c9cd"`
);
await queryRunner.query(
`DROP INDEX "public"."IDX_e73d28c1e5e3c85125163f7c9c"`
);
await queryRunner.query(`DROP TABLE "episode"`);
}
}
103 changes: 103 additions & 0 deletions server/migration/sqlite/1780843239768-AddEpisodeTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class AddEpisodeTable1780843239768 implements MigrationInterface {
name = 'AddEpisodeTable1780843239768';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "IDX_03f7958328e311761b0de675fb"`);
await queryRunner.query(
`CREATE TABLE "temporary_user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (CURRENT_TIMESTAMP), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "UQ_6427d07d9a171a3a1ab87480005" UNIQUE ("endpoint", "userId"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
);
await queryRunner.query(
`INSERT INTO "temporary_user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "user_push_subscription"`
);
await queryRunner.query(`DROP TABLE "user_push_subscription"`);
await queryRunner.query(
`ALTER TABLE "temporary_user_push_subscription" RENAME TO "user_push_subscription"`
);
await queryRunner.query(
`CREATE INDEX "IDX_03f7958328e311761b0de675fb" ON "user_push_subscription" ("userId") `
);
await queryRunner.query(
`CREATE TABLE "episode" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "episodeNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT (1), "status4k" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "updatedAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "seasonId" integer)`
);
await queryRunner.query(
`CREATE INDEX "IDX_e73d28c1e5e3c85125163f7c9c" ON "episode" ("seasonId") `
);
await queryRunner.query(`DROP INDEX "IDX_03f7958328e311761b0de675fb"`);
await queryRunner.query(
`CREATE TABLE "temporary_user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (CURRENT_TIMESTAMP), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "UQ_6427d07d9a171a3a1ab87480005" UNIQUE ("endpoint", "userId"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
);
await queryRunner.query(
`INSERT INTO "temporary_user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "user_push_subscription"`
);
await queryRunner.query(`DROP TABLE "user_push_subscription"`);
await queryRunner.query(
`ALTER TABLE "temporary_user_push_subscription" RENAME TO "user_push_subscription"`
);
await queryRunner.query(
`CREATE INDEX "IDX_03f7958328e311761b0de675fb" ON "user_push_subscription" ("userId") `
);
await queryRunner.query(`DROP INDEX "IDX_e73d28c1e5e3c85125163f7c9c"`);
await queryRunner.query(
`CREATE TABLE "temporary_episode" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "episodeNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT (1), "status4k" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "updatedAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "seasonId" integer, CONSTRAINT "FK_e73d28c1e5e3c85125163f7c9cd" FOREIGN KEY ("seasonId") REFERENCES "season" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
);
await queryRunner.query(
`INSERT INTO "temporary_episode"("id", "episodeNumber", "status", "status4k", "createdAt", "updatedAt", "seasonId") SELECT "id", "episodeNumber", "status", "status4k", "createdAt", "updatedAt", "seasonId" FROM "episode"`
);
await queryRunner.query(`DROP TABLE "episode"`);
await queryRunner.query(
`ALTER TABLE "temporary_episode" RENAME TO "episode"`
);
await queryRunner.query(
`CREATE INDEX "IDX_e73d28c1e5e3c85125163f7c9c" ON "episode" ("seasonId") `
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "IDX_e73d28c1e5e3c85125163f7c9c"`);
await queryRunner.query(
`ALTER TABLE "episode" RENAME TO "temporary_episode"`
);
await queryRunner.query(
`CREATE TABLE "episode" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "episodeNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT (1), "status4k" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "updatedAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "seasonId" integer)`
);
await queryRunner.query(
`INSERT INTO "episode"("id", "episodeNumber", "status", "status4k", "createdAt", "updatedAt", "seasonId") SELECT "id", "episodeNumber", "status", "status4k", "createdAt", "updatedAt", "seasonId" FROM "temporary_episode"`
);
await queryRunner.query(`DROP TABLE "temporary_episode"`);
await queryRunner.query(
`CREATE INDEX "IDX_e73d28c1e5e3c85125163f7c9c" ON "episode" ("seasonId") `
);
await queryRunner.query(`DROP INDEX "IDX_03f7958328e311761b0de675fb"`);
await queryRunner.query(
`ALTER TABLE "user_push_subscription" RENAME TO "temporary_user_push_subscription"`
);
await queryRunner.query(
`CREATE TABLE "user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (CURRENT_TIMESTAMP), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "UQ_6427d07d9a171a3a1ab87480005" UNIQUE ("endpoint", "userId"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
);
await queryRunner.query(
`INSERT INTO "user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "temporary_user_push_subscription"`
);
await queryRunner.query(`DROP TABLE "temporary_user_push_subscription"`);
await queryRunner.query(
`CREATE INDEX "IDX_03f7958328e311761b0de675fb" ON "user_push_subscription" ("userId") `
);
await queryRunner.query(`DROP INDEX "IDX_e73d28c1e5e3c85125163f7c9c"`);
await queryRunner.query(`DROP TABLE "episode"`);
await queryRunner.query(`DROP INDEX "IDX_03f7958328e311761b0de675fb"`);
await queryRunner.query(
`ALTER TABLE "user_push_subscription" RENAME TO "temporary_user_push_subscription"`
);
await queryRunner.query(
`CREATE TABLE "user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (CURRENT_TIMESTAMP), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "UQ_6427d07d9a171a3a1ab87480005" UNIQUE ("endpoint", "userId"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
);
await queryRunner.query(
`INSERT INTO "user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "temporary_user_push_subscription"`
);
await queryRunner.query(`DROP TABLE "temporary_user_push_subscription"`);
await queryRunner.query(
`CREATE INDEX "IDX_03f7958328e311761b0de675fb" ON "user_push_subscription" ("userId") `
);
}
}
Loading
Loading