Browse Source

fix detection of date in movie titles with multiple 4 digit numbers

master
cinnaboot 7 years ago
parent
commit
09925bc82c
  1. 21
      admin.php
  2. 7
      query_page.php

21
admin.php

@ -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) {

7
query_page.php

@ -52,8 +52,13 @@ function main(&$local_cache, &$tmdb_interface, &$cache_results, &$is_cached, $qu
if (!$is_cached) { if (!$is_cached) {
$parsed = $tmdb_interface->query('search/movie', $key, $query_str); $parsed = $tmdb_interface->query('search/movie', $key, $query_str);
if (!$tmdb_interface->errors && $parsed) if ($tmdb_interface->errors) {
foreach ($tmdb_interface->errors as $err) {
error_log(__FILE__ . " , " . __FUNCTION__ . " , $err");
}
} else if ($parsed) {
$cache_results = $local_cache->insert_query_cache($query_str, $parsed); $cache_results = $local_cache->insert_query_cache($query_str, $parsed);
}
} }
} }

Loading…
Cancel
Save