public function warn($msg) { $e = error_get_last(); $this->warnx("{$msg}: {$e['message']}"); } public function warnx($msg) { slog("{$msg}"); } } YouTubeCacher::static_constructor(); function char_to_hex($ch) { return sprintf('%2X', ord($ch)); } function safe_filename($fn) { return preg_replace_callback('/[^a-zA-Z0-9_-]/', 'char_to_hex', $fn); } function fatal($msg) { slog($msg); exit; } function slog($msg) { syslog(LOG_ERR, $msg); } $cr = new YouTubeCacher(); $cr->run();
$this->log(2, __FUNCTION__, "Cannot rename temporary cache file: [{$this->temp_cache_filename}] to [{$this->cache_filename}]"); } else { $this->add_video($sz); // Add video to the db $this->add_to_stats(); // Calc stats $this->cache_fp = null; $this->log(1, __FUNCTION__, "Close cached file: " . $this->cache_filename); } } } $this->close_temporary_transfer($this->cache_request); // Delete from temporary $this->stop_caching(); } } function char_to_hex($ch) { return sprintf('%2X', ord($ch)); } function safe_filename($fn) { return preg_replace_callback('/[^a-zA-Z0-9_-]/', 'char_to_hex', $fn); } if (!$db || !$set) { fatal_error("No DB instance or settings!"); } // Instance cacher and run it $cr = new YouTubeCacher(); $cr->run($db, $set);