Skip to content

Commit

Permalink
Merge pull request #511 from neet/add-missing-url
Browse files Browse the repository at this point in the history
fix: Add missing url in performer insertion
  • Loading branch information
neet committed Nov 9, 2022
2 parents 21d6d7c + 6e1d1c4 commit 8845ea8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class PerformerRepository implements IPerformerRepository {
name: performer.name.value,
description: unwrap(performer.description),
color: performer.color.hex(),
url: performer.url?.toString(),
youtubeChannelId: unwrap(performer.youtubeChannelId),
twitterUsername: unwrap(performer.twitterUsername),
avatarId:
Expand Down Expand Up @@ -70,6 +71,7 @@ export class PerformerRepository implements IPerformerRepository {
name: performer.name.value,
color: performer.color.hex(),
description: unwrap(performer.description),
url: performer.url?.toString(),
youtubeChannelId: unwrap(performer.youtubeChannelId),
twitterUsername: unwrap(performer.twitterUsername),
avatarId:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export class CreateStream {
title: video.title,
url: new URL(video.url),
description: video.description,
startedAt: dayjs(video.startedAt),
endedAt: dayjs(video.endedAt),
startedAt: video.startedAt != null ? dayjs(video.startedAt) : dayjs(),
endedAt: video.endedAt != null ? dayjs(video.endedAt) : null,
ownerId: performer.id,
castIds: casts.map((cast) => cast.id),
thumbnail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,31 @@ export class YoutubeApiService implements IYoutubeApiService {
video.snippet.description == null ||
video.snippet.publishedAt == null ||
video.snippet.thumbnails?.maxres?.url == null
// video.liveStreamingDetails?.actualStartTime == null
) {
throw new Error(
`Either videoId or publishedAt or actualStartTime is null`,
);
}

const startedAt =
video.liveStreamingDetails?.actualStartTime ??
video.liveStreamingDetails?.scheduledStartTime;

const endedAt =
video.liveStreamingDetails?.actualEndTime ??
video.liveStreamingDetails?.scheduledEndTime;

if (startedAt == null) {
this._logger.error(
`Failed to infer start time. Both actualStartTime and scheduledStartTime were null`,
{ videoId, liveStreamingDetails: video.liveStreamingDetails },
);

throw new Error(
`Failed to infer start time. Both actualStartTime and scheduledStartTime were null`,
);
}

return {
id: video.id,
title: video.snippet.title,
Expand All @@ -81,8 +99,8 @@ export class YoutubeApiService implements IYoutubeApiService {
url: `https://www.youtube.com/watch?v=${video.id}`,
channelId: video.snippet.channelId,
publishedAt: video.snippet.publishedAt,
startedAt: video.liveStreamingDetails?.actualStartTime,
endedAt: video.liveStreamingDetails?.actualEndTime ?? undefined,
startedAt,
endedAt,
};
}

Expand Down

1 comment on commit 8845ea8

@vercel
Copy link

@vercel vercel bot commented on 8845ea8 Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.