This commit is contained in:
2018-09-03 02:53:01 -07:00
parent d2ed189d2b
commit 489ff7cd70
3 changed files with 129 additions and 46 deletions

80
Yuba.php Executable file → Normal file
View File

@@ -3,7 +3,7 @@
// Yuba
// //
//////////////////////////////////////////
$version = "0.7.2.5";
$version = "0.7.3";
ini_set('memory_limit', '4096M');
date_default_timezone_set("America/Los_Angeles");
@@ -228,30 +228,14 @@ $dbo->exec("CREATE TABLE files (
gfi_attr TEXT,
gfi_created TEXT,
Size INTEGER,
Title TEXT,
PixelWidth INTEGER,
PixelHeight INTEGER,
Duration INTEGER,
DateTimeOriginal INTEGER,
Origin TEXT,
GPS TEXT,
Author TEXT,
has_exif INTEGER,
has_mediainfo INTEGER,
has_hash INTEGER,
thumb_filename TEXT,
thumb_width INTEGER,
thumb_height INTEGER,
ProfileDescription TEXT,
BitDepth INTEGER,
Compression TEXT,
Orientation INTEGER,
LensType TEXT,
VideoFormat TEXT,
AudioFormat TEXT,
Tracks INTEGER,
Profile TEXT,
Bitrate INTEGER
has_contents INTEGER,
contents_filename TEXT
)");
$stmt = $dbo->prepare("INSERT INTO _skim VALUES (:version, :opts, :host, :uid, :zpath, :bpath, :type, :passed_file, :passed_dir, :passed_link, :passed_total, :nodescended, :ignored, :dupes, :stats, :qlmanage, :sysvers, :diskutil, :disks, :df, :df_device, :df_volume, :mdutil, :profile, :status)");
@@ -328,6 +312,8 @@ $files = new RecursiveIteratorIterator(
// Tally
//////////////////////////////////////////
echo "Tally\n";
foreach ($files as $null) { }
$first_run = 0;
@@ -391,7 +377,6 @@ $dbp->exec("CREATE TABLE IF NOT EXISTS contents (fid TEXT, created INTEGER, rela
//////////////////////////////////////////
$family = array();
$fids = array();
echo ProgressBar::start($passed_total,"Prescan");
@@ -615,7 +600,8 @@ if ($p['meta']) {
if (!$check) {
$stmt = $dbp->prepare("INSERT INTO mediainfo VALUES (:fid, :info)");
$stmt->BindValue(":fid",$fid);
$stmt->BindValue(":info",serialize(parseMediaInfo(shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1"))));
//$stmt->BindValue(":info",serialize(parseMediaInfo(shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1"))));
$stmt->BindValue(":info",shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1"));
$stmt->execute();
}
}
@@ -754,6 +740,54 @@ if ($p['spotlight']) {
}
// Milk
//////////////////////////////////////////
// Aggregate values
$sb['a'] = array( "t*Title" => array("e_Title","k_Title","m_Title"),
"t*Dimensions" => array("k_PixelWidth.k_PixelHeight","e_PixelWidth.e_PixelHeight","m_PixelWidth.m_PixelHeight"),
"i*Seconds" => array("k_DurationSeconds","e_Duration","m_Duration"),
"d*DateTime" => array("e_DateTimeOriginal","m_EncodedDate","e_CreateDate","e_MediaCreateDate","k_ContentCreationDate"),
"t*Origin" => array("e_CameraModelName","e_Producer","e_CreatorTool","e_WriterName","e_Software","e_Encoder","m_WritingApplication"),
"t*GPS" => array("e_GPSPosition","k_Latitude.k_Longitude"),
"t*Author" => array("e_Author","e_Artist","e_Creator","e_By-line")
);
// Exiftool values
$sb['e'] = array( "i*Orientation",
"t*Compression",
"t*ProfileDescription",
"i*BitDepth",
"t*LensType",
"t*FocalLength",
"t*Aperture",
"t*LightSource",
"t*WhiteBalance" );
// Mediainfo values
$sb['m'] = array( "t*VideoFormat",
"t*AudioFormat",
"i*Tracks",
"t*Profile",
"t*Bitrate" );
// Build DB
unset($cbuild, $ibuild);
foreach (array_merge(array_keys($sb['a']),$sb['e'],$sb['m']) as $name) {
$parts = explode("*",$name);
$ibuild[] = ":".$parts[1];
if ($parts[0] == "t") {
$cbuild[] = $parts[1]." TEXT";
} else {
$cbuild[] = $parts[1]." INTEGER";
}
}
$dbo->exec("CREATE TABLE milk (".implode(",",$cbuild).")");
$stmt = $dbo->prepare("INSERT INTO milk VALUES (".implode(",",$ibuild).")");
$stmt->execute();
// Files
//////////////////////////////////////////
@@ -767,7 +801,7 @@ foreach ($files as $splFileInfo) {
// DB
$stmt = $dbo->prepare("INSERT INTO files VALUES (:pid, :fid, :Pathname, :Path, :Filename, :Extension, :Type, :Inode, :Perms, :Owner, :ATime, :CTime, :MTime, :LinkTarget, :RealPath, :stat, :items, :newest, :gfi_type, :gfi_attr, :gfi_created, :Size, :Title, :PixelWidth, :PixelHeight, :Duration, :DateTimeOriginal, :Origin, :GPS, :Author, :has_exif, :has_mediainfo, :has_hash, :thumb_filename, :thumb_width, :thumb_height, :ProfileDescription, :BitDepth, :Compression, :Orientation, :LensType, :VideoFormat, :AudioFormat, :Tracks, :Profile, :Bitrate)");
$stmt = $dbo->prepare("INSERT INTO files VALUES (:pid, :fid, :Pathname, :Path, :Filename, :Extension, :Type, :Size, :Inode, :Perms, :Owner, :ATime, :CTime, :MTime, :LinkTarget, :RealPath, :stat, :items, :newest, :gfi_type, :gfi_attr, :gfi_created, :has_exif, :has_mediainfo, :has_hash, :thumb_filename, :thumb_width, :thumb_height, :has_contents, :contents_filename)");
// Identify dir, file, link or bundle dir
@@ -913,7 +947,7 @@ foreach ($files as $splFileInfo) {
// ------------------------------------------------ //
// Breakouts
// Milk

7
functions.php Executable file → Normal file
View File

@@ -50,10 +50,6 @@ function getParents($zpath, $pathname) {
}
*/
function stringPrint($string) {
echo $string.@str_repeat(" ", (10-strlen($string)));
}
function shortlabel($pathname, $max = 99, $pad = false) {
$basename = basename($pathname);
$suffix = "(...).".pathinfo($basename,PATHINFO_EXTENSION);
@@ -62,9 +58,6 @@ function shortlabel($pathname, $max = 99, $pad = false) {
} else {
$return = $basename;
}
if ($pad) {
$return = $return.@str_repeat(" ", ($max-strlen($return)));
}
return $return;
}

View File

@@ -1,11 +1,24 @@
<?
/////////////////////////////////////////////////////////////////
// Yuba RTC Browser
/////////////////////////////////////////////////////////////////
$icon_size = 64;
$pad = 28;
?>
<html>
<head>
<style>
div.container { display: flex; flex-flow: row wrap; justify-content: center; }
div.item { width: 99px; height: 99px; padding: 20px; }
div.item { width: <?=$icon_size+$pad;?>px; height: <?=$icon_size+$pad;?>px; padding: <?=$pad;?>px; word-wrap: break-word; }
div.item { font-family: Helvetica; font-size: 11px; }
img { width: 64px; height: 64px; }
div.flexfill { width: <?=$icon_size+($pad*3);?>px; height: 1px; }
img.thumb { padding: 6px; border: 1px solid gainsboro; }
img { margin-bottom: 8px; }
</style>
</head>
@@ -14,12 +27,20 @@ img { width: 64px; height: 64px; }
<?
////////////////////////////////////////////////
// Yuba RTC Browser
////////////////////////////////////////////////
// Functions
function breadcrumbs() { }
function shortlabel($filename, $max = 40) {
$suffix = "(...).".pathinfo($filename)['extension'];
if (strlen($filename) > $max) {
$return = substr($filename, 0, ($max-strlen($suffix))).$suffix;
} else {
$return = $filename;
}
return $return;
}
function findicon($filename) {
$ext = pathinfo($filename)['extension'];
if (!$ext) {
@@ -35,24 +56,29 @@ function findicon($filename) {
return $good;
}
////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
$db_file = $_GET['db'];
$pid = $_GET['pid'];
if ($db_file) {
// Show a view
// View
if (!is_readable($db_file)) { echo "can't read db file"; die; }
echo "<a href='?db='>index</a>";
echo "<a href='?db='>db list</a>";
echo "<hr>";
$dbo = new PDO("sqlite:".$db_file);
$dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$array = $dbo->query("SELECT children FROM family WHERE (rowid=2)")->fetch()['children'];
if (!$pid) {
$array = $dbo->query("SELECT children FROM family WHERE (rowid=2)")->fetch()['children'];
} else {
$array = $dbo->query("SELECT children FROM family WHERE (pid='".$pid."')")->fetch()['children'];
}
$children = unserialize($array);
@@ -62,26 +88,55 @@ if ($db_file) {
echo "<hr>";
echo "\n<div class='container'>";
dsf
print_r($children);
foreach ($children as $key => $item) {
if (count($children) < 1) { echo "dir is empty."; die; }
foreach ($children as $item) {
echo "<div class='item'>";
$row_a = $dbo->query("SELECT * FROM files WHERE (pid='".$item."')")->fetchAll()[0];
//$row_b = $dbo->query("SELECT * FROM mdls WHERE (pid='".$item."')")->fetchAll()[0];
//$row_c = $dbo->query("SELECT * FROM milk WHERE (pid='".$item."')")->fetchAll()[0];
$icon = "<img src='".findicon($row_a['Filename'])."'>";
if ($row_a['thumb_filename']) {
$aspect = $row_a['thumb_width']/$row_a['thumb_height'];
if ($aspect > 1) {
$width = $icon_size;
$height = $icon_size/$aspect;
} else {
$width = $icon_size*$aspect;
$height = $icon_size;
}
$realfile = dirname($db_file).$row_a['thumb_filename'];
$icon = "<img class='thumb' src='".$realfile."' width='".$width."' height='".$height."'>";
} else {
$icon = "<img class='icon' src='".findicon($row_a['Filename'])."' width='".$icon_size."' height='".$icon_size."'>";
}
echo "\n<div class='item'>".$icon."<br>".htmlentities($row_a['Filename'])."</div>";
$name = htmlentities(shortlabel($row_a['Filename']));
if ($row_a['Type'] == "dir") {
echo "\n<a href='?db=".$db_file."&pid=".$row_a['pid']."'>".$icon."</a><br>".$name;
} else {
echo $icon."<br>".$name;
}
echo "</div>";
echo "<br>";
}
echo str_repeat("<div class='flexfill'></div>", 100);
echo "\n</div>";
} else {
/////////////////////////////////////////////////////////////////
// DB List
$bundles = glob("skim/*.bundle");
@@ -101,6 +156,7 @@ if ($db_file) {
}
}
/////////////////////////////////////////////////////////////////
echo "<hr><br>".round($time = microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"],2)." seconds";