/** * Is there a valid - existing - Calibre directory? * @return boolean true if available */ function has_valid_calibre_dir() { global $globalSettings; return has_global_setting(CALIBRE_DIR) && Calibre::checkForCalibre($globalSettings[CALIBRE_DIR]); }
/** * @brief scan files for metadata * * @param int $id fileid * @return array $meta metadata */ public static function scan($id) { $meta = self::create($id); $path = \OC\Files\Filesystem::getLocalFile(\OC\Files\Filesystem::getPath($id)); /* scan for Calibre-generated metadata.opf first. If found, use it as metadata source, * if not found continue file/isbn/etc scan */ if (!Calibre::get($path, $meta)) { /* try to call function named 'type' with signature type($path,$meta) * eg, pdf(), epub(), etc */ $type = strtolower(substr(strrchr($path, "."), 1)); if (is_callable(array(__CLASS__, $type))) { try { self::$type($path, $meta); } catch (Exception $e) { Util::logWarn("no metadata scanner for format " . $type); } } } /* if title is not set, assume metadata was invalid or not present * use filename as title */ if (!$meta['title']) { $info = pathinfo($path); $meta['title'] = basename($path, '.' . $info['extension']); } self::save($meta); return $meta; }