Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(activity/livevideo): attempt to update livestream archive with the external vod id #347

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions internal/activities/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,32 @@ func DownloadTwitchLiveVideo(ctx context.Context, input dto.ArchiveVideoInput, c
return dbErr
}

// attempt to find vod id of the livesstream so the external id is correct
videos, err := twitch.GetVideosByUser(input.Channel.ExtID, "archive")
if err != nil {
cancel()
return temporal.NewApplicationError(err.Error(), "", nil)
}

// attempt to find vod of current livestream
var livestreamVodId string
for _, video := range videos {
if video.StreamID == input.Vod.ExtID {
livestreamVodId = video.ID
log.Info().Msgf("found vod id %s for livestream %s, updating database", livestreamVodId, input.Vod.ExtID)
// update vod with external id
_, dbErr = database.DB().Client.Vod.UpdateOneID(input.Vod.ID).SetExtID(livestreamVodId).Save(ctx)
if dbErr != nil {
cancel()
return temporal.NewApplicationError(err.Error(), "", nil)
}
}
}

if livestreamVodId == "" {
log.Info().Msgf("no vod found for livestream %s, keeping live stream ID as external id", input.Vod.ExtID)
}

cancel()
return nil
}
Expand Down
Loading