fix release date bug

This commit is contained in:
Niko Storni 2020-08-06 00:25:54 +02:00
parent 6c6e93cefc
commit ec9f46f552
2 changed files with 8 additions and 8 deletions

View file

@ -163,19 +163,20 @@ func getUploadTime(config *sdk.APIConfig, videoID string, ip *net.TCPAddr, uploa
//slack("Getting upload time for %s", videoID) //slack("Getting upload time for %s", videoID)
release, err := config.GetReleasedDate(videoID) release, err := config.GetReleasedDate(videoID)
if err != nil { if err != nil {
if release != nil { logrus.Error(err)
const sqlTimeFormat = "2006-01-02 15:04:05" }
sqlTime, err := time.ParseInLocation(sqlTimeFormat, release.ReleaseTime, time.UTC) if release != nil {
if err != nil { const sqlTimeFormat = "2006-01-02 15:04:05"
return sqlTime.Format(releaseTimeFormat), nil sqlTime, err := time.ParseInLocation(sqlTimeFormat, release.ReleaseTime, time.UTC)
} if err == nil {
return sqlTime.Format(releaseTimeFormat), nil
} }
} }
ytdlUploadDate, err := time.Parse("20060102", uploadDate) ytdlUploadDate, err := time.Parse("20060102", uploadDate)
if err != nil { if err != nil {
logrus.Error(err) 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 return ytdlUploadDate.Format(releaseTimeFormat), nil
} }
client := getClient(ip) client := getClient(ip)

View file

@ -144,7 +144,6 @@ func CountVideosInChannel(channelID string) (int, error) {
} }
func ChannelInfo(channelID string) (*YoutubeStatsResponse, 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" url := "https://www.youtube.com/channel/" + channelID + "/about"
req, _ := http.NewRequest("GET", url, nil) req, _ := http.NewRequest("GET", url, nil)