Home > Uncategorized > Get updates of completed torrents via SMS Part 2

Get updates of completed torrents via SMS Part 2

The other day one of my friends Ankur , made a python script to get updates via sms using twitter account.
Check here :http://tinyurl.com/djbnon

I have changed the script to use Gmail SMTP instead .
Enjoy

import dbus,base64,urllib2,urllib
from dbus.mainloop.glib import DBusGMainLoop
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email import Encoders
import os

ver = "v1.0"
gmail_user = ""				                #Gmail Username

gmail_pwd  = ""					#Gmail Password
gmail_alias=" "+gmail_user                       #Gmail Nickname
gateway=""	# Check http://tinyurl.com/d5ghcv

def mailz(text):

    mail = MIMEMultipart()
    mail['From'] = gmail_alias

    mail['To'] = gateway
    mail.attach(MIMEText(text))
    mailServer = smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, gateway, mail.as_string())
    mailServer.close()

DBusGMainLoop(set_as_default=True)

s = dbus.SessionBus()
kt = s.get_object("org.ktorrent.ktorrent","/core")

def update(k):
        torrent = s.get_object("org.ktorrent.ktorrent","/torrent/"+k)
        name = torrent.get_dbus_method("name","org.ktorrent.torrent")
        mailz("ktorrent: finished " +name())

kt.connect_to_signal("finished",update)

import gobject
loop = gobject.MainLoop()
loop.run()
Advertisements
Categories: Uncategorized
  1. Pawan
    October 31, 2010 at 8:01 pm

    hey … this is a very nice script…though i wanted to know how do you obtain the value of the connection parameter in the get_object() call … if i need to make a similar script for any desktop application then how do i obtain the connection name and also the parameters like /core that you’ve used…

  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: