Advertisement
Narayan

Scc-autodl.script.irssi

Jun 23rd, 2012
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 5.86 KB | None | 0 0
  1. # --------------------------------------
  2. # SCC Auto Download Script for Irssi
  3. # version 1.3+debug by cyb
  4. # --------------------------------------
  5.  
  6. use Net::SSLeay;
  7. use LWP::Simple;
  8. use Irssi;
  9. use Irssi::Irc;
  10.  
  11. # your passkey goes here
  12. $passkey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  13.  
  14. # default place torrents will be downloaded to
  15. $torrentdir = "/home/narayan/Downloads/";
  16.  
  17. # Debug
  18. $debug = 1;
  19.  
  20. # Retry delay in seconds
  21. $retry = 30;
  22.  
  23. # [ Define categories to download below. ]
  24. #
  25. # Please remove the seperator(/ or -, dont worry about _ like Music_Videos can be left as is) from the category ie, tv/xvid becomes $tvxvid = 1;
  26. # Movies/Xvid becomes $moviesxvid =1; etc... and make sure it is in lowercase.
  27.  
  28. #$tvx264 = 1;
  29. #$moviesxvid = 1;
  30. #$tvxvid = 1;
  31. $mp3 = 1;
  32. $moviespacks = 1;
  33. $gamespacks = 1;
  34. $xxxpacks = 1;
  35. $musicpacks = 1;
  36. $tvpacks = 1;
  37. $gamespc = 1;
  38. #$apps0day = 1;
  39. #$tvdvdrip = 1;
  40.  
  41. # [ Inclusion and Exclusion Filters ]
  42. # NOTE: If NO filters are defined, the script will download ALL torrents from the category.
  43. # You can have zero, one or more filters.
  44.  
  45. # Define inclusion filters
  46. #
  47. # Same as defining categories, remove category seperator and make sure its lowercase with the keyword 'filter' added to the
  48. # end of the category name
  49.  
  50. $gamespcfilter = "RELOADED|SKIDROW|ViTALiTY|FLT";
  51.  
  52. # Define exclusion filter (NOT filter)
  53. #
  54. # Same as above, keyword for this filter is 'not', add 'not' to end of the category name for this filter to be active
  55. # $tvxvidnot = "Greys.Anatomy|Smallville";
  56. #$moviesxvidnot = "internal";
  57.  
  58. # [ Size filters ]
  59. #
  60. # Define the max size of torrents... the keyword to add this time to the category name is 'size'
  61. # NOTE: Put size in MB
  62. #$tvpacksmax = 20000;
  63.  
  64. # Define min size of torrents
  65. # Add min to the end of the category
  66. #$tvpacksmin = 1000;
  67. #$mp3min = 100;
  68. #$apps0daymin = 300;
  69.  
  70.  
  71. # [ Specific directory for a category ]
  72. #  
  73. #  Add 'dir' to the end of the category name... if this isnt defined, the default place to download torrnets will be used
  74. #$apps0daydir = "/home/cyb/t/appz";
  75.  
  76. #$mp3dir = "/home/cyb/t/mp3";
  77. #$tvpacksdir = "/home/cyb/t/packs";
  78.  
  79.  
  80. #---------------------------------------------------------------------------------
  81. #                               END OF CONFIG
  82. #---------------------------------------------------------------------------------
  83.  
  84. my $url = "https://sceneaccess.eu";
  85. my $aurl = " ";
  86. my $botnick = "SCC";
  87.  
  88. use vars qw($VERSION %IRSSI);
  89.  
  90. $VERSION="1.3";
  91. %IRSSI = (
  92.         authors=> 'cyb',
  93.         name=> 'SCCauto',
  94.         description=> 'SCC Auto download script',
  95.         license=> 'GPL',
  96. );
  97.  
  98. Irssi::print ("%_SCC Auto Download Script v1.3 Loaded%:%_by cyb");
  99.  
  100.  
  101. sub event_privmsg {
  102.  my ($server, $data, $nick, $address) = @_;
  103.  my ($target, $text) = split(/ :/, $data, 2);
  104.  $text =~ s/\x03\d?\d?(,\d?\d?)?|\x02|\x1f|\x16|\x06|\x07//g;
  105.  
  106. my $match = qr/NEW in (.*): -> (.*) \((.*) (MB|GB)\) \- .*details\.php\?id=(.*)\)/i;
  107.  
  108. if ($text =~ $match)
  109. {
  110. $disptype = $1;
  111. $type = $1;
  112. $release = $2;
  113. $rlssize = $3;
  114. $mborgb = $4;
  115. $relid = $5;
  116. }
  117.  
  118. $type =~ s/[\/,\-]//;
  119. # $type =~ s/\///;
  120. $type = lc $type;
  121. $release =~ s/\s.*$//;
  122. $filter = "$type" . "filter";
  123. $notfilter = "$type" . "not";
  124. $sizecheck = "$type" . "max";
  125. $minsize = "$type" . "min";
  126. $typedir = "$type" . "dir";
  127.  
  128. if ($mborgb =~ /GB/) { $rlssize = $rlssize * 1024; }
  129.  
  130.  
  131. if ($type =~ /.*packs/) { $aurl = "downloadbig2.php"; } else { $aurl = "download2.php"; }
  132. $furl = "$url/$aurl/$relid/$passkey/$release" . ".torrent";
  133.  
  134. # Irssi::print("$$typedir");
  135. if (defined($$typedir)) {
  136. $filename = "$$typedir" . "/$release" . ".torrent";
  137. } else {
  138. $filename = "$torrentdir" . "/$release" . ".torrent";
  139. }
  140.  
  141.  
  142. my $failed = 0;
  143.  
  144. if (($nick =~ /$botnick/) && (defined($$type) && $$type == 1) && (!(-e $filename))) {
  145. if ($debug == 1) { Irssi::print("Passed: botnick check, category defined, file doesnt exist");
  146. $w = filter($release, $$filter);
  147. $x = notfilter($release, $$notfilter);
  148. $y = sizefilter($rlssize, $$sizecheck);
  149. $z = minsize($rlssize, $$minsize);
  150. Irssi::print("Filter: $w Notfilter: $x Max size: $y Min size: $z");
  151. Irssi::print("Filter: ($release/$$filter) Notfilter: ($release/$$notfilter) Maxsize: ($rlssize/$$sizecheck) Minsize: ($rlssize/$$minsize)");
  152. }
  153.  
  154.         if (filter($release, $$filter) == 1 && notfilter($release, $$notfilter) == 1 && sizefilter($rlssize, $$sizecheck) == 1 && minsize($rlssize, $$minsize) == 1) {
  155.         my ($dltype, $length, $mod,$expires, $server) = head($furl);
  156.                 if ((download($furl,$filename,0) == 1) && ($dltype eq "application/x-bittorrent")) {
  157.                         Irssi::print("%G[$disptype]%n $release downloaded successfully from %p$botnick%n");
  158.                 }
  159.                 elsif (download($furl, $filename, $retry) == 1) {
  160.                         Irssi::print("%B[$disptype]%n $release downloaded on retry ($retry s) from %p$botnick%n");
  161.  
  162.                 } else {
  163.                         Irssi::print("%R[$disptype]%n $release failed to download, giving up");
  164.                 }
  165.         }
  166.  
  167. }
  168.  
  169.  
  170. }
  171.  
  172. sub filter {
  173. if (defined($_[1]) && $_[0] =~ /$_[1]/i) {
  174. return 1;
  175. }
  176.  
  177. elsif (!defined($_[1])) {
  178. return 1;
  179.  
  180. }
  181. else {
  182. return 0;
  183. }
  184. }
  185.  
  186. sub notfilter {
  187. if (defined($_[1]) && $_[0] =~ /$_[1]/i) {
  188. return 0;
  189. }
  190.  
  191. elsif (!defined($_[1])) {
  192. return 1;
  193.  
  194. }
  195. else {
  196. return 1;
  197. }
  198.  
  199. }
  200.  
  201.  
  202. sub sizefilter {
  203. if (defined($_[1]) && ($_[1] > $_[0])) {
  204. return 1;
  205. }
  206.  
  207. elsif (!defined($_[1])) {
  208. return 1;
  209.  
  210. }
  211. else {
  212. return 0;
  213. }
  214.  
  215. }
  216.  
  217. sub minsize {
  218. if (defined($_[1]) && ($_[1] < $_[0])) {
  219. return 1;
  220. }
  221.  
  222. elsif (!defined($_[1])) {
  223. return 1;
  224.  
  225. }
  226. else {
  227. return 0;
  228. }
  229.  
  230. }
  231.  
  232. sub download {
  233. sleep ($_[2]);
  234. if ($debug == 1) { Irssi::print("Downloading: $_[0] Saving to: $_[1]"); }
  235. my $status = getstore($_[0], $_[1]);
  236. if (is_success($status)) { return 1; } else { return 0; }
  237.  
  238. }
  239.  
  240. Irssi::signal_add("event privmsg", "event_privmsg")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement