diff --git a/downloader/downloader.go b/downloader/downloader.go index 56872bc..7ad4155 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -59,7 +59,7 @@ func GetVideoInformation(config *sdk.APIConfig, videoID string, stopChan stop.Ch tries := 0 GetTime: tries++ - t, err := getUploadTime(config, videoID, ip) + t, err := getUploadTime(config, videoID, ip, video.UploadDate) if err != nil { //slack(":warning: Upload time error: %v", err) if tries <= maxTries && (errors.Is(err, errNotScraped) || errors.Is(err, errUploadTimeEmpty) || errors.Is(err, errStatusParse) || errors.Is(err, errConnectionIssue)) { @@ -158,7 +158,7 @@ func triggerScrape(videoID string, ip *net.TCPAddr) error { //https://caa.iti.gr/caa/api/v4/videos/reports/h-tuxHS5lSM } -func getUploadTime(config *sdk.APIConfig, videoID string, ip *net.TCPAddr) (string, error) { +func getUploadTime(config *sdk.APIConfig, videoID string, ip *net.TCPAddr, uploadDate string) (string, error) { //slack("Getting upload time for %s", videoID) release, err := config.GetReleasedDate(videoID) if err != nil { @@ -170,6 +170,13 @@ func getUploadTime(config *sdk.APIConfig, videoID string, ip *net.TCPAddr) (stri } } } + ytdlUploadDate, err := time.Parse("20060102", uploadDate) + if err != nil { + logrus.Error(err) + } + if time.Now().Add(-5 * 24 * time.Hour).After(ytdlUploadDate) { + return ytdlUploadDate.Format(releaseTimeFormat), nil + } client := getClient(ip) req, err := http.NewRequest(http.MethodGet, "https://caa.iti.gr/get_verificationV3?url=https://www.youtube.com/watch?v="+videoID, nil) if err != nil { @@ -314,7 +321,7 @@ func run(use string, args []string, withStdErr, withStdOut bool, stopChan stop.C break } } - logrus.Debug("Unkown error, returning failure: %s", err.Error()) + logrus.Debugf("Unkown error, returning failure: %s", err.Error()) return nil, errors.Prefix("youtube-dl "+strings.Join(argsForCommand, " "), err) } return strings.Split(strings.Replace(string(outLog), "\r\n", "\n", -1), "\n"), nil diff --git a/downloader/ytdl/Video.go b/downloader/ytdl/Video.go index df032e1..c1d5c08 100644 --- a/downloader/ytdl/Video.go +++ b/downloader/ytdl/Video.go @@ -121,7 +121,7 @@ type Format struct { Ext string `json:"ext"` FragmentBaseURL string `json:"fragment_base_url,omitempty"` Filesize interface{} `json:"filesize"` - Fps interface{} `json:"fps"` + Fps int `json:"fps"` Fragments []struct { Path string `json:"path"` Duration float64 `json:"duration,omitempty"`