helo.
thanks for transmission. wonderful app.
would be great if you could integrate Twitter Support. Transmission could send a Direct Message to a preconf Twitter account when a download has finished. should be not to hard to integrate via the Twitter API.
Twitter Notification
-
- Transmission Developer
- Posts: 3142
- Joined: Fri Jan 13, 2006 8:08 pm
Re: Twitter Notification
This is clear and obvious bloat. My only recommendation at all for this is see if the Growl developers are interested in adding a twitter module.
Re: Twitter Notification
I will burn the code to the ground and salt the earth before this feature is added into Transmission's core.vgbnd wrote:helo.
thanks for transmission. wonderful app.
would be great if you could integrate Twitter Support. Transmission could send a Direct Message to a preconf Twitter account when a download has finished. should be not to hard to integrate via the Twitter API.
That said, it would be very easy -- literally, maybe 20-30 lines -- for someone to write a Python script to use JSON/RPC to sniff out completed torrents on a Transmission session, and submit them to Twitter.
-
- Posts: 1
- Joined: Wed May 06, 2009 3:14 am
Re: Twitter Notification
Here's a simple proof-of-concept that could be run as a cron job every five minutes (it will direct message a specified user with the torrent name and "is done" for each torrent that has completed in the past five minutes:
import http.client, json, base64, time
from datetime import datetime, timedelta
server = http.client.HTTPConnection('localhost:9091')
twitterserver = http.client.HTTPConnection('twitter.com')
basic_auth = base64.b64encode(b'USERNAME:PASSWORD') #Replace USERNAME and PASSWORD with the account name and password to use to send the message from.
requestheader = {'Authorization':'Basic ' + bytes.decode(basic_auth)}
o = json.dumps({ 'arguments': {'fields': ['id','name','doneDate']},'method': 'torrent-get'},sort_keys=False, indent=4)
server.request("POST","/transmission/rpc/",o)
rawdata=server.getresponse().read().decode()
data=json.loads(rawdata)
darray = [{'id':x['id'], 'date':datetime.fromtimestamp(x['doneDate'])} for x in data['arguments']['torrents']]
curr = [x for x in darray if datetime.now() - x['date'] < timedelta(minutes=5)]
def dmself(mess):
print(mess)
twitterserver.request("POST","/direct_messages/new.json","user=TARGETUSERNAME&text="+mess,requestheader) #Replace TARGETUSERNAME with the account name to send the message to
twitterserver.getresponse()
if len(curr) > 0:
[dmself([y for y in data['arguments']['torrents'] if y['id'] == x['id']][0]['name'] + " is done.") for x in curr]
import http.client, json, base64, time
from datetime import datetime, timedelta
server = http.client.HTTPConnection('localhost:9091')
twitterserver = http.client.HTTPConnection('twitter.com')
basic_auth = base64.b64encode(b'USERNAME:PASSWORD') #Replace USERNAME and PASSWORD with the account name and password to use to send the message from.
requestheader = {'Authorization':'Basic ' + bytes.decode(basic_auth)}
o = json.dumps({ 'arguments': {'fields': ['id','name','doneDate']},'method': 'torrent-get'},sort_keys=False, indent=4)
server.request("POST","/transmission/rpc/",o)
rawdata=server.getresponse().read().decode()
data=json.loads(rawdata)
darray = [{'id':x['id'], 'date':datetime.fromtimestamp(x['doneDate'])} for x in data['arguments']['torrents']]
curr = [x for x in darray if datetime.now() - x['date'] < timedelta(minutes=5)]
def dmself(mess):
print(mess)
twitterserver.request("POST","/direct_messages/new.json","user=TARGETUSERNAME&text="+mess,requestheader) #Replace TARGETUSERNAME with the account name to send the message to
twitterserver.getresponse()
if len(curr) > 0:
[dmself([y for y in data['arguments']['torrents'] if y['id'] == x['id']][0]['name'] + " is done.") for x in curr]