Category Archives: Python

Twisted Python RDT/RTSP Library and Stream Downloader

Twisted is a great framework for Python, but they don’t support RDT or RTSP protocol used for streaming Real video. The RDT/RTSP handler in MPlayer is a bit buggy and suffers from disconnect problems when receiving RTSP packets after switching to raw mode for RDT (though perhaps such occurrences are out of specification, they do [...]

Automatically Download Songs from Grooveshark

Because manually downloading songs from Grooveshark is too tedious, here’s a nice process to automatically save all the songs you listen to on Grooveshark. Unlike other methods, this does not use any extra bandwidth so you don’t need to listen to the song and download it, once is enough.

Wiki Parser v0.1 – Read Wikipedia Offline

Wiki Parser is a Python program which takes a Wikipedia dump and hosts it locally, offline. To save disk space, Wiki Parser keeps the dump compressed and serves articles to a web browser without decompressing the entire file. I originally created it to serve up Wikipedia articles from a compressed version, but seek times on [...]

Using Twisted Python library to replicate packets

Most of the programming I do is packet replication and automation. My workflow is to first analyze the handshakes and protocols in FireFox with the Tamper Data add-on. I use WireShark to nail down the interaction details. Finally, I recreate everything using the Twisted library in Python. Here’s a boilerplate to quickly recreate packets using [...]

Python FTP upload using Twisted

Here’s a snippet for uploading a file via FTP using the Twisted Python library available from TwistedMatrix. from twisted.protocols.basic import FileSender from twisted.protocols.ftp import FTPClient from twisted.internet.protocol import ClientCreator from twisted.internet import reactor   def fileTransferFail(failure): failure.printTraceback() reactor.stop()   def cbStore(consumer, filename): fs = FileSender() d = fs.beginFileTransfer(open(filename, ‘r’), consumer) d.addCallback(lambda _: consumer.finish()).addErrback(fileTransferFail) return d [...]