1 <!-- This tool generates a BitTorrent Magnet Link based on a given hash value and optionally a custom resource name.
2 You can also provide the "hash" and "name" parameters as URL GET parameters,
3 and they will be automatically filled into the form.
5 Customize the trackers by editing the list below.
6 These will be included in the generated magnet link to ensure better availability and downloading speed.
8 Made with ♥ by Andrea Draghetti
10 This file may be licensed under the terms of of the GNU General Public License Version 3 (the ``GPL''). -->
15 <meta charset=
"utf-8">
16 <meta name=
"viewport" content=
"width=device-width, initial-scale=1.0">
17 <title>Magnet Link Generator - Generate Custom Magnet Links for BitTorrent
</title>
19 <!-- Meta tags for SEO -->
20 <meta name=
"description" content=
"Generate custom torrent magnet links quickly and easily. Enter an info hash and torrent name to create a personalized magnet link with the latest trackers for optimal download speed.">
21 <meta name=
"keywords" content=
"Torrent Magnet Link Generator, BitTorrent Magnet Link, Custom Magnet Link, Torrent Hash Generator, Online Magnet Link Creator, BitTorrent Tracker, Torrent Generator">
22 <meta name=
"author" content=
"Andrea Draghetti">
23 <meta name=
"viewport" content=
"width=device-width, initial-scale=1.0">
25 <!-- Open Graph / Facebook -->
26 <meta property=
"og:type" content=
"website">
27 <meta property=
"og:url" content=
"https://magnet.draghetti.it">
28 <meta property=
"og:title" content=
"Torrent Magnet Link Generator - Generate Custom Magnet Links for BitTorrent">
29 <meta property=
"og:description" content=
"Easily create a custom BitTorrent magnet link by providing an info hash and torrent name. Automatically includes top trackers for better download performance.">
30 <meta property=
"og:image" content=
"https://magnet.draghetti.it/images/magnet-link-generator-thumbnail.png">
33 <meta property=
"twitter:card" content=
"summary_large_image">
34 <meta property=
"twitter:url" content=
"https://magnet.draghetti.it">
35 <meta property=
"twitter:title" content=
"Torrent Magnet Link Generator - Generate Custom Magnet Links for BitTorrent">
36 <meta property=
"twitter:description" content=
"Easily create a custom BitTorrent magnet link by providing an info hash and torrent name. Includes top trackers for faster downloads.">
37 <meta property=
"twitter:image" content=
"https://magnet.draghetti.it/images/magnet-link-generator-thumbnail.png">
40 <link rel=
"apple-touch-icon" sizes=
"180x180" href=
"https://magnet.draghetti.it/apple-touch-icon.png">
41 <link rel=
"icon" type=
"image/png" sizes=
"32x32" href=
"https://magnet.draghetti.it/favicon-32x32.png">
42 <link rel=
"icon" type=
"image/png" sizes=
"16x16" href=
"https://magnet.draghetti.it/favicon-16x16.png">
43 <link rel=
"manifest" href=
"https://magnet.draghetti.it/site.webmanifest">
45 <!-- Bootstrap CSS (version 5.3.3) with integrity check -->
46 <link rel=
"stylesheet" href=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" integrity=
"sha512-jnSuA4Ss2PkkikSOLtYs8BlYIeeIK1h99ty4YfvRPAlzr377vr3CXDb7sb7eEEBYjDtcYj+AjBH3FLv5uSJuXg==" crossorigin=
"anonymous" referrerpolicy=
"no-referrer" />
49 <body class=
"d-flex flex-column align-items-center bg-light min-vh-100">
51 <div class=
"container bg-white shadow rounded p-4 mt-5">
53 <div class=
"text-center mb-4">
54 <h1 class=
"h4 fw-bold">BitTorrent Magnet Link Generator
</h1>
57 <!-- Information section -->
58 <div class=
"text-secondary mb-4">
59 <p>This tool generates a BitTorrent Magnet Link based on a given hash value and optionally a custom resource name. You can also provide the
"hash" and
"name" parameters as URL GET parameters, and they will be automatically filled into the form.
</p>
60 <p>Customize the trackers by editing the list below. These will be included in the generated magnet link to ensure better availability and downloading speed.
</p>
63 <form name=
"form" onsubmit=
"update(); return false;">
64 <!-- Info hash input field -->
66 <label for=
"hash" class=
"form-label">Info Hash
<small>(Mandatory)
</small></label>
67 <input id=
"hash" type=
"text" class=
"form-control" placeholder=
"Enter the info hash" required
>
70 <!-- Torrent name input field -->
72 <label for=
"name" class=
"form-label">Resource Name
<small>(Optional)
</small></label>
73 <input id=
"name" type=
"text" class=
"form-control" placeholder=
"Enter the resource name">
76 <!-- Generate button -->
77 <button type=
"submit" class=
"btn btn-primary w-100">Generate
</button>
79 <!-- Generated Magnet Link display section -->
81 <a href=
"magnet:" id=
"link" class=
"text-primary fw-bold">Magnet Link
</a>:
82 <input id=
"link_text" type=
"text" class=
"form-control mt-2" readonly
>
85 <!-- Trackers list for customization -->
86 <div class=
"mb-3 mt-3">
87 <label for=
"trackers" class=
"form-label">Trackers to include in the magnet link:
</label>
88 <textarea id=
"trackers" class=
"form-control" rows=
"6">http://tracker.opentrackr.org:
1337/announce
89 udp://tracker.torrent.eu.org:
451/announce
</textarea>
90 <small class=
"form-text text-muted">These trackers are sourced from the
<a href=
"https://github.com/ngosang/trackerslist" target=
"_blank">TrackersList project
</a>.
</small>
95 <!-- Footer with credit -->
96 <footer class=
"text-center mt-auto py-3 text-muted">
97 BitTorrent Magnet Link Generator made with ♥ by
<a href=
"https://www.andreadraghetti.it/" target=
"_blank">Andrea Draghetti
</a>.
100 <!-- Bootstrap JS and dependencies (version 5.3.3) with integrity check -->
101 <script src=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.bundle.min.js" integrity=
"sha512-7Pi/otdlbbCR+LnW+F7PwFcSDJOuUJB3OxtEHbg4vSMvzvJjde4Po1v4BR9Gdc9aXNUNFVUY+SK51wWT8WF0Gg==" crossorigin=
"anonymous" referrerpolicy=
"no-referrer"></script>
104 <script type=
"text/javascript">
105 /* Function to retrieve URL GET parameters */
106 function getUrlParameter(name) {
107 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
108 var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
109 var results = regex.exec(location.search);
110 return results === null ? '' : decodeURIComponent(results[
1].replace(/\+/g, ' ')).trim();
113 /* Function to auto-fill form fields if GET parameters are provided */
114 async function autoFillForm() {
115 var hashValue = getUrlParameter('hash');
116 var nameValue = getUrlParameter('name');
119 document.getElementById(
"hash").value = hashValue.trim();
122 document.getElementById(
"name").value = nameValue.trim();
125 // Wait for trackers to load before generating the link
126 await loadTrackers();
128 // Execute update only if hash is provided
134 /* Function to generate the magnet link */
137 var hashInput = document.getElementById(
"hash").value.trim().toUpperCase(); // Convert to uppercase
138 var nameInput = document.getElementById(
"name").value.trim();
140 // Set `name` to `hash` if it is empty
141 if (hashInput && !nameInput) {
142 document.getElementById(
"name").value = hashInput;
143 nameInput = hashInput; // Update variable
146 // Generate the magnet link
148 var trackers = document.getElementById(
"trackers").value.match(/[^\s\|]+:\/\/[^\s\|]+/g);
149 var data =
"magnet:" +
"?xt=urn:btih:" + hashInput;
151 data +=
"&dn=" + encodeURIComponent(nameInput);
153 for (var t in trackers) {
154 data +=
"&tr=" + encodeURIComponent(trackers[t]);
157 document.getElementById(
"link").href = data;
158 document.getElementById(
"link_text").value = data;
160 // Clear the link_text field if hash is not present
161 document.getElementById(
"link_text").value = '';
164 alert(
"exception: " + e);
168 /* Automatically fill the form on page load if GET parameters are present */
169 window.onload = autoFillForm;
172 <script type=
"text/javascript">
173 // Function to load trackers from the external URL
174 async function loadTrackers() {
175 const url =
"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt";
178 const response = await fetch(url);
181 // Get the trackers list as text
182 let trackersList = await response.text();
184 // Remove empty lines
185 trackersList = trackersList
186 .split('\n') // Split into an array of lines
187 .filter(line =
> line.trim() !== '') // Remove empty lines
188 .join('\n'); // Rejoin into a single string
190 document.getElementById(
"trackers").value = trackersList;
192 console.error(
"Failed to load trackers: " + response.status);
195 console.error(
"Error fetching trackers: ", error);
199 // Load trackers on page load
200 window.onload = function() {
201 autoFillForm(); // Existing function to autofill form fields if URL parameters are provided
202 loadTrackers(); // Load trackers from the external source