Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Code:
Selected Language:
Show Linenumbers:
Short link for Twitter:
HTML:

HTML view:

Copy Source | Copy HTML
  1. #!/bin/bash
  2.  
  3. ################################################
  4. #Purpose: Automate the downloading of files from rapidshare using the free account
  5. #using simple unix tools.
  6. #Date: 14-7-2008
  7. #Authors: Slith, Tune
  8. #Improvements: Please email them to jwhatson@gmail.com
  9. #Post Feedback and comments to http://emkay.unpointless.com/Blog/?p=63
  10. #Notes: To use curl instead of wget use 'curl -s' and 'curl -s -d'
  11. #Version: 1.2 - Rapidshare has added a wait time in between file downloads. On top of your download
  12. #to start. This has been fixed.
  13. #Added a 'kill time' feature. Specify killTime as an hour of the day and if the time is greater than this.
  14. #the script will end. Useful for using cron to start script at offpeak time and killing it when off speak ends.
  15. ################################################
  16.  
  17. mirror=dt.rapidshare.com;
  18.  
  19. ## possible mirrors
  20. # cg.rapidshare.com
  21. # l34.rapidshare.com
  22. # tg.rapidshare.com
  23. # gc2.rapidshare.com
  24. # dt.rapidshare.com
  25. # tl2.rapidshare.com
  26. # l32.rapidshare.com
  27. # l3.rapidshare.com
  28. # gc.rapidshare.com
  29. # l33.rapidshare.com
  30. # tl.rapidshare.com
  31. # cg2.rapidshare.com
  32.  
  33. killTimeEnable=0
  34. killTime=9
  35.  
  36. function getOutputFromFreeUserSubmit(){
  37.         URL=$(wget -q -O - $line | grep "<form id=\"ff\" action=\"" | grep -o 'http://[^"]*');
  38.         output=$(wget -q -O - --post-data "dl.start=Free" "$URL");
  39. }
  40.  
  41. while read line
  42. do
  43.  
  44.         if [[ $killTimeEnable -eq 1 && $(date +%H) -gt $killTime ]]; then exit; fi;
  45.  
  46.         getOutputFromFreeUserSubmit output; #call getOutputFromFreeUserSubmit, result is stored in $output
  47.         posibleWaitTime=$(echo "$output" | grep "try again in about" | grep -o "[0-9]\{1,3\}");
  48.  
  49.         if [ -z "$posibleWaitTime" ]; then #check for zero lenght string
  50.                 echo "No wait time, likely to be the first file you have downloaded in a while";
  51.         else
  52.                 echo "Waiting $[ $posibleWaitTime+1] minutes (in between file download wait)";
  53.                 sleep $[ $posibleWaitTime+1]m;
  54.                 getOutputFromFreeUserSubmit output; #Now we have waited we will try again...
  55.         fi
  56.  
  57.         time=$(echo "$output" | grep "var c=[0-9]*;" | grep -o "[0-9]\{1,3\}");
  58.         ourfile=$(echo "$output" | grep "document.dlf.action=" | grep -o "http://[^\"]*$mirror[^\\]*");
  59.         echo "Waiting $time secs for download of $ourfile";
  60.         sleep $time;
  61.         wget $ourfile;
  62.         ./p1 | grep pppd | grep -v grep | awk '{print $1;}' | xargs ./p2;
  63.         sleep 5;
  64.  
  65. done < input.txt
  66.  

Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2010
Some API could be found at http://s-c.me/WS/HighLight.asmx