Downloading torrents by text message


I was often stranded on a bus or somewhere else without wifi and wished I could start a torrent download before I forget to do it. I needed a way to use my cell phone to do it without having access to the internet. Twitter is the best place I could think of which will provide me with a simple way of transcending from the world of SMS into the world of interwebz. So I wrote a little python script that connects twitter, and a torrent server.

Typical use case

  1. You need a torrent, let’s say “Paintings of Van Gogh Collection”
  2. You make sure your cell phone is connected to your twitter accounts so you can tweet through text messages
  3. You text twitter with “@torrenter download Paintings of Van Gogh Collection”
  4. The torrent server runs this python script periodically, checking for new messages directed at its twitter account (or any twitter account I guess)
  5. The torrent server sees a new request, searches demonoid for the most seeded torrent that is relevant and starts downloading it

The setup

(It’s assumed that you have a linux based server you want to control through your cell phone)

  1. Make a twitter account for your torrenter
  2. Set up your phone to tweet through text messages
  3. Put the python script below on your torrent server
  4. Configure the variables inside the script (demonoid username and password, download path and twitter username for the torrenter)
  5. Set up cron to run it periodically
  6. Set up your torrent client to load torrent files from the folder you chose to download the torrents to in the config

Edit: Demonoid seems to have changed their domain to, so if anyone wants to try this, see if just changing the domain will work. If not I guess you’ll have to figure it out yourself.

import urllib, urllib2, json, re, cookielib

demonoid_user = ''
demonoid_password = ''
save_folder = ''
torrenter_twitter = ''

def torrenter_download(command):
    q = ' '.join(command[2:])
    listing = urllib2.urlopen(''+urllib.urlencode({
        'query' : q,
        'category' : 0,
        'subcategory' : 'All',
        'seeded' : 0,
        'external' : 2,
    torrent = re.findall(r'<a href="([/a-zA-Z0-9]+)"><img src="/images/downbg.gif"',[0]
    download = open(save_folder + q + '_' + str(torrent.rsplit('/')[4]) + '.torrent', 'wb')
                'nickname' : demonoid_user,
                'password' : demonoid_password,
                'returnpath' : torrent

    f = open(save_folder+'last_id.txt', 'r')
    last_id =
    last_id = ''

results = json.loads(
            'q' : '@'+torrenter_twitter,
            'rpp' : 10,

for req in results:
    command = req['text'].rsplit(' ')
    commands = {
        'download' : torrenter_download,

if len(results) > 0:
    f = open(save_folder+'last_id.txt', 'w')


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s