1 <!-- 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.
3 Customize the trackers by editing the list below. These will be included in the generated magnet link to ensure better availability and downloading speed.
5 Made with ♥ by Andrea Draghetti
7 This file may be licensed under the terms of of the GNU General Public License Version 3 (the ``GPL''). -->
12 <meta charset=
"utf-8">
13 <meta name=
"viewport" content=
"width=device-width, initial-scale=1.0">
14 <title>Magnet Link Generator - Generate Custom Magnet Links for BitTorrent
</title>
16 <!-- Meta tags for SEO -->
17 <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.">
18 <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">
19 <meta name=
"author" content=
"Andrea Draghetti">
20 <meta name=
"viewport" content=
"width=device-width, initial-scale=1.0">
22 <!-- Open Graph / Facebook -->
23 <meta property=
"og:type" content=
"website">
24 <meta property=
"og:url" content=
"https://magnet.draghetti.it">
25 <meta property=
"og:title" content=
"Torrent Magnet Link Generator - Generate Custom Magnet Links for BitTorrent">
26 <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.">
27 <meta property=
"og:image" content=
"https://magnet.draghetti.it/images/magnet-link-generator-thumbnail.png">
30 <meta property=
"twitter:card" content=
"summary_large_image">
31 <meta property=
"twitter:url" content=
"https://magnet.draghetti.it">
32 <meta property=
"twitter:title" content=
"Torrent Magnet Link Generator - Generate Custom Magnet Links for BitTorrent">
33 <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.">
34 <meta property=
"twitter:image" content=
"https://magnet.draghetti.it/images/magnet-link-generator-thumbnail.png">
37 <link rel=
"apple-touch-icon" sizes=
"180x180" href=
"https://magnet.draghetti.it/apple-touch-icon.png">
38 <link rel=
"icon" type=
"image/png" sizes=
"32x32" href=
"https://magnet.draghetti.it/favicon-32x32.png">
39 <link rel=
"icon" type=
"image/png" sizes=
"16x16" href=
"https://magnet.draghetti.it/favicon-16x16.png">
40 <link rel=
"manifest" href=
"https://magnet.draghetti.it/site.webmanifest">
42 <!-- Bootstrap CSS (version 5.3.3) with integrity check -->
43 <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" />
46 <body class=
"d-flex flex-column align-items-center bg-light min-vh-100">
48 <div class=
"container bg-white shadow rounded p-4 mt-5">
50 <div class=
"text-center mb-4">
51 <h1 class=
"h4 fw-bold">BitTorrent Magnet Link Generator
</h1>
54 <!-- Information section -->
55 <div class=
"text-secondary mb-4">
56 <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>
57 <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>
60 <form name=
"form" onsubmit=
"update(); return false;">
61 <!-- Info hash input field -->
63 <label for=
"hash" class=
"form-label">Info Hash
<small>(Mandatory)
</small></label>
64 <input id=
"hash" type=
"text" class=
"form-control" placeholder=
"Enter the info hash" required
>
67 <!-- Torrent name input field -->
69 <label for=
"name" class=
"form-label">Resource Name
<small>(Optional)
</small></label>
70 <input id=
"name" type=
"text" class=
"form-control" placeholder=
"Enter the resource name">
73 <!-- Generate button -->
74 <button type=
"submit" class=
"btn btn-primary w-100">Generate
</button>
76 <!-- Generated Magnet Link display section -->
78 <a href=
"magnet:" id=
"link" class=
"text-primary fw-bold">Magnet Link
</a>:
79 <input id=
"link_text" type=
"text" class=
"form-control mt-2" readonly
>
82 <!-- Trackers list for customization -->
83 <div class=
"mb-3 mt-3">
84 <label for=
"trackers" class=
"form-label">Trackers to include in the magnet link:
</label>
85 <textarea id=
"trackers" class=
"form-control" rows=
"6">http://tracker.opentrackr.org:
1337/announce
86 udp://tracker.torrent.eu.org:
451/announce
</textarea>
87 <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>
92 <!-- Footer with credit -->
93 <footer class=
"text-center mt-auto py-3 text-muted">
94 BitTorrent Magnet Link Generator made with ♥ by
<a href=
"https://www.andreadraghetti.it/" target=
"_blank">Andrea Draghetti
</a>.
97 <!-- Bootstrap JS and dependencies (version 5.3.3) with integrity check -->
98 <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>
101 <script type=
"text/javascript">
102 /* Function to retrieve URL GET parameters */
103 function getUrlParameter(name) {
104 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
105 var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
106 var results = regex.exec(location.search);
107 return results === null ? '' : decodeURIComponent(results[
1].replace(/\+/g, ' ')).trim();
110 /* Function to auto-fill form fields if GET parameters are provided */
111 async function autoFillForm() {
112 var hashValue = getUrlParameter('hash');
113 var nameValue = getUrlParameter('name');
116 document.getElementById(
"hash").value = hashValue.trim();
119 document.getElementById(
"name").value = nameValue.trim();
122 // Wait for trackers to load before generating the link
123 await loadTrackers();
125 // Execute update only if hash is provided
131 /* Function to generate the magnet link */
134 var hashInput = document.getElementById(
"hash").value.trim().toUpperCase(); // Convert to uppercase
135 var nameInput = document.getElementById(
"name").value.trim();
137 // Set `name` to `hash` if it is empty
138 if (hashInput && !nameInput) {
139 document.getElementById(
"name").value = hashInput;
140 nameInput = hashInput; // Update variable
143 // Generate the magnet link
145 var trackers = document.getElementById(
"trackers").value.match(/[^\s\|]+:\/\/[^\s\|]+/g);
146 var data =
"magnet:" +
"?xt=urn:btih:" + hashInput;
148 data +=
"&dn=" + encodeURIComponent(nameInput);
150 for (var t in trackers) {
151 data +=
"&tr=" + encodeURIComponent(trackers[t]);
154 document.getElementById(
"link").href = data;
155 document.getElementById(
"link_text").value = data;
157 // Clear the link_text field if hash is not present
158 document.getElementById(
"link_text").value = '';
161 alert(
"exception: " + e);
165 /* Automatically fill the form on page load if GET parameters are present */
166 window.onload = autoFillForm;
169 <script type=
"text/javascript">
170 // Function to load trackers from the external URL
171 async function loadTrackers() {
172 const url =
"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt";
175 const response = await fetch(url);
178 // Get the trackers list as text
179 let trackersList = await response.text();
181 // Remove empty lines
182 trackersList = trackersList
183 .split('\n') // Split into an array of lines
184 .filter(line =
> line.trim() !== '') // Remove empty lines
185 .join('\n'); // Rejoin into a single string
187 document.getElementById(
"trackers").value = trackersList;
189 console.error(
"Failed to load trackers: " + response.status);
192 console.error(
"Error fetching trackers: ", error);
196 // Load trackers on page load
197 window.onload = function() {
198 autoFillForm(); // Existing function to autofill form fields if URL parameters are provided
199 loadTrackers(); // Load trackers from the external source