From 96c607d2da295207ec6d9689c61f71d5d147b19a Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Mon, 30 Jan 2012 09:10:05 +0000 Subject: [PATCH 1/2] Fixed fatal error calling identifyOutputDir on parent folder --- source/lib/DownloadDispatcher/Source/Plugin/TV.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php b/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php index 11cae9e..c2ebebc 100644 --- a/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php +++ b/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php @@ -109,7 +109,7 @@ class DownloadDispatcher_Source_Plugin_TV extends DownloadDispatcher_Source_Plug // Filename not recognised, try the parent directory name instead if ($try_parent) { - return identifyOutputDir(dirname($dir), basename($dir), false); + return $this->identifyOutputDir(dirname($dir), basename($dir), false); } throw new DownloadDispatcher_Exception_UnidentifiedContent($file); From 52865832db01eb9f9cb7c8f3f5605874ab77e82d Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Mon, 30 Jan 2012 09:10:40 +0000 Subject: [PATCH 2/2] Update normalise regex to strip out prefix --- .../Source/Plugin/TV.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php b/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php index c2ebebc..be44ef1 100644 --- a/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php +++ b/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php @@ -132,16 +132,18 @@ class DownloadDispatcher_Source_Plugin_TV extends DownloadDispatcher_Source_Plug } protected function normalise($name) { - if (preg_match('/(.*?)([\s\.]us)?([\s\.]+(19|20)\d{2})?[\s\.]+(\d+x\d+|s\d+e\d+|\d{3,4}).*/i', $name, $matches)) { - $name = $matches[1]; + $normalised_name = $name; + if (preg_match('/(?:\[ www.[a-zA-Z0-9.]+ \] - )?(.*?)([\s.]+us)?([\s\.](19|20)\d{2})?[\s\.](\d+x\d+|s\d+e\d+|\d{3,4}).*/i', $normalised_name, $matches)) { + $normalised_name = $matches[1]; } - $name = preg_replace('/[^a-zA-Z0-9]/', ' ', $name); - $name = preg_replace('/ +/', ' ', $name); - $name = strtolower($name); - $name = trim($name); + $normalised_name = preg_replace('/[^a-zA-Z0-9]/', ' ', $normalised_name); + $normalised_name = preg_replace('/ +/', ' ', $normalised_name); + $normalised_name = strtolower($normalised_name); + $normalised_name = trim($normalised_name); - return $name; + DownloadDispatcher_LogEntry::debug($this->log, "Normalised '{$name}' to '{$normalised_name}'"); + return $normalised_name; } protected function season($name) {