Simple download from RS & extract

Status
Not open for further replies.

Tango

Moderator
Staff member
4,055
2009
1,610
15,335
I download movies to remote upload to moviehosts.

I used to use command line to do it all, but got around to making it easier :)

I made a simple script that
  • Downloads RS links.
  • Extracts rar's
  • Deletes orignal .rar's and Junk files
  • Displays finished movie file URL

Create a folder & CMOD to 777

http://www.g-loaded.eu/2010/10/04/rsapiget-download-rapidshare-api/
save the py script to rs.py (enter your RS premium details in config)



Save the following to index.php
PHP:
<?
	$files = glob("{*.avi,*.mkv,*.mp4}", GLOB_BRACE); 
	foreach($files as $file)
		{
		echo "<a href='".substr("http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."",0,-9)."$file'>$file</a><br />";
		} 

	if(empty($_POST))
		{
		?>
			RS links<br /><form method="post" action=""><textarea name="links" style="width:400px;height:250px;"></textarea><br/><input type="submit" value="Submit"/></form>
		<?
		}	else	{
		$links = array();
		preg_match_all("/http:\/\/rapidshare\.com\/files\/[0-9A-Za-z]+\/[-_.0-9A-Za-z]+/i", $_POST['links'], $matches, PREG_SET_ORDER);
		foreach($matches as $link)
			{
			$links[] = $link[0];
			$filename = getfilename($link[0]);
			echo "Downloading : ".$filename."<br />";
			shell_exec("python rs.py " . $link[0] . "");
			}
		echo "<br />Extracting<br />";
		$filename = getfilename($link[0]);
		shell_exec("rar e " . $filename . "");
		echo "Done - Deleting rars<br />";
		foreach($matches as $link)
			{
			$links[] = $link[0];
			$filename = getfilename($link[0]);
			unlink($filename);
			}

		$files = glob("{*.txt,*.url,*.nfo,*.jpg}", GLOB_BRACE); 
		foreach($files as $file)
			{
			unlink($file);
			} 	
		echo "Finished";
	}

        function getfilename($link)
        {
          $startpos = strripos($link, "/");
          $endpos = strlen($link);
          $theid = substr($link, ($startpos + 1), ($endpos - $startpos));
          return $theid;
        }
?>
 
2 comments
I checked out basename when i was making it, but couldnt be bothered to see how it handled special chars etc, so used the function I had :D

I updated it a bit to remove more junk files and list completed movies
 
Status
Not open for further replies.
Back
Top