Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- //
- // Torrent folder post processing thingamajiggy.
- //
- //
- // Edit these vars to suit your directory structure and file paths //////////////
- $wput = "/usr/bin/wput";
- $user = "user";
- $pass = "password";
- $host = "servername";
- $MYSQLHOST = "ruri";
- $MYSQLUSER = "root";
- $MYSQLPASS = "mysqlpassword";
- $MYSQLDB = "announce";
- $db = mysql_connect($MYSQLHOST, $MYSQLUSER , $MYSQLPASS);
- mysql_select_db($MYSQLDB, $db) or die(mysql_error($db));
- $toplevels = array( // change the 2nd part to suit your dir names
- 'tv' => 'tv.eps',
- 'movie' => 'movies',
- 'x264' => 'x264',
- 'applications' => 'applications',
- 'games' => 'games',
- 'wii' => 'wii'
- );
- // Don't edit blow this line if you're clueless ////////////////////////////////
- $dir = trim($argv[1]);
- //
- // Match TV Eps based on 'SxxExx'
- //
- if($ok = preg_match('/(.*)\.S([0-9]+)E([0-9]+)/i', $dir, $m)) {
- $tld = $toplevels['tv'];
- $name = str_replace('.', ' ', $m[1]) .'/Season '. preg_replace('/^0+/', '', $m[2]);
- $destdir = "/$tld/". $name ."/";
- }
- //
- // Match movies based on 'DVDRIP/DVDSCR/CAM/XVID/DIVX/BDRIP'
- //
- else if($ok = preg_match('/DVDRIP|DVDSCR|CAM|XVID|DIVX|BDRIP/i', $dir, $m)) {
- $tld = $toplevels['movie'];
- $destdir = "/$tld/";
- }
- //
- // Match movies based on 'x264'
- //
- else if($ok = preg_match('/x264/i', $dir, $m)) {
- $tld = $toplevels['x264'];
- $destdir = "/$tld/";
- }
- else if($ok = preg_match('/ISO|Razor1911|RELOADED|FLT|DEViANCE|SKIDROW/i', $dir, $m)) {
- $tld = $toplevels['games'];
- $destdir = "/$tld/";
- }else if($ok = preg_match('/Wii|WII|wii/i',$dir,$m)) {
- $tld = $toplevels['wii'];
- $destdir = "/$tld/";
- } else {
- $rld = $toplevels['applications'];
- $destdir = "/$tld/";
- //
- // Perform the desired action(s) if a match was found
- //
- if($ok) {
- echo $destdir;
- exec("$wput '$dir' 'ftp://$user:$pass@$host$destdir' 2>&1", $output, $retval);
- $sqldir = '"' . $dir . '"';
- $query = "insert into downloads (name,printed) VALUES($sqldir,0)";
- mysql_query($query);
- if($retval == 0) {
- echo "Successfully uploaded $dir to $destdir.\n";
- } else {
- echo "FAILED to upload $dir to $destdir:\n";
- foreach($output as $line)
- echo $line ."\n";
- }
- } else {
- echo "NO MATCH for ". $dir ." :(\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement