Skip to content

Commit

Permalink
Update youtube.go
Browse files Browse the repository at this point in the history
handle video.ContentDetails changes
  • Loading branch information
fqx authored Jun 28, 2024
1 parent 3010046 commit 0429af0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/builder/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,15 @@ func (yt *YouTubeBuilder) queryVideoDescriptions(ctx context.Context, playlist m
// Parse duration
d, err := duration.FromString(video.ContentDetails.Duration)
if err != nil {
return errors.Wrapf(err, "failed to parse duration %s", video.ContentDetails.Duration)
// If parsing fails, log the error and use the default value
log.Printf("Warning: Failed to parse duration %s: %v. Using default value.", video.ContentDetails.Duration, err)
// seconds is already set to 1, so we don't need to set it again
} else {
// If parsing succeeds, set seconds to the parsed duration
seconds = int64(d.ToDuration().Seconds())
}

seconds = int64(d.ToDuration().Seconds())
// seconds = int64(d.ToDuration().Seconds())
}

var (
Expand Down

0 comments on commit 0429af0

Please sign in to comment.