Skip to content

Commit

Permalink
Merge pull request #347 from Zibbp/livestream-update-id-346
Browse files Browse the repository at this point in the history
feat(activity/livevideo): attempt to update livestream archive with the external vod id
  • Loading branch information
Zibbp authored Jan 7, 2024
2 parents 856d300 + ec9fce5 commit 3bbd4a3
Showing 1 changed file with 26 additions and 0 deletions.
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

0 comments on commit 3bbd4a3

Please sign in to comment.