From ec9f46f5526fb07454f20261db199e3978d572bc Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Thu, 6 Aug 2020 00:25:54 +0200 Subject: [PATCH] fix release date bug --- downloader/downloader.go | 15 ++++++++------- ytapi/ytapi.go | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/downloader/downloader.go b/downloader/downloader.go index eba0c1a..0dc12de 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -163,19 +163,20 @@ func getUploadTime(config *sdk.APIConfig, videoID string, ip *net.TCPAddr, uploa //slack("Getting upload time for %s", videoID) release, err := config.GetReleasedDate(videoID) if err != nil { - if release != nil { - const sqlTimeFormat = "2006-01-02 15:04:05" - sqlTime, err := time.ParseInLocation(sqlTimeFormat, release.ReleaseTime, time.UTC) - if err != nil { - return sqlTime.Format(releaseTimeFormat), nil - } + logrus.Error(err) + } + if release != nil { + const sqlTimeFormat = "2006-01-02 15:04:05" + sqlTime, err := time.ParseInLocation(sqlTimeFormat, release.ReleaseTime, time.UTC) + if err == nil { + return sqlTime.Format(releaseTimeFormat), nil } } ytdlUploadDate, err := time.Parse("20060102", uploadDate) if err != nil { logrus.Error(err) } - if time.Now().Add(-5 * 24 * time.Hour).After(ytdlUploadDate) { + if time.Now().AddDate(0, 0, -5).After(ytdlUploadDate) { return ytdlUploadDate.Format(releaseTimeFormat), nil } client := getClient(ip) diff --git a/ytapi/ytapi.go b/ytapi/ytapi.go index 5b07d37..a15d8a6 100644 --- a/ytapi/ytapi.go +++ b/ytapi/ytapi.go @@ -144,7 +144,6 @@ func CountVideosInChannel(channelID string) (int, error) { } func ChannelInfo(channelID string) (*YoutubeStatsResponse, error) { - //return nil, nil, errors.Err("ChannelInfo doesn't work yet because we're focused on existing channels") url := "https://www.youtube.com/channel/" + channelID + "/about" req, _ := http.NewRequest("GET", url, nil)