|
|
|
@ -21,10 +21,11 @@ declare(strict_types=1); |
|
|
|
require_once('include/getJsonErrorString.php'); |
|
|
|
require_once('include/getJsonErrorString.php'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//const FOLDER_PATH = '../video/unwatched'; |
|
|
|
const FOLDER_PATH = '../video/unwatched'; |
|
|
|
const FOLDER_PATH = '../video/tv.shows/Archer'; |
|
|
|
//const FOLDER_PATH = '../video/tv.shows/Archer'; |
|
|
|
const MAX_RECURSE_DEPTH = 5; |
|
|
|
const MAX_RECURSE_DEPTH = 5; |
|
|
|
$g_errors = []; |
|
|
|
$g_errors = []; |
|
|
|
|
|
|
|
$g_debug = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class path_entry |
|
|
|
class path_entry |
|
|
|
@ -42,16 +43,19 @@ class path_entry |
|
|
|
|
|
|
|
|
|
|
|
function guessMediaType($filename) : string |
|
|
|
function guessMediaType($filename) : string |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
global $g_errors, $g_debug; |
|
|
|
|
|
|
|
$matches = []; |
|
|
|
$current_year = getdate()['year']; |
|
|
|
$current_year = getdate()['year']; |
|
|
|
|
|
|
|
|
|
|
|
if (false !== stristr($filename, 'season')) { |
|
|
|
if (preg_match('/season?[0-9]{2}/i', $filename)) { |
|
|
|
return 'tv_show'; |
|
|
|
return 'tv_show'; |
|
|
|
} else if (preg_match('/s[0-9]{2}/i', $filename)) { |
|
|
|
} else if (preg_match('/s[0-9]{2}/i', $filename)) { |
|
|
|
return 'tv_show'; |
|
|
|
return 'tv_show'; |
|
|
|
// TODO: this will only match the first 4 digit number in the string |
|
|
|
} else if (preg_match_all('/[0-9]{4}/', $filename, $matches)) { |
|
|
|
} else if (preg_match('/[0-9]{4}/', $filename, $match)) { |
|
|
|
foreach ($matches[0] as $match) { |
|
|
|
if ((int) $match[0] >= 1878 && (int) $match[0] <= $current_year) |
|
|
|
if ((int) $match >= 1878 && (int) $match <= $current_year) |
|
|
|
return 'movie'; |
|
|
|
return 'movie'; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 'unknown'; |
|
|
|
return 'unknown'; |
|
|
|
@ -125,7 +129,7 @@ function unsetParentReferences(&$path_entry) : void |
|
|
|
function getUnsavedMetadata() : void |
|
|
|
function getUnsavedMetadata() : void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$path_info = getPathEntry(FOLDER_PATH); |
|
|
|
$path_info = getPathEntry(FOLDER_PATH); |
|
|
|
global $g_errors; |
|
|
|
global $g_errors, $g_debug; |
|
|
|
$out = new StdClass(); |
|
|
|
$out = new StdClass(); |
|
|
|
|
|
|
|
|
|
|
|
header('Content-Type: text/json'); |
|
|
|
header('Content-Type: text/json'); |
|
|
|
@ -134,6 +138,7 @@ function getUnsavedMetadata() : void |
|
|
|
unsetParentReferences($path_info); // NOTE: don't encode parent references |
|
|
|
unsetParentReferences($path_info); // NOTE: don't encode parent references |
|
|
|
$out->mem_usage = memory_get_peak_usage(); |
|
|
|
$out->mem_usage = memory_get_peak_usage(); |
|
|
|
$out->path_info = $path_info; |
|
|
|
$out->path_info = $path_info; |
|
|
|
|
|
|
|
$out->debug = $g_debug; |
|
|
|
$json = json_encode($out); |
|
|
|
$json = json_encode($out); |
|
|
|
|
|
|
|
|
|
|
|
if ($json) { |
|
|
|
if ($json) { |
|
|
|
|