Skip to content

Commit

Permalink
fix: nullable type for jellyfinMediaId(4k) (#702)
Browse files Browse the repository at this point in the history
The jellyfinMediaId(4k) properties were inferred as string | undefined, causing them to be set to
undefined when assigning null. This prevented the media from being saved correctly to the SQLite
database, as it doesn't accept undefined values. This resolves the availabilitySync job issue where
the "play on" button wasn't being removed for all media server types.

fix #668
  • Loading branch information
Fallenbagel authored Mar 31, 2024
1 parent 0c86684 commit 0900a95
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions server/entity/Media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ class Media {
@Column({ nullable: true, type: 'varchar' })
public ratingKey4k?: string | null;

@Column({ nullable: true })
public jellyfinMediaId?: string;
@Column({ nullable: true, type: 'varchar' })
public jellyfinMediaId?: string | null;

@Column({ nullable: true })
public jellyfinMediaId4k?: string;
@Column({ nullable: true, type: 'varchar' })
public jellyfinMediaId4k?: string | null;

public serviceUrl?: string;
public serviceUrl4k?: string;
Expand Down
4 changes: 2 additions & 2 deletions server/lib/availabilitySync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,15 +548,15 @@ class AvailabilitySync {
media[is4k ? 'ratingKey4k' : 'ratingKey'] =
mediaStatus === MediaStatus.PROCESSING
? media[is4k ? 'ratingKey4k' : 'ratingKey']
: undefined;
: null;
} else if (
mediaServerType === MediaServerType.JELLYFIN ||
mediaServerType === MediaServerType.EMBY
) {
media[is4k ? 'jellyfinMediaId4k' : 'jellyfinMediaId'] =
mediaStatus === MediaStatus.PROCESSING
? media[is4k ? 'jellyfinMediaId4k' : 'jellyfinMediaId']
: undefined;
: null;
}
logger.info(
`The ${is4k ? '4K' : 'non-4K'} ${
Expand Down
8 changes: 4 additions & 4 deletions server/lib/scanners/jellyfin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ class JellyfinScanner {
newMedia.jellyfinMediaId =
hasOtherResolution || (!this.enable4kMovie && has4k)
? metadata.Id
: undefined;
: null;
newMedia.jellyfinMediaId4k =
has4k && this.enable4kMovie ? metadata.Id : undefined;
has4k && this.enable4kMovie ? metadata.Id : null;
await mediaRepository.save(newMedia);
this.log(`Saved ${metadata.Name}`);
}
Expand Down Expand Up @@ -461,9 +461,9 @@ class JellyfinScanner {
tmdbId: tvShow.id,
tvdbId: tvShow.external_ids.tvdb_id,
mediaAddedAt: new Date(metadata.DateCreated ?? ''),
jellyfinMediaId: isAllStandardSeasons ? Id : undefined,
jellyfinMediaId: isAllStandardSeasons ? Id : null,
jellyfinMediaId4k:
isAll4kSeasons && this.enable4kShow ? Id : undefined,
isAll4kSeasons && this.enable4kShow ? Id : null,
status: isAllStandardSeasons
? MediaStatus.AVAILABLE
: newSeasons.some(
Expand Down

0 comments on commit 0900a95

Please sign in to comment.