cops/resources/epub-loader/app/action_db_load.php

31 lines
823 B
PHP
Raw Permalink Normal View History

<?php
/**
2013-10-01 00:29:27 +03:00
* 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>
*/
2013-09-25 09:28:20 +03:00
// 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'])) {
2013-10-08 01:00:06 +03:00
$fileList = RecursiveGlob($dbConfig['epub_path'], '*.epub');
2013-10-10 09:33:25 +03:00
foreach ($fileList as $file) {
$error = $db->AddEpub($file);
if (!empty($error)) {
2013-10-10 09:33:25 +03:00
$gErrorArray[$file] = $error;
}
}
}
2013-09-25 09:28:20 +03:00
}
catch (Exception $e) {
$gErrorArray[$fileName] = $e->getMessage();
}
?>