From 2bf96196cb860526f0c90462eca77db7f3c68ba1 Mon Sep 17 00:00:00 2001 From: TheAMM Date: Sun, 15 Jul 2018 04:26:26 +0300 Subject: [PATCH] torrents: Clean up magnet URI quotation A cosmetic change. Swapping quote_via to quote, we don't convert spaces to pluses, keeping the name intact (which only mattered until peers send the metadata). --- nyaa/torrents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nyaa/torrents.py b/nyaa/torrents.py index 0b91489..42d5ce4 100644 --- a/nyaa/torrents.py +++ b/nyaa/torrents.py @@ -1,6 +1,6 @@ import base64 import os -from urllib.parse import urlencode +from urllib.parse import urlencode, quote import flask from flask import current_app as app @@ -88,7 +88,7 @@ def create_magnet(torrent, max_trackers=5, trackers=None): magnet_parts.append(('tr', tracker)) b32_info_hash = base64.b32encode(torrent.info_hash).decode('utf-8') - return 'magnet:?xt=urn:btih:' + b32_info_hash + '&' + urlencode(magnet_parts) + return 'magnet:?xt=urn:btih:' + b32_info_hash + '&' + urlencode(magnet_parts, quote_via=quote) def create_default_metadata_base(torrent, trackers=None, webseeds=None):