Archive for the ‘Uncategorized’ Category

Retrieving Rapidshare Files with Python

Friday, January 2nd, 2009

A cursory google search will reveal several scripts for retrieving rapidshare files using python, but each one I’ve seen delegates the actual retrieval to wget.

This is not necessary.

Rapidshare uses basic authentication to identify logged in members and urllib2 can handle this easily.

The following method would do the trick without the need to call external executables:

def rapidget(url. login, password):
    "Retrieve files from rapidshare using only python"
    request = urllib2.Request(url)
    base64string = base64.encodestring('%s:%s' % (login, password))[:-1]
    request.add_header("Authorization", "Basic %s" % base64string)
    i = url.rfind('/')
    filename = url[i+1:]
    print url, "->", filename
    file = open(filename, 'wb')
    handle = urllib2.urlopen(request)
    buffer = ''
    buffersize = 1024*1024
    while True:
        buffer = handle.read(buffersize)
        if not buffer:
            handle.close()
            file.close()
            break
        file.write(buffer)
        buffer = ''
        print '.',

This assumes, of course, that you have an account at rapidshare.

56K Nostalgia

Tuesday, November 27th, 2007

What the lights on a modem mean:

TR Terminal Ready Illuminated when terminal software is activated
HS High Speed Illuminated during K56flex connections (32.000 to 56.000 bps)
CD Carrier Detect The modem is connected with another modem.
AA Auto Answer The modem is ready to answer incoming calls automatically.
OH Off Hook The modem has picked up the phone line, just like taking your phone handset “off hook.”
SD Send Data Flashes as data are sent.
RD Receive Data Flashes as data are received.
PWR Power The modem is receiving power.

Using Mutt with Exim4 to Send Mail via Smarthost over SSL (TLS) Connection on Port 465

Monday, November 26th, 2007

One day I’ll learn pine and I’m sure I’ll love it but for now I’m hooked on mutt.

Getting mutt to use exim4 for delivery is as simple as adding set sendmail="/usr/sbin/exim4" to your ~/.muttrc. Getting exim4 working as a smarthost to authenticate over port 465 is far harder.

The solution is to use a tunnel as outlined in this excellent post: exim4 with ssmtp on Debian.

Before finding this answer, I also discovered a very clear post on testing an smtp auth connection here and a useful tutorial on setting up and testing exim, both of which may be helpful to other people.

del.icio.us bookmarks for October 21st through October 25th

Saturday, October 27th, 2007

Links for October 21st through October 25th:

del.icio.us bookmarks for October 13th through October 20th

Sunday, October 21st, 2007

Links for October 13th through October 20th: