diff --git a/Tests/searchloadTest.php b/Tests/searchloadTest.php index 6042809..07bbe88 100644 --- a/Tests/searchloadTest.php +++ b/Tests/searchloadTest.php @@ -78,6 +78,16 @@ function testInitSubtitlesList() { $this->assertEquals(2, count($subtitlesList)); } + function testHandleSubtitleFile_wrongSubName_fixedSubName() { + $this->createFiles(array(base64_decode('W0hvcnJpYmxlU3Vic10gSHVuZHJlZCAtIDA1IFsxMDgwcF0uYXNz'))); + $subtitlesList = initSubtitlesList(TEST_DIR); + foreach ($subtitlesList as $sub) { + handleSubtitleFile($this->dirInfo, $sub); + } + $this->assertEquals(1, searchloadTest::$downloadCount); + $this->assertFileExists(TEST_DIR . '/' . base64_decode('W0hvcnJpYmxlU3Vic10gSHVuZHJlZCAtIDA1IFsxMDgwcF0uYXNz')); + } + function testHandleSubtitleFile_CantfindWithoutQuotes_FindWithQuotes() { $this->createFiles(array(base64_decode("W0hvcnJpYmxlU3Vic10gR0FURSAtIDEzIFs3MjBwXS5hc3M="))); $subtitlesList = initSubtitlesList(TEST_DIR); diff --git a/searchload.php b/searchload.php index 29e1925..b0bb448 100644 --- a/searchload.php +++ b/searchload.php @@ -116,7 +116,11 @@ function renameAndDownload($dirInfo, $torname, $linkmath, $html) { if (preg_match('~(.*?)~', $html, $torFileName)) { $torFileName = htmlentities2utf8($torFileName[1]); $torFileNameWithoutExt = get_path_without_ext($torFileName); + removeQutes($torname); if (strcasecmp($torname["name"], $torFileNameWithoutExt) != 0) { + if (!isset($torname["oldname"])) { + $torname["oldname"] = $dirnameRaw . "/" . $torname["name"] . "." . $torname["ext"]; + } $torname["name"] = $torFileNameWithoutExt; } }