Friday, April 03, 2009

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 comment:

Samwise said...

You know how to make a patch, right?

http://rapidshare.com/files/216999432/rsupload.py.patch.html

Guidance available upon request...

kostenloser Counter