config:transmission
This is an old revision of the document!
Transmission
Firefox addon to add magnet/torrent links to transmission web server:
https://addons.mozilla.org/en-GB/firefox/addon/transmitter-for-transmission/?src=search
https://addons.mozilla.org/en-GB/firefox/addon/magnet-link-to-transmission/
https://forum.transmissionbt.com/viewtopic.php?p=67122#p67122
Python script for adding magnet links:
#!/usr/bin/python3
#
# Simple magnet link uploader
#
# Needs httplib2: http://code.google.com/p/httplib2/
#
import httplib2
from sys import argv, exit
from json import dumps
# is magnet link given in command line?
if len(argv) < 2:
print('Usage: magnet-handler.py "magnet link"')
exit(1)
# Replace hostname, transmission-username and transmission-password
url = 'http://hostname:9091/transmission/rpc'
username = 'transmission-username'
password = 'transmission-password'
h = httplib2.Http(".cache")
h.add_credentials(username, password)
resp, content = h.request(url, "GET")
headers = { "X-Transmission-Session-Id": resp['x-transmission-session-id'] }
body = dumps( { "method": "torrent-add",
"arguments": { "filename": argv[1] } } )
response, content = h.request(url, 'POST', headers=headers, body=body)
if str(content).find("success") == -1:
print("Magnet Link: " + argv[1])
print("Answer: " + content)
print("No 'success' here!")
print("Press Enter to Exit.")
input()
Python script for adding magnet links with notification (windows):
#!/usr/bin/python3
#
# Transmission magnet link uploader
# (https cert check disabled)
#
# Uses requests & PyQt5
# http://docs.python-requests.org/en/latest/
# http://www.riverbankcomputing.co.uk/software/pyqt/download5
#
# Standard
from json import dumps
from sys import argv, exit
from urllib.parse import unquote
# 3rd Party
import requests
from PyQt5.QtCore import QTimer
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import (QApplication, QMessageBox, QSystemTrayIcon)
# Settings
url = 'https://address.domain:port/transmission/rpc'
username = 'transmission'
password = 'secret'
icon = 'C:\\Icons\\Magnet-icon.png'
# Functions
# Show Message Box
def show_message(title, message):
app = QApplication([])
QMessageBox.information(None, title, message)
# Show Tray Message
def show_tray_message(title, message):
app = QApplication([])
trayIcon = QSystemTrayIcon(QIcon(icon), app)
trayIcon.show()
trayIcon.showMessage(title, message, QSystemTrayIcon.Information)
QTimer.singleShot(8000, app.quit)
app.exec_()
# Get RPC Session ID
def get_session_id():
sessionid_request = requests.get(url, auth=(username, password), verify=False)
return sessionid_request.headers['x-transmission-session-id']
# Post Magnet Link
def post_link(magnetlink):
sessionid = get_session_id()
if sessionid:
headers = {"X-Transmission-Session-Id": sessionid}
body = dumps({"method": "torrent-add", "arguments": {"filename": magnetlink}})
post_request = requests.post(url, data=body, headers=headers, auth=(username, password), verify=False)
if str(post_request.text).find("success") == -1:
title = argv[0] + ' - Error'
message = 'Magnet Link: ' + magnetlink + '\nAnswer: ' + post_request.text
show_message(title, message)
else:
message = '\n'.join(names) + '\n' + '\n'.join(trackers)
show_tray_message('Magnet Link Added', message)
# End of Functions
# Main prog
if __name__ == '__main__':
# Check Argument and Extract Name/Trackers or Display Alert Message
if len(argv) < 2:
show_message(argv[0] + ' - Alert', 'Usage: ' + argv[0] + ' [magnet link]')
exit(1)
elif argv[1].startswith('magnet'):
names = []
trackers = []
for item in argv[1].split('&'):
decoded = unquote(item)
if decoded.startswith('dn='):
names.append(decoded.replace('dn=', ''))
if decoded.startswith('tr='):
trackers.append(decoded.replace('tr=', ''))
else:
show_message(argv[0] + ' - Alert', argv[1] + ' not magnet link!')
exit(1)
post_link(argv[1])
config/transmission.1597595745.txt.gz · Last modified: (external edit)