Skip to content

Commit

Permalink
added tracker servers lists via &tr param
Browse files Browse the repository at this point in the history
  • Loading branch information
Lifailon authored Jun 3, 2024
1 parent 6f6e843 commit 8f64b85
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 19 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,17 @@ magnet:?xt=urn:btih:7395A859E8E590418F422E7D0DFE68860DE90631
```

the operating system will redirect you to the default torrent client.

---

The `&tr` parameter adds a list of torrent tracker servers to the magnet link:

```
https://lifailon.github.io/magnet2url#7395a859e8e590418f422e7d0dfe68860de90631&tr
```

redirect to

```
magnet:?xt=urn:btih:7395A859E8E590418F422E7D0DFE68860DE90631&tr=wss://tracker.btorrent.xyz&tr=wss://tracker.openwebtorrent.com&tr=udp://tracker.btorrent.xyz:80&tr=udp://tracker.openwebtorrent.com:80&tr=udp://tracker.openwebtorrent.com:1337&tr=udp://retracker.local:80&tr=udp://tr0.torrent4me.com:80&tr=udp://tr1.torrent4me.com:80&tr=udp://tr2.torrent4me.com:80&tr=udp://tr3.torrent4me.com:80&tr=udp://tr4.torrent4me.com:80&tr=udp://tr0.tor4me.info:80&tr=udp://tr1.tor4me.info:80&tr=udp://tr2.tor4me.info:80&tr=udp://tr3.tor4me.info:80&tr=udp://tr4.tor4me.info:80&tr=udp://tr0.tor2me.info:80&tr=udp://tr1.tor2me.info:80&tr=udp://tr2.tor2me.info:80&tr=udp://tr3.tor2me.info:80&tr=udp://tr4.tor2me.info:80
```
61 changes: 42 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,62 @@
<html>
<head>
<title>magnet2url</title>
<!--
<meta http-equiv="refresh" content="0;url=magnet:?xt=urn:btih:ACED2A5FF8B266EF40B76BFCF6B9E76BF19BFD9F">
-->
<script>
window.onload = function() {
var hashValue = window.location.hash.substr(1)
function magnetRedirec() {
var messageElement = document.getElementById("message")
var hashValue = window.location.hash.substr(1)
if (hashValue) {
if (hashValue.startsWith("magnet:?xt=urn:btih:")) {
window.location.href = hashValue
}
else {
window.location.href = "magnet:?xt=urn:btih:" + hashValue
var magnet = "magnet:?xt=urn:btih:" + hashValue
if (magnet.includes("&tr")) {
window.location.href = addTracker(magnet.split('&tr')[0])
}
else {
window.location.href = magnet
}
}
}
else {
messageElement.innerHTML = "For redirect to the default torrent client, pass the info hash or magnet link in the address bar after the # symbol"
}
}
window.onhashchange = function() {
var hashValue = window.location.hash.substr(1)
var messageElement = document.getElementById("message")
if (hashValue) {
if (hashValue.startsWith("magnet:?xt=urn:btih:")) {
window.location.href = hashValue
}
else {
window.location.href = "magnet:?xt=urn:btih:" + hashValue
}
}
else {
messageElement.innerHTML = "For redirect to the default torrent client, pass the info hash or magnet link in the address bar after the # symbol"
function addTracker(infoHash) {
var trackers = [
"wss://tracker.btorrent.xyz",
"wss://tracker.openwebtorrent.com",
"udp://tracker.btorrent.xyz:80",
"udp://tracker.openwebtorrent.com:80",
"udp://tracker.openwebtorrent.com:1337",
"udp://retracker.local:80",
"udp://tr0.torrent4me.com:80",
"udp://tr1.torrent4me.com:80",
"udp://tr2.torrent4me.com:80",
"udp://tr3.torrent4me.com:80",
"udp://tr4.torrent4me.com:80",
"udp://tr0.tor4me.info:80",
"udp://tr1.tor4me.info:80",
"udp://tr2.tor4me.info:80",
"udp://tr3.tor4me.info:80",
"udp://tr4.tor4me.info:80",
"udp://tr0.tor2me.info:80",
"udp://tr1.tor2me.info:80",
"udp://tr2.tor2me.info:80",
"udp://tr3.tor2me.info:80",
"udp://tr4.tor2me.info:80"
]
for (var i = 0; i < trackers.length; i++) {
infoHash += "&tr=" + encodeURIComponent(trackers[i])
}
return infoHash
}
window.onload = function() {
magnetRedirec()
}
window.onhashchange = function() {
magnetRedirec()
}
</script>
</head>
Expand Down

0 comments on commit 8f64b85

Please sign in to comment.