mainURL = "tokyotosho.com";
$this->altURL = "tokyotosho.info";
$this->mainTitle = "TokyoTosho";
$this->engineName = "TokyoTosho";
$this->author = "nls";
$this->version = "1.00-tfb";
$this->updateURL = "http://www.torrentflux.com/forum/index.php/topic,1581.0.html";
$this->Initialize($cfg);
}
function populateMainCategories()
{
$this->mainCatalog["0"] = "(all types)";
$this->mainCatalog["1"] = "Anime";
$this->mainCatalog["10"] = "Non-English Sub";
$this->mainCatalog["8"] = "Drama";
$this->mainCatalog["3"] = "Manga";
$this->mainCatalog["2"] = "Music";
$this->mainCatalog["9"] = "Music-Video";
$this->mainCatalog["7"] = "Raw";
$this->mainCatalog["4"] = "Hentai";
$this->mainCatalog["5"] = "Other";
}
//----------------------------------------------------------------
// Function to Make the Request (overriding base)
function makeRequest($request)
{
return parent::makeRequest($request, false);
}
//----------------------------------------------------------------
// Function to get Latest
function getLatest()
{
return $this->performSearch("");
}
//----------------------------------------------------------------
// Function to perform Search.
function performSearch($searchTerm)
{
if ($searchTerm == "") {
$request = "/";
} else {
$searchTerm = str_replace(" ", "+", $searchTerm);
$request = "/search.php?terms=" . $searchTerm;
}
$cat = tfb_getRequestVar("cat");
if(empty($cat)) $cat = tfb_getRequestVar("mainGenre");
if(!empty($cat))
{
if(strpos($request, "?")) {
$request .= "&cat=" . $cat;
} else {
$request .= "?cat=" . $cat;
}
}
if (!empty($this->pg))
{
if(strpos($request, "?")) {
$request .= "&page=" . $this->pg;
} else {
$request .= "?page=" . $this->pg;
}
}
if ($this->makeRequest($request)) {
return $this->parseResponse();
} else {
return $this->msg;
}
}
//----------------------------------------------------------------
// Function to parse the response.
function parseResponse()
{
$output = $this->tableHeader();
$s = $this->htmlPage;
$bg = $this->cfg["bgLight"];
$s = substr($s, strpos($s, "
"));
if ($s === false) {
return "";
}
$s = substr($s, strpos($s, "") - strpos($s, "
", $s);
foreach($tmpListArr as $line)
{
$buildLine = true;
if (strpos($line, "cat=") !== false) {
$ts = new ToTo($line);
// we always have category description, but when searching,
// there is no category id, so we try to find it...
if (!is_int($ts->catId))
$ts->catId = array_search($ts->catName, $this->mainCatalog);
if (is_int(array_search($ts->catId, $this->catFilter))) {
$buildLine = false;
}
if (!empty($ts->torrentFile) && $buildLine) {
$output .= trim($ts->BuildOutput($bg));
if ($bg == $this->cfg["bgLight"]) {
$bg = $this->cfg["bgDark"];
} else {
$bg = $this->cfg["bgLight"];
}
}
}
}
$output .= "
";
// http://tokyotosho.com/?cat=4&page=2
// is there paging?
$s = $this->htmlPage;
if (strpos($s, " | | ";
if (preg_match("@.*page=([0-9]*)&cat=([0-9]*)\">.*Previous 50.*@U", $s, $parts)) {
$output .= "searchURL() . "&pg=" . $parts[1] . "&cat=" . $parts[2] . "\"><< Previous 50 :: ";
}
$output .= "searchURL() . "\">50 Most Recent";
if (preg_match("@.*page=([0-9]*)&cat=([0-9]*)\">Next 50 .*@U", $s, $parts)) {
$output .= " :: searchURL() . "&pg=" . $parts[1] . "&cat=" . $parts[2] . "\">Next 50 >>";
}
$output .= " |
";
}
return $output;
}
// Function to setup the table header - overridden for toto (no seeds, no peers)
function tableHeader()
{
$output = "";
$output .= "
\n";
$output .= "cfg["table_header_bg"]."\">";
$output .= " | | ";
$output .= " Torrent Name | ";
$output .= " Category | ";
// $output .= " Date | ";
$output .= " Size | ";
$output .= "
\n";
return $output;
}
}
// This is a worker class that takes in a row in a table and parses it.
class ToTo
{
var $catId = "";
var $catName = "";
var $torrentFile = "";
var $torrentName = "";
var $torrentDisplayName = "";
var $torrentSize = "";
var $dateAdded = "";
var $comment = "";
function ToTo($line) {
if (strlen($line) > 0) {
if (0 == preg_match(
"@.*
([^\"]*)" .
".*Size: ([^ ]*) \| Date: ([^\|<]*).*@", $line, $parts))
{
// search results
preg_match(
"@.*
([^\"]*)" .
".*Size: ([^ ]*) \| Date: ([^\|<]*).*@", $line, $parts);
}
$this->catId = trim($parts[1]);
$this->catName = trim($parts[2]);
$this->torrentFile = $parts[3];
$this->torrentName = $parts[4];
$this->torrentSize = trim($parts[5]);
$this->dateAdded = trim($parts[6]);
$this->torrentDisplayName = $this->torrentName;
if(strlen($this->torrentDisplayName) > 103) {
$this->torrentDisplayName = substr($this->torrentDisplayName, 0, 100) . "...";
}
if (preg_match("@.*Comment: (.*)@U", $line, $parts)) $this->comment = trim($parts[1]);
}
}
function BuildOutput($bg) {
$output = "\n";
$output .= " torrentFile."\"> torrentName."\" border=0> | \n";
$output .= " torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName." | \n";
$output .= " " . $this->catName . " | \n";
// $output .= " " . $this->dateAdded . " | \n";
$output .= " " . $this->torrentSize . " | \n";
$output .= "
\n";
return $output;
}
}
?>