From a8378aed3be8c88bf1837f095ebf4a636be71bb2 Mon Sep 17 00:00:00 2001 From: Ashish <51633862+ashishjh-bst@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:04:09 +0530 Subject: [PATCH] increased youtube shorts check to 3 minutes (#1770) Co-authored-by: Ashish --- youtube/feed.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/youtube/feed.go b/youtube/feed.go index a8bcf3dfc6..881e9e31a4 100644 --- a/youtube/feed.go +++ b/youtube/feed.go @@ -434,7 +434,7 @@ func (p *Plugin) parseYtUrl(channelUrl *url.URL) (id ytChannelID, err error) { } } - // Similarly to handle URLs, other types of channel URL + // Similarly to handle URLs, other types of channel URL // may have more than two segments. if len(pathSegments) < 2 { return nil, fmt.Errorf("%q is not a valid path", path) @@ -641,11 +641,14 @@ func (p *Plugin) isShortsVideo(video *youtube.Video) bool { logger.WithError(err).Errorf("Failed to parse video duration with value %s, assuming it is not a short video", videoDurationString) return false } - if videoDuration > time.Minute { + // videos below 3 minutes can be shorts + // the 10 second is a buffer as youtube is stupid sometimes + if videoDuration >= (time.Minute*3 + time.Second*10) { return false } - - return p.isShortsRedirect(video.Id) + isShort := p.isShortsRedirect(video.Id) + logger.Infof("Video %s is a shorts video?: %t", video.Id, isShort) + return isShort } func (p *Plugin) isShortsRedirect(videoId string) bool {