cops/resources/epub-loader/app/action_db_load.php
2013-10-07 23:00:06 +01:00

28 lines
758 B
PHP

<?php
/**
* Epub loader application action: load ebooks into calibre databases
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Didier Corbière <didier.corbiere@opale-concept.com>
*/
// Init database file
$fileName = $dbConfig['db_path'] . DIRECTORY_SEPARATOR . 'metadata.db';
try {
// Open or create the database
$db = new CalibreDbLoader($fileName, $gConfig['create_db']);
echo sprintf('Load database %s', $fileName) . '<br />';
// Add the epub files into the database
if (!empty($dbConfig['epub_path'])) {
$fileList = RecursiveGlob($dbConfig['epub_path'], '*.epub');
foreach ($fileList as $fileName) {
$db->AddEpub($fileName);
}
}
}
catch (Exception $e) {
$gErrorArray[$fileName] = $e->getMessage();
}
?>