Pre time Bot (Scene)

Started by greentide, July 22, 2011, 11:56:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

greentide

Hi

Thanks for all the help!

I desperately need to pre bot to work on my tracker and cant seem to get hold of those guys is there not a open one available?

Please please  :-[

Thanks :)

stoner

Quote from: Mindless on July 23, 2011, 09:56:52 AM
The tracker has the pretime mod installed, you only need pre-db access, can ask mistero, islander and few others if stoners code is no good.

I would go this route as 1: Mindless has the code already in there (Didnt know this sry m8) and 2: You will get better results from a private pre-db than from a public IRC channel.  Saying that for all the time I used it, it found 99.9% of scene releases as I they was being uploaded by our auto bot, including music which was preing around 10 seconds and less.  The key is to find a really good public pre irc channel.  Not something like doopes or orlydb.  I dont want to say in public which one I used, but send me a PM and I will let you know.


greentide

Thanks for your help :)

Where will I need to add the bot too, I haven't come across it yet.

Thanks Again :)

Mindless

The tracker has the pretime mod installed, you only need pre-db access, can ask mistero, islander and few others if stoners code is no good.

greentide

Thanks buddy..

Will give it a bash :) and if you have some time could you may by integrate it with in the tracker :)

stoner

Not quite sure that this is what you want (might not even work on this source  ::) )
This is pulled straight out of my tbdev09 source code, I never got round to adding it to V2 memcached, so this is not tested.  I have the weekend off work, so if I can put the weed down for a couple of hours I might get round to installing my test site again and trying to intergrate and test this.

NOTE:
This mod will sit in a IRC channel and log it to a DB, this might be frowned upon by some channels, so be wise.  I used it in a pretty well known public channel for a couple of months with no problems though.
Also you may need to change some querys depending on the output of the IRC channel.

Here Goes.
Torrenttable.php
Add near the top.  (I made this the first function)
function ago($st){
$secs = $st;
   $mins = floor($st / 60);
   $hours = floor($mins / 60);
   $days = floor($hours / 24);
   $week = floor($days / 7);
   $month = floor($week / 4);

   $week_elapsed = floor(($st - ($month * 4 * 7 * 24 * 60 * 60)) / (7 * 24 * 60 * 60));
   $days_elapsed = floor(($st - ($week * 7 * 24 * 60 * 60)) / (24 * 60 * 60));
   $hours_elapsed = floor(($st - ($days * 24 * 60 * 60)) / (60 * 60));
   $mins_elapsed = floor(($st - ($hours * 60 * 60)) / 60);
   $secs_elapsed = floor($st - $mins * 60);

   $pretime = "";

   if($secs_elapsed > 0)
      $pretime = "$secs_elapsed Seconds " .$pretime;
   if($mins_elapsed == 1)
      $pretime = "$mins_elapsed Minute " .$pretime;
   elseif($mins_elapsed > 0)
      $pretime = "$mins_elapsed Minutes " .$pretime;
   if($hours_elapsed == 1)
      $pretime = "$hours_elapsed Hour " .$pretime;
   elseif($hours_elapsed > 0)
      $pretime = "$hours_elapsed Hours " .$pretime;
   if($days_elapsed == 1)
      $pretime = "$days_elapsed Day " .$pretime;
   elseif($days_elapsed > 0)
      $pretime = "$days_elapsed Days " .$pretime;
   if($week_elapsed == 1)
      $pretime = "$week_elapsed Week " .$pretime;
   elseif($week_elapsed > 0)
      $pretime = "$week_elapsed Weeks " .$pretime;
   if($month == 1)
      $pretime = "$month Month " .$pretime;
   elseif($month > 0)
      $pretime = "$month Months " .$pretime;
return "$pretime";
}

function rel_time($from, $to = null)
{
  $to = (($to === null) ? (time()) : ($to));
  $to = ((is_int($to)) ? ($to) : (strtotime($to)));
  $from = ((is_int($from)) ? ($from) : (strtotime($from)));

  $units = array
  (
   "year"   => 29030400, // seconds in a year   (12 months)
   "month"  => 2419200,  // seconds in a month  (4 weeks)
   "week"   => 604800,   // seconds in a week   (7 days)
   "day"    => 86400,    // seconds in a day    (24 hours)
   "hour"   => 3600,     // seconds in an hour  (60 minutes)
   "minute" => 60,       // seconds in a minute (60 seconds)
   "second" => 1         // 1 second
  );

  $diff = abs($from - $to);
  $suffix = (($from > $to) ? ("from now") : ("ago"));

  foreach($units as $unit => $mult)
   if($diff >= $mult)
   {
    $and = (($mult != 1) ? ("") : ("and "));
    $output .= ", ".$and.intval($diff / $mult)." ".$unit.((intval($diff / $mult) == 1) ? ("") : ("s"));
    $diff -= intval($diff / $mult) * $mult;
   }
  $output .= " ".$suffix;
  $output = substr($output, strlen(", "));

  return $output;
}


Add somewhere before the code to display the torrent name.
$add = $row['added'];
$name = $row['save_as'];

    $pretime = $row['pretime'];

$timestamp = strtotime($pretime);
$time = $row['added'];
if ($row["pretime"] && $row["pretime"] == '0000-00-00 00:00:00') {
$ago = "";
} else {
$ago = ago($time+60*59.7 - $timestamp);
$ago = "Uploaded $ago After Pre";

}


Add to the line where it displays the torrent name
".$ago."
So would look something like this
$htmlout .= "'><b>$dispname</b></a>".($row['added'] >= $CURUSER['last_browse'] ? " <font color=\"lime\">[New]</font>" : "")."".$isdlfree.$isdouble."<br /> ".$ago." ".$free_tag.$uploaduser;


takeupload.php add
//Pretime mod
$res = mysql_query("SELECT `logstamp` FROM `irssi_logs` WHERE `textinput` like '%$torrent%'") or die(mysql_error());

while ($row = mysql_fetch_row($res))
$pre = $row[0];

In the big query add
pretime, and    $pre,

For the logging from the irc channel, you need to be running irssi which afaik is linux only
Here is the link for the main page
http://www.seanodonnell.com/wp/2011/04/15/irssi-mysql-and-perl-irc-channel-logging-irssi_logs-pl/
Read the files with it, as they will explain on how to set that side up, its pretty straight forward and i'm 90% sure it should all be drop in code.  I'm sure mindless will take a little look over it.
You can change this line in torrent details to adjust the time shown, some sites are 1hr / 2hr etc in front or behind.
$ago = ago($time+60*59.7 - $timestamp); 

NOTE2
Just remembered, this can start to fill up ur DB pretty darn quick.  something like 3,000+ entrys per day, I was just emptying that table each week manually.  But you could add something in cleanup to do this.
Once the torrents is uploaded and the pretime found, it is saved into the torrents table, so is no longer needed in the logs table.   Anyhow hopefully mindless / putyn or some of the other better coders here will see this and stick there 2 pennys in  8)

greentide

Hi

I wonder if you could please help me. I am quite used to uploading scene groups and im pretty sure that i've named the torrent correctly, but i'm ''getting pre-time not found.''

I would really like to use the scene bot.

Thanks.. :)