Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

57 lines (44 sloc) 1.84 kB
# Author: Geoffrey Huntley <>
from flask import Flask, jsonify, render_template
import transmissionrpc
from datetime import timedelta
from Maraschino import app
from import *
def xhr_transmission():
# initialize empty list, which will be later populated with listing
# of active torrents [of transmissionrpc.Client().info()]
transmission = list()
# initialize empty datetime, which will be later incremented
# to hold the total time remaining for all active downloads
eta = timedelta()
# transmissionrpc connection params
params = {
'address' : get_setting_value('transmission_ip'),
'port' : get_setting_value('transmission_port'),
'user' : get_setting_value('transmission_user') or None,
'password' : get_setting_value('transmission_password') or None
client = transmissionrpc.Client(**params)
# return list of running jobs:
# {1: <Torrent 1 "Hello">, 2: <Torrent 2 "World">}
torrents = client.list()
# loop through each job, add any active (downloading) torrents to the transmission list()
for i in torrents:
torrent =[i]
if torrent.status == 'downloading':
# take the ETA for the current torrent, add it to the total ETA remaining
eta = eta + torrent.eta
# unset transmission, if there are no torrents currently being downloaded/seeded
if not transmission.__len__():
transmission = None
transmission = None
return render_template('transmission.html',
transmission = transmission,
eta = eta
Jump to Line
Something went wrong with that request. Please try again.