public static function downloadVideo() { $videos = Video::where('state', '=', 'detected')->take(1)->get(); if ($videos->count() == 0) { return; } $video = $videos[0]; $sys = php_uname('s'); if ($sys == 'Windows NT') { TumblrDownloader::downloadVideoInWindowsNT($video); } else { if ($sys == 'Linux') { TumblrDownloader::downloadVideoInLinux($video); } } }
public function tryDownload() { $lastDetect = Carbon::createFromFormat('Y-m-d H:i:s', $this->configs['lastDownload']); $diff = $this->now->diffInSeconds($lastDetect); if ($diff < intval($this->configs['downloadInterval'])) { return; } $this->configs['lastDownload'] = $this->now->toDateTimeString(); $this->saveConfigs(); $images = Image::where('state', '=', 'detected')->take(1)->get(); if ($images->count() != 0) { TumblrDownloader::downloadImage(); } else { TumblrDownloader::downloadVideo(); } }