Skip to content

lightrabbit/ed2k-link

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ed2k-link

A simple module to parse/generate ed2k link for nodejs.
NPM

Installation

You can use this command to install:

npm install ed2k-link

Usage

You should require the module first:

ed2k = require('ed2k-link');

Example

Parse a ed2k url

Code:

ed2k.parse("ed2k://|file|foo.bar|123|0123456789ABCDEF0123456789ABCDEF|/");

Output:

{ filename: 'foo.bar',
  ed2k: '0123456789ABCDEF0123456789ABCDEF',
  aich: '',
  hashset: [],
  sources: { client: [], url: [] },
  length: 123 }

Convert Ed2kLink to ed2k url string

Code:

var link = ed2k.parse("ed2k://|file|foo.bar|123|0123456789ABCDEF0123456789ABCDEF|/");
link.toString();

Output:

ed2k://|file|foo.bar|123|0123456789ABCDEF0123456789ABCDEF|/

Generate Ed2kLink from file:

Code:

//node-like callback
ed2k.generate("./foo.bar", function(err, link) {
  console.log(link);
});
//Promise
ed2k.generate("./foo.bar").then(function(link) {
  console.log(link);
});

Output:

{ filename: 'foo.bar',
  ed2k: '0123456789ABCDEF0123456789ABCDEF',
  aich: '',
  hashset: [],
  sources: { client: [], url: [] },
  length: 123 }

License

The project is released under the MIT license.

Contact

Author: [email protected]

About

A simple module to parse/generate ed2k link for nodejs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published