summaryrefslogtreecommitdiffstats
path: root/resources/epub-loader/app/action_db_load.php
blob: ad21afc611925c58a9f979bc46a3d28fcdd074e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?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 $file) {
			$error = $db->AddEpub($file);
			if (!empty($error)) {
				$gErrorArray[$file] = $error;
			}
		}
	}
}
catch (Exception $e) {
	$gErrorArray[$fileName] = $e->getMessage();
}

?>