samedi 5 mars 2011

Automatic download from MegaUpload

Updated: script updated after megaupload.com changes their downloads system

This script allows you to:
  1. Store MegaUpload links in a file .list
  2. Run the script on a shell
  3. Stop and resume downloads at any time
  4. Add links to the files even when working
Create a file .list (hidden) in the downloads folder
ubugnu@ubugnu-laptop:~$ cd Downloads/
ubugnu@ubugnu-laptop:~$ touch .list
than create the script file
ubugnu@ubugnu-laptop:~$ sudo nano /usr/bin/mega
and put

#!/bin/bash
#for l in $@

list=`cat .list`
for l in $list
do
echo "downloading $l..."
url=`wget -qO- $l | grep -P "id=\"downloadlink\"" | grep -oP "(((http)\://){1}\S+)" | grep "megaupload.com\/files" | tr -d "\""`
echo "url found: [$url] sleeping 46 sec..."
sleep 46
wget -c $url
echo "$l downloaded" `date`
sed -i '1 d' .list
done;
make it executable
ubugnu@ubugnu-laptop:~$ sudo chmod +x /usr/bin/mega
To begin downloads, populate the .list file with MegaUpload links (line by line) than enter to the download folder and run the script
ubugnu@ubugnu-laptop:~$ cd Downloads/
ubugnu@ubugnu-laptop:~$ mega