/** * Cleans file names for PreDB Match */ protected function _cleanMatchFiles($fileName = '') { // first strip all non-printing chars from filename $this->_fileName = $this->utility->stripNonPrintingChars($fileName); if (strlen($this->_fileName) !== false && strlen($this->_fileName) > 0 && strpos($this->_fileName, '.') !== 0) { switch (true) { case strpos($this->_fileName, '.') !== false: //some filenames start with a period that ends up creating bad matches so we don't process them $this->_fileName = $this->utility->cutStringUsingLast('.', $this->_fileName, "left", false); continue; //if filename has a .part001, send it back to the function to cut the next period //if filename has a .part001, send it back to the function to cut the next period case preg_match('/\\.part\\d+$/', $this->_fileName): $this->_fileName = $this->utility->cutStringUsingLast('.', $this->_fileName, "left", false); continue; //if filename has a .vol001, send it back to the function to cut the next period //if filename has a .vol001, send it back to the function to cut the next period case preg_match('/\\.vol\\d+(\\+\\d+)?$/', $this->_fileName): $this->_fileName = $this->utility->cutStringUsingLast('.', $this->_fileName, "left", false); continue; //if filename contains a slash, cut the string and keep string to the right of the last slash to remove dir //if filename contains a slash, cut the string and keep string to the right of the last slash to remove dir case strpos($this->_fileName, '\\') !== false: $this->_fileName = $this->utility->cutStringUsingLast('\\', $this->_fileName, "right", false); continue; // A lot of obscured releases have one NFO file properly named with a track number (Audio) at the front of it // This will strip out the track and match it to its pre title // A lot of obscured releases have one NFO file properly named with a track number (Audio) at the front of it // This will strip out the track and match it to its pre title case preg_match('/^\\d{2}-/', $this->_fileName): $this->_fileName = preg_replace('/^\\d{2}-/', '', $this->_fileName); } return trim($this->_fileName); } }