From 3dc30c3b98bdb1af0ac00ae5427093f2779e125d Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Thu, 12 Mar 2020 19:22:23 +0100 Subject: [PATCH] speed up duration checks --- sources/youtubeVideo.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sources/youtubeVideo.go b/sources/youtubeVideo.go index cee2d05..4bb1477 100644 --- a/sources/youtubeVideo.go +++ b/sources/youtubeVideo.go @@ -434,6 +434,13 @@ func (v *YoutubeVideo) Sync(daemon *jsonrpc.Client, params SyncParams, existingV func (v *YoutubeVideo) downloadAndPublish(daemon *jsonrpc.Client, params SyncParams) (*SyncSummary, error) { var err error + videoDuration, err := duration.FromString(v.youtubeInfo.ContentDetails.Duration) + if err != nil { + return nil, errors.Err(err) + } + if videoDuration.ToDuration() > time.Duration(v.maxVideoLength*60)*time.Minute { + return nil, errors.Err("video is too long to process") + } for { err = v.download() if err != nil && strings.Contains(err.Error(), "HTTP Error 429") {