command-line rapidshare upload

If you want to upload something to rapidshare.com, quickly, and you only have command-line access, what do you do? This script was promising, but failed on line 30 because a regular expression didn’t match on something that turned out to be an empty (NoneType) object.

I replaced this code:
def upload(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("rapidshare.com", 80))
sock.send('GET /cgi-bin/rsapi.cgi?sub=nextuploadserver_v1 HTTP/1.0\r\n\r\n')
uploadserver = re.search('\r\n\r\n(\d+)', sock.recv(1000000000))
uploadserver = uploadserver.group().lstrip()
sock.close()

with this:
def upload(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("rapidshare.com", 80))
uls = sock.send('GET /cgi-bin/rsapi.cgi?sub=nextuploadserver_v1 HTTP/1.0\r\n\r\n')
uploadserver = str(uls)
sock.close()

and it worked. Update: Get it here.


  1. pavel

    Can’t be bothered to help debug it, but it broke:

    • yorksranter

      would seem to be an issue with the receive buffer? sock.recv(100000000) creates a buffer of that length; rapidshare has made some changes recently, so perhaps the new version returns too much stuff to fit in the buffer. Dunno what the other guy was doing using explicit memory allocation in python.

  2. rumgurke

    how i got it working:

    replace
    result = sock.recv(100000000)
    with
    result = sock.recv(10000)

    greetz




Leave a comment