Example #1
0
 public function isBroken() : bool
 {
     global $Database;
     if (isset($this->not_broken_at)) {
         $nb = strtotime($this->not_broken_at);
         if ($nb + Time::$IN_SECONDS['hour'] * 2 > time()) {
             return false;
         }
     }
     $url = VideoProvider::getEmbed($this, VideoProvider::URL_ONLY);
     if ($this->provider === 'yt') {
         $url = "http://www.youtube.com/oembed?url={$url}";
     }
     $broken = !CoreUtils::isURLAvailable($url);
     if (!$broken) {
         $this->not_broken_at = date('c');
         $Database->whereEp($this->season, $this->episode)->where('provider', $this->provider)->where('id', $this->id)->update('episodes__videos', array('not_broken_at' => $this->not_broken_at));
     }
     return $broken;
 }
Example #2
0
 static function isImageAvailable(string $url) : bool
 {
     if (CoreUtils::isURLAvailable($url)) {
         return true;
     }
     CoreUtils::msleep(300);
     if (CoreUtils::isURLAvailable($url)) {
         return true;
     }
     CoreUtils::msleep(300);
     if (CoreUtils::isURLAvailable("{$url}?")) {
         return true;
     }
     CoreUtils::msleep(300);
     if (CoreUtils::isURLAvailable("{$url}?")) {
         return true;
     }
     return false;
 }