From a732d3cebcb8ff3170502b13d01ba90ac8efe26f Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 21 Nov 2012 00:54:20 -0500 Subject: Fix new magnet link generation Apparently clients don't like urlencoded values in the magnet link, so %3A isn't treated the same as ':'. Signed-off-by: Dan McGee --- releng/models.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'releng') diff --git a/releng/models.py b/releng/models.py index b3ab1a3..a22e01d 100644 --- a/releng/models.py +++ b/releng/models.py @@ -1,5 +1,4 @@ import markdown -from urllib import urlencode from django.core.urlresolvers import reverse from django.db import models @@ -132,14 +131,14 @@ class Release(models.Model): return "iso/%s/archlinux-%s-dual.iso" % (self.version, self.version) def magnet_uri(self): - query = { - 'dn': "archlinux-%s-dual.iso" % self.version, - 'tr': ("udp://tracker.archlinux.org:6969", - "http://tracker.archlinux.org:6969/announce"), - } + query = [ + ('dn', "archlinux-%s-dual.iso" % self.version), + ('tr', "udp://tracker.archlinux.org:6969"), + ('tr', "http://tracker.archlinux.org:6969/announce"), + ] if self.torrent_infohash: - query['xt'] = "urn:btih:%s" % self.torrent_infohash - return "magnet:?%s" % urlencode(query, doseq=True) + query.insert(0, ('xt', "urn:btih:%s" % self.torrent_infohash)) + return "magnet:?%s" % '&'.join(['%s=%s' % (k, v) for k, v in query]) def info_html(self): return mark_safe(markdown.markdown( -- cgit v1.2.3-24-g4f1b