Skip to content

Commit

Permalink
Fixed rename issue
Browse files Browse the repository at this point in the history
Closes #9 issue
  • Loading branch information
smad2005 committed May 9, 2016
1 parent 4410c6a commit 01e3cf9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Tests/searchloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions searchload.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ function renameAndDownload($dirInfo, $torname, $linkmath, $html) {
if (preg_match('~<td class="viewtorrentname">(.*?)</td>~', $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;
}
}
Expand Down

0 comments on commit 01e3cf9

Please sign in to comment.