Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/billiegoose/download-with-webtorrent-button

Transform ordinary download links into super-powered WebTorrent ones!
https://github.com/billiegoose/download-with-webtorrent-button

Last synced: about 1 month ago
JSON representation

Transform ordinary download links into super-powered WebTorrent ones!

Awesome Lists containing this project

README

        

# download-with-webtorrent-button
Transform ordinary download links into super-powered WebTorrent ones!

## Example

Check out the demo page: https://wmhilton.github.io/download-with-webtorrent-button

[![screenshot of WebTorrent button](https://github.com/wmhilton/download-with-webtorrent-button/blob/master/dist/animated.gif?raw=true)](https://wmhilton.github.io/download-with-webtorrent-button)

Sponsor

## Rationale

Do you have a big, popular file that lots of people download and the Internet
would grind to a halt if your website went down?
It is EASY to spread the burden of hosting a file among all the people who are
downloading it. Bittorrent (despite its association with piracy) is a fabulous
network protocol that does exactly that. It use to be that you needed to install
separate software to use Bittorrent, but with the advent of
[WebTorrent](https://webtorrent.io) it is now possible to use the Bittorrent
protocol seamlessly in the browser without visitors ever having to leave your site!

Despite how FREAKING AWESOME WebTorrent is, not enough sites are taking advantage
of it. To make taking advantage of WebTorrent as easy and
accessible as possible, I decided to make a "Download with WebTorrent" button
that turns your ordinary download link into a super-powered WebTorrent download
link! All you have to do is paste a small code snippet in your HTML.

## Installation using a CDN

Add the following stylesheet to ``:

```html

```

And the following scripts to the bottom of ``:

```html

```

This adds a single function `registerWebtorrentLinks()` to the global scope.
It automatically initializes `a` tags. If you add additional `a` tags after the
initial page load (such as in the case of single page apps) you can rerun registerWebtorrentLinks().

If you want to override the CSS styles, take a look at `index.css`.

## Installation using a module bundler?

Somebody should fork this and make it a React component. Pull requests welcome!

## Usage

### The easiest way

To add a **Download with WebTorrent** button to your page, use a regular `` link.
The link's `href` attribute will be provided as a fallback on browsers that can't run WebTorrent,
or if an error occurs. Then add a `data-webtorrent` attribute.

You can use `data-webtorrent="auto"` and these
[fabulous](https://github.com/wmhilton/webtorrentify-link)
[free](https://github.com/wmhilton/webtorrentify-server)
[services](https://github.com/wmhilton/cors-buster)
will auto-generate a WebTorrent-compatible .torrent file for your link.

```html
Link Text
```

### Bring your own torrent

If you already have a magnet URI, you can use that,

```html
Link Text
```

or the location of a .torrent file,

```html
Link Text
```

but know that WebTorrent is not yet compatible with the DHT and requires `ws` or `http` trackers. If your .torrent only includes `udp` trackers or is tracker-less and relies on the DHT, you are better off using `data-webtorrent="auto"`.

If your torrent is a folder torrent rather than a single file, add a `data-file` attribute with the name of the individual file you intend the link for.

```html
Sintel
```

## License

Copyright 2017 William Hilton.
Licensed under [The Unlicense](http://unlicense.org/).