ed2k-link
A simple module to parse/generate ed2k link for nodejs.
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 }
Ed2kLink
to ed2k url string
Convert Code:
var link = ed2k.parse("ed2k://|file|foo.bar|123|0123456789ABCDEF0123456789ABCDEF|/");
link.toString();
Output:
ed2k://|file|foo.bar|123|0123456789ABCDEF0123456789ABCDEF|/
Ed2kLink
from file:
Generate 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: lightpacerabbit@gmail.com