aboutsummaryrefslogtreecommitdiff
path: root/torrent.html
blob: 17e24ffe06aaa0455bda32f43852e13acec6b1e0 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="/styles.css" />
    <title>WebTorrent player - EuAndreh</title>
    <script src="/vendor/webtorrent/webtorrent.min.js"></script>
  </head>
  <body>
    <div id="output"></div>
    <div id="torrentLink"></div>
    <script>
      const params = new URLSearchParams(window.location.search);
      const torrentID = params.get("torrent"); // "https://webtorrent.io/torrents/sintel.torrent";
      document.querySelector("#torrentLink").innerHTML = `Downloading <a href=${torrentID}>${torrentID}</a>`;

      const client = new WebTorrent();
      client.add(torrentID, torrent =>
        torrent.files.forEach(file => file.appendTo("#output")));
    </script>
    <noscript>
      This page uses JavaScript for downloading with <a href="https://webtorrent.io/">WebTorrent</a>.

      <br />

      To view the content either enable JavaScript or download the torrent file directly (link in the URL).
    </noscript>
  </body>
</html>