Skip to content

Commit 0c2eb4e

Browse files
committed
ignore video if video.ContentDetails.Duration is empty, usually upcoming live broadcast.
1 parent 0429af0 commit 0c2eb4e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pkg/builder/youtube.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,16 @@ func (yt *YouTubeBuilder) queryVideoDescriptions(ctx context.Context, playlist m
317317

318318
// Sometimes YouTube retrun empty content defailt, use arbitrary one
319319
var seconds int64 = 1
320-
if video.ContentDetails != nil {
320+
if video.ContentDetails.Duration != "" {
321321
// Parse duration
322322
d, err := duration.FromString(video.ContentDetails.Duration)
323323
if err != nil {
324-
// If parsing fails, log the error and use the default value
325-
log.Printf("Warning: Failed to parse duration %s: %v. Using default value.", video.ContentDetails.Duration, err)
326-
// seconds is already set to 1, so we don't need to set it again
327-
} else {
328-
// If parsing succeeds, set seconds to the parsed duration
329-
seconds = int64(d.ToDuration().Seconds())
324+
return errors.Wrapf(err, "failed to parse duration %s", video.ContentDetails.Duration)
330325
}
331326

332-
// seconds = int64(d.ToDuration().Seconds())
327+
seconds = int64(d.ToDuration().Seconds())
328+
} else {
329+
continue
333330
}
334331

335332
var (

0 commit comments

Comments
 (0)