From b4c0ad9e843ec0af72dbb5e720801694e78952a1 Mon Sep 17 00:00:00 2001 From: TheAMM Date: Sat, 4 Nov 2017 23:46:50 +0200 Subject: [PATCH] torrents.py: Add link to torrent page into .torrent comment metadata --- nyaa/views/torrents.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nyaa/views/torrents.py b/nyaa/views/torrents.py index ebba437..f3e53eb 100644 --- a/nyaa/views/torrents.py +++ b/nyaa/views/torrents.py @@ -447,6 +447,12 @@ def _get_cached_torrent_file(torrent): 'torrent_cache', str(torrent.id) + '.torrent') if not os.path.exists(cached_torrent): with open(cached_torrent, 'wb') as out_file: - out_file.write(torrents.create_bencoded_torrent(torrent)) + metadata_base = torrents.create_default_metadata_base(torrent) + # Replace the default comment with url to the torrent page + metadata_base['comment'] = flask.url_for('torrents.view', + torrent_id=torrent.id, + _external=True) + + out_file.write(torrents.create_bencoded_torrent(torrent, metadata_base)) return open(cached_torrent, 'rb'), os.path.getsize(cached_torrent)