improve upload time detection
This commit is contained in:
parent
4b4cee9fcc
commit
e985a60761
1 changed files with 4 additions and 2 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -176,8 +177,9 @@ func getUploadTime(config *sdk.APIConfig, videoID string, ip *net.TCPAddr, uploa
|
||||||
//const sqlTimeFormat = "2006-01-02 15:04:05"
|
//const sqlTimeFormat = "2006-01-02 15:04:05"
|
||||||
sqlTime, err := time.ParseInLocation(time.RFC3339, release.ReleaseTime, time.UTC)
|
sqlTime, err := time.ParseInLocation(time.RFC3339, release.ReleaseTime, time.UTC)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if sqlTime.Day() != ytdlUploadDate.Day() {
|
hoursDiff := math.Abs(sqlTime.Sub(ytdlUploadDate).Hours())
|
||||||
logrus.Infof("upload day from APIs differs from the ytdl one by more than 1 day.")
|
if hoursDiff > 48 {
|
||||||
|
logrus.Infof("upload day from APIs differs from the ytdl one by more than 2 days.")
|
||||||
} else {
|
} else {
|
||||||
return sqlTime.Format(releaseTimeFormat), nil
|
return sqlTime.Format(releaseTimeFormat), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue