Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 5.05 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5. my $COOKIEFILE  = '/home/fluff/curl_cookiejar';
  6. my $COMMENT     = "put your TT comment here";
  7.  
  8. my $CURL_BASE = <<EOF;
  9. <?php
  10. ini_set("error_reporting", E_ALL);
  11. function GET(\$url,\$referer = "",\$proxy="", \$header=false) {
  12.     \$ch = curl_init();
  13.     curl_setopt(\$ch, CURLOPT_URL,"\$url");
  14.     curl_setopt(\$ch, CURLOPT_COOKIEJAR, '$COOKIEFILE');
  15.     curl_setopt(\$ch, CURLOPT_COOKIEFILE, '$COOKIEFILE');
  16.     if (\$referer != "")
  17.         curl_setopt (\$ch, CURLOPT_REFERER, \$referer);
  18.     if (\$proxy != "")
  19.     {
  20.         curl_setopt(\$ch, CURLOPT_PROXY, "");
  21.         curl_setopt(\$ch, CURLOPT_HTTPPROXYTUNNEL,true);
  22.     }
  23.     if (\$header) {
  24.         curl_setopt(\$ch, CURLOPT_HEADER, true);
  25.     }
  26.     curl_setopt(\$ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; nl; rv:1.9.1) Gecko/20090612 Firefox/ 3.5");
  27.     curl_setopt(\$ch, CURLOPT_RETURNTRANSFER, true);
  28.     \$result = curl_exec(\$ch);
  29.     curl_close(\$ch);
  30.     return \$result;
  31. }
  32.  
  33. function POST(\$url,\$data,\$referer = "",\$proxy="") {
  34.     \$ch = curl_init();
  35.     curl_setopt(\$ch, CURLOPT_URL,"\$url");
  36.     if (\$referer != "")
  37.         curl_setopt (\$ch, CURLOPT_REFERER, \$referer);
  38.  
  39.     curl_setopt(\$ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; nl; rv:1.9.1) Gecko/20090612 Firefox/ 3.5");
  40.     if (\$proxy != "") {
  41.         curl_setopt(\$ch, CURLOPT_PROXY, "");
  42.         curl_setopt(\$ch, CURLOPT_HTTPPROXYTUNNEL,true);
  43.     }
  44.     curl_setopt(\$ch, CURLOPT_COOKIEJAR, '$COOKIEFILE');
  45.     curl_setopt(\$ch, CURLOPT_COOKIEFILE, '$COOKIEFILE');
  46.     curl_setopt(\$ch, CURLOPT_RETURNTRANSFER, true);
  47.     curl_setopt(\$ch, CURLOPT_POST, true );
  48.     curl_setopt(\$ch, CURLOPT_POSTFIELDS, \$data );
  49.     curl_setopt(\$ch, CURLOPT_HEADER, true);
  50.     curl_setopt(\$ch, CURLOPT_HTTPHEADER, array('Expect:'));
  51.     \$result = curl_exec(\$ch);
  52.     curl_close(\$ch);
  53.     return \$result;
  54. }
  55.  
  56. EOF
  57.  
  58.  
  59. my $NYAA_POST_PHP = <<EOF;
  60. \$data = array(
  61.     'torrent'=>"\@___TORRENTFILE___",
  62.     'catid'=>"___CATID___",
  63.     'description'=>"Hi Lance",
  64.     'submit'=>"Upload",
  65.     'rules'=>"1",
  66.     'info'=>'',
  67. );
  68. \$a = POST("http://www.nyaatorrents.org/?page=upload",\$data,"http://www.nyaatorrents.org/?page=upload");
  69. if (preg_match('/Record-ID:\\s*(\\d+)/i', \$a, \$m))
  70.     echo \$m[1];
  71. else
  72.     echo "Couldn't post to Nyaatorrents";
  73. EOF
  74.  
  75. my $TT_POST_PHP = <<EOF;
  76. POST("http://tokyotosho.info/new.php","type=___CATID___&url=".urlencode("___URL___")."&comment=".urlencode("___COMMENT___").
  77.     "&countdown=156&website=&send=Submit+New+Torrent","http://tokyotosho.info/new.php");
  78. EOF
  79.  
  80. my $JISHAKU_POST_PHP = <<EOF;
  81. GET(
  82.     "http://www.jishaku.net/api.php?action=add&key=MAKEUPYOUROWNGODDAMNEDKEY&url=".urlencode('___URL___').
  83.     "&website=&comment=".urlencode("___COMMENT___").
  84.     "&category=___CATID___&translation=xx&nsfw=0&batch=0"
  85. );
  86. EOF
  87.  
  88.  
  89. sub get_category_id_nyaa {
  90.     my $name = shift;
  91.  
  92.     return '1_11' if ($name eq 'anime');
  93.     return '5_20' if ($name eq 'drama');
  94.     return '5_22' if ($name eq 'music');
  95.  
  96.     return '1_11';
  97. }
  98.  
  99.  
  100. sub get_category_id_tt {
  101.     my $name = shift;
  102.  
  103.     return '7' if ($name eq 'anime');
  104.     return '9' if ($name eq 'music');
  105.     return '8' if ($name eq 'drama');
  106.  
  107.     return '7';
  108. }
  109.  
  110. sub get_category_id_jishaku {
  111.     my $name = shift;
  112.  
  113.     return '1' if ($name eq 'anime');
  114.     return '3' if ($name eq 'drama');
  115.     return '5' if ($name eq 'music');
  116.  
  117.     return '1';
  118. }
  119.  
  120. sub post_torrent_nyaa {
  121.     my ($torrentfile, $catid, $count) = @_;
  122.     $count = (defined($count)) ? $count+1 : 0;
  123.  
  124.     my $phpfile = '/tmp/nyaapost-temp'.time().'.php';
  125.     open(PFILE, ">", $phpfile) or (print("couldn't write to $phpfile: $!\n\n") and return);
  126.  
  127.     print PFILE $CURL_BASE;
  128.  
  129.     my $np = $NYAA_POST_PHP;
  130.     $np =~ s/___TORRENTFILE___/$torrentfile/;
  131.     $np =~ s/___CATID___/$catid/;
  132.     print PFILE $np;
  133.     close(PFILE);
  134.  
  135.     my $tid = `php $phpfile`;
  136.     #print "nyaapost returned: $tid\n";
  137.     if ($tid !~ /^\d+$/) {
  138.         return undef unless $count < 3;
  139.         return post_torrent_nyaa($torrentfile, $catid, $count);
  140.     }
  141.  
  142.     unlink($phpfile);
  143.     return 'http://nyaatorrents.org/?page=download&tid='.$tid;
  144. }
  145.  
  146. sub post_tt {
  147.     my ($url, $catid) = @_;
  148.  
  149.     my $phpfile = '/tmp/tokyotosho-temp'.time().'.php';
  150.     open(PFILE, ">", $phpfile) or (print("couldn't write to $phpfile: $!\n\n") and return);
  151.  
  152.     print PFILE $CURL_BASE;
  153.  
  154.     my $tt = $TT_POST_PHP;
  155.     $tt =~ s/___URL___/$url/;
  156.     $tt =~ s/___CATID___/$catid/;
  157.     $tt =~ s/___COMMENT___/$COMMENT/;
  158.     print PFILE $tt;
  159.     close(PFILE);
  160.  
  161.     `php $phpfile`;
  162.     unlink($phpfile);
  163. }
  164.  
  165. sub post_jishaku {
  166.     my ($url, $catid) = @_;
  167.  
  168.     my $phpfile = '/tmp/jishaku-temp'.time().'.php';
  169.     open(PFILE, ">", $phpfile);
  170.  
  171.     print PFILE $CURL_BASE;
  172.  
  173.     my $j   = $JISHAKU_POST_PHP;
  174.     $j      =~ s/___URL___/$url/;
  175.     $j      =~ s/___CATID___/$catid/;
  176.     $j      =~ s/___COMMENT___/$COMMENT/;
  177.     print PFILE $j;
  178.     close(PFILE);
  179.  
  180.     `php $phpfile`;
  181.     unlink($phpfile);
  182. }