0.7.12.5 (Icons)
This commit is contained in:
64
helper.php
Executable file
64
helper.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?
|
||||
|
||||
// Yuba batch helper
|
||||
// //
|
||||
//////////////////////////////////////////
|
||||
|
||||
$prefs_file = "/Users/".get_current_user()."/Library/Preferences/yuba_prefs.php";
|
||||
$p = unserialize(file_get_contents($prefs_file));
|
||||
|
||||
$bin_mediainfo = __DIR__."/bin/mediainfo";
|
||||
$bin_exiftool = __DIR__."/bin/exiftool";
|
||||
$bin_ffmpeg = __DIR__."/bin/ffmpeg";
|
||||
$bin_qlthumb = __DIR__."/bin/ql-thumbnail";
|
||||
$bin_qltool = __DIR__."/bin/qltool";
|
||||
$bin_magick = __DIR__."/bin/magick";
|
||||
$bin_sox = __DIR__."/bin/sox";
|
||||
|
||||
$mode = $argv[1];
|
||||
$fid = $argv[2];
|
||||
$pathname = $argv[3];
|
||||
$bpath = $argv[4];
|
||||
$mytime = $argv[5];
|
||||
|
||||
$tfile = "/tmp/Yuba/".$mytime."/".$fid.".png";
|
||||
|
||||
$shellpath = escapeshellarg($pathname);
|
||||
|
||||
$dbp = new PDO("sqlite:".$bpath."/pool.sqlite3");
|
||||
$dbp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$dbp->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
|
||||
if (@!$dbp->query("SELECT EXISTS(SELECT 1 FROM icons WHERE fid='".$fid."')")->fetch()[0]) {
|
||||
|
||||
$stmt = $dbp->prepare("INSERT INTO icons VALUES (:fid, :hash, :created, :relative_path, :tool)");
|
||||
|
||||
$cmd = $bin_qltool." di ".$shellpath." ".$p['thumb_size']." ".$p['thumb_size']." | base64 --decode | ".$bin_magick." convert - -scale 50% -strip -define png:compression-level=9 ".$tfile;
|
||||
shell_exec($cmd);
|
||||
|
||||
$stmt->BindValue(":fid",$fid);
|
||||
if (@filesize($tfile)) {
|
||||
$hash = md5_file($tfile);
|
||||
$stmt->BindValue(":hash",$hash);
|
||||
if ($row = @$dbp->query("SELECT * FROM icons WHERE hash='".$hash."'")->fetchAll()[0]) {
|
||||
$stmt->BindValue(":created",$row['created']);
|
||||
$stmt->BindValue(":relative_path",$row['relative_path']);
|
||||
$stmt->BindValue(":tool",$row['tool']);
|
||||
} else {
|
||||
$dfile = $bpath."/icons/".substr($hash, 0, 2)."/".$hash.".png";
|
||||
if (!is_dir(dirname($dfile))) { mkdir(dirname($dfile)); }
|
||||
rename($tfile,$dfile);
|
||||
$stmt->BindValue(":created",time());
|
||||
$stmt->BindValue(":relative_path",substr($dfile,strlen($bpath)));
|
||||
$stmt->BindValue(":tool","qltool");
|
||||
}
|
||||
}
|
||||
$stmt->execute();
|
||||
|
||||
}
|
||||
|
||||
$stmt = $dbp->prepare("UPDATE counter SET count = count + 1 WHERE time='".$mytime."'");
|
||||
$stmt->execute();
|
||||
echo "\nPROGRESS: ".$dbp->query("SELECT count FROM counter WHERE time='".$mytime."'")->fetch()['count'];
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user