How to use the magnet-uri.decode function in magnet-uri

To help you get started, we’ve selected a few magnet-uri examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / magnet-uri / magnet-uri-tests.ts View on Github external
import * as magnet from 'magnet-uri';

// "Leaves of Grass" by Walt Whitman
// tslint:disable-next-line:max-line-length
const uri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337';

const parsed = magnet.decode(uri);
console.log(parsed);
console.log(magnet.encode(parsed));
github Stremio / addon-helloworld / addon.js View on Github external
function fromMagnet(name, type, uri) {
    const parsed = magnet.decode(uri);
    const infoHash = parsed.infoHash.toLowerCase();
    const tags = [];
    if (uri.match(/720p/i)) tags.push("720p");
    if (uri.match(/1080p/i)) tags.push("1080p");
    return {
        name: name,
        type: type,
        infoHash: infoHash,
        sources: (parsed.announce || []).map(function(x) { return "tracker:"+x }).concat(["dht:"+infoHash]),
        tag: tags,
        title: tags[0], // show quality in the UI
    }
}
github Mrigank11 / embetacloud / server / server.js View on Github external
var dupes = Object.keys(torrents).filter(function (key) {
            return magnet.decode(data.magnet).infoHash == torrents[key].infoHash;
        });
        if (dupes.length > 0) {
github Mrigank11 / embetacloud / server / server.ts View on Github external
var dupes = Object.keys(torrents).filter((key) => {
            return magnet.decode(data.magnet).infoHash == torrents[key].infoHash;
        });
        if (dupes.length > 0) {
github havfo / multiparty-meeting / app / src / components / MeetingDrawer / FileSharing / File.js View on Github external
}}
									>
										Save
									
								
							))}
						
					}
					
						{ `${displayName} shared a file` }
					

					{ (!file.active && !file.files) &&
						<div>
							
								{ magnet.decode(magnetUri).dn }
							
							{ canShareFiles ?
								<button>
									{
										roomClient.handleDownload(magnetUri);
									}}
								&gt;
									Download
								</button>
								:
								
									Your browser does not support downloading files using WebTorrent.</div>
github havfo / multiparty-meeting / app / lib / components / FileSharing / FileEntry.jsx View on Github external
<p>{this.props.data.name} shared a file.</p>
					)}

					{!this.state.active &amp;&amp; !this.state.files &amp;&amp; (
						<div>
							{WebTorrent.WEBRTC_SUPPORT ? (
								<span>
									<img src="resources/images/download-icon.svg">
								</span>
							) : (
								<p>
									Your browser does not support downloading files using WebTorrent.
								</p>
							)}

							<p>{magnet.decode(this.props.data.file.magnet).dn}</p>
						</div>
					)}

					{this.state.active &amp;&amp; this.state.numPeers === 0 &amp;&amp; (
						
							<p>
								Locating peers
							</p>

							{this.state.timeout &amp;&amp; (
								<p>
									If this process takes a long time, there might not be anyone seeding
									this torrent. Try asking someone to reupload the file that you want.
								</p>
							)}

magnet-uri

Parse a magnet URI and return an object of keys/values

MIT
Latest version published 11 months ago

Package Health Score

69 / 100
Full package analysis

Popular magnet-uri functions