diff --git a/Blacklight/Console.php b/Blacklight/Console.php index 1df197c9c..5ba225ffb 100755 --- a/Blacklight/Console.php +++ b/Blacklight/Console.php @@ -706,10 +706,12 @@ class Console try { $result = Game::where('name', $gameInfo)->get(); if (! empty($result)) { + $bestMatchPct = 0; foreach ($result as $res) { similar_text(strtolower($gameInfo), strtolower($res->name), $percent); - if ($percent >= 90) { + if ($percent >= 90 && $percent > $bestMatchPct) { $bestMatch = $res->id; + $bestMatchPct = $percent; } } if ($bestMatch !== false) { @@ -744,10 +746,12 @@ class Console if (! empty($game->platforms)) { foreach ($game->platforms as $platforms) { + $percentCurrent = 0; $gamePlatforms = Platform::where('id', $platforms)->get(); foreach ($gamePlatforms as $gamePlat) { similar_text($gamePlat->name, $gamePlatform, $percent); - if ($percent >= 85) { + if ($percent >= 85 && $percent > $percentCurrent) { + $percentCurrent = $percent; $platform = $gamePlat->name; break; } diff --git a/Blacklight/Games.php b/Blacklight/Games.php index 304b1665a..604bd17d3 100755 --- a/Blacklight/Games.php +++ b/Blacklight/Games.php @@ -509,12 +509,12 @@ class Games $result = $this->giantBomb->search($gameInfo['title'], 'Game'); if (! \is_object($result)) { - $percentCurrent = 0; + $bestMatchPct = 0; foreach ($result as $res) { similar_text(strtolower($gameInfo['title']), strtolower($res->name), $percent1); - if ($percent1 >= self::GAME_MATCH_PERCENTAGE && $percent1 > $percentCurrent) { - $percentCurrent = $percent1; + if ($percent1 >= self::GAME_MATCH_PERCENTAGE && $percent1 > $bestMatchPct) { $bestMatch = $res->id; + $bestMatchPct = $percent1; } } @@ -578,12 +578,12 @@ class Games $this->_classUsed = 'IGDB'; $result = Game::where('name', $gameInfo['title'])->get(); if (! empty($result)) { - $percentCurrent = 0; + $bestMatchPct = 0; foreach ($result as $res) { similar_text(strtolower($gameInfo['title']), strtolower($res->name), $percent1); - if ($percent1 >= self::GAME_MATCH_PERCENTAGE && $percent1 > $percentCurrent) { - $percentCurrent = $percent1; + if ($percent1 >= self::GAME_MATCH_PERCENTAGE && $percent1 > $bestMatchPct) { $bestMatch = $res->id; + $bestMatchPct = $percent1; } } if ($bestMatch !== false) { diff --git a/Blacklight/NameFixer.php b/Blacklight/NameFixer.php index bb22ed4dd..f82225a1c 100755 --- a/Blacklight/NameFixer.php +++ b/Blacklight/NameFixer.php @@ -707,13 +707,13 @@ class NameFixer AND rf.mediainfo REGEXP '\' AND rel.nzbstatus = %d AND rel.isrenamed = %d - AND rel.predb_id = 0 - AND rel.categories_id IN (%d, %d)", + AND rel.predb_id = 0", NZB::NZB_ADDED, - self::IS_RENAMED_NONE, - Category::OTHER_MISC, - Category::OTHER_HASHED + self::IS_RENAMED_NONE ); + if ($cats == 2) { + $query .= PHP_EOL.sprintf('AND rel.categories_id IN (%s)', [Category::OTHER_MISC, Category::OTHER_HASHED]); + } } $releases = $this->_getReleases($time, $cats, $query); @@ -757,10 +757,10 @@ class NameFixer SELECT rel.id AS releases_id, rel.size AS relsize, rel.groups_id, rel.fromname, rel.categories_id, rel.name, rel.name AS textstring, rel.predb_id, rel.searchname, - IFNULL(ph.hash, "") AS hash + IFNULL(ph.hash, \'\') AS hash FROM releases rel LEFT JOIN par_hashes ph ON ph.releases_id = rel.id - WHERE ph.hash != "" + WHERE ph.hash != \'\' AND rel.nzbstatus = %d AND rel.predb_id = 0', NZB::NZB_ADDED @@ -773,13 +773,13 @@ class NameFixer SELECT rel.id AS releases_id, rel.size AS relsize, rel.groups_id, rel.fromname, rel.categories_id, rel.name, rel.name AS textstring, rel.predb_id, rel.searchname, - IFNULL(ph.hash, "") AS hash + IFNULL(ph.hash, \'\') AS hash FROM releases rel LEFT JOIN par_hashes ph ON ph.releases_id = rel.id WHERE rel.nzbstatus = %d AND (rel.isrenamed = %d OR rel.categories_id IN (%d, %d)) AND rel.predb_id = 0 - AND ph.hash != "" + AND ph.hash != \'\' AND rel.proc_hash16k = %d', NZB::NZB_ADDED, self::IS_RENAMED_NONE, diff --git a/Blacklight/TmuxOutput.php b/Blacklight/TmuxOutput.php index 7b08fd158..6d1cb05b3 100755 --- a/Blacklight/TmuxOutput.php +++ b/Blacklight/TmuxOutput.php @@ -506,17 +506,19 @@ class TmuxOutput extends Tmux ) ); - $pieces = explode(' ', $this->pdo->getAttribute(\PDO::ATTR_SERVER_INFO)); - $buffer .= color("\nThreads = ")->green. - color($pieces[4])->yellow. - color(', Opens = ')->green. - color($pieces[14])->yellow. - color(', Tables = ')->green. - color($pieces[22])->yellow. - color(', Slow = ')->green. - color($pieces[11])->yellow. - color(', QPS = ')->green. - color($pieces[28])->yellow.PHP_EOL; + $info = $this->pdo->getAttribute(\PDO::ATTR_SERVER_INFO); + $pieces = []; + foreach ([ + ['Threads', '/.*\bThreads: (\d+)\b.*/'], + ['Opens', '/.*\bOpens[^:]*?: (\d+)\b.*/'], + ['Tables', '/.* tables: (\d+)\b.*/'], + ['Slow', '/.*\bSlow[^:]*?: (\d+)\b.*/'], + ['QPS', '/.*\bQueries[^:]*?: (\d+)\b.*/'], + ] as $v) { + $pieces[] = color($v[0].' = ')->green. + color(preg_replace($v[1], '$1', $info))->yellow; + } + $buffer .= PHP_EOL.implode(', ', $pieces).PHP_EOL; return $buffer; } diff --git a/resources/tmp/imdb_cache/.gitignore b/resources/tmp/imdb_cache/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/resources/tmp/imdb_cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore