Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
peardownloader
Advanced tools
PearDownloader(梨享下载器) 是完全用JavaScript写的开源文件下载器, 实现了融合HTTP(包含HTTPS、HTTP2)、WebRTC的多协议、多源、低延迟、高带宽利用率的无插件Web端下载加速能力。 基于高效的调度算法将来自多个节点的数据进行拼接形成完整的文件, PearDownloader能在保证下载速度前提下最大化P2P率。
只需将pear-downloader.min.js
通过<script>
标签导入到HTML就可以使用。
参考以下代码示例,也可以查看/examples/download.html
来了解使用方法。
信令部分以及WebRTC部分使用了精心设计的协议,实现此部分可以参考API文档。
Demo演示地址:https://qq.webrtc.win/downloader
首先通过script标签导入pear-downloader.min.js:
<script src="./dist/pear-downloader.min.js"></script>
或者使用CDN:
假设要下载(/tv/pear001.mp4)这个视频,只需要如下几行代码:
<script>
/**
* 第一个参数为文件的url
* 第二个参数为获得授权后的token
* opts是可选的参数配置
*/
var player = new PearDownloader('/tv/pear001.mp4', token, opts);
</script>
恭喜您,您的播放器已经具备P2P能力了,而且无须任何插件!
在使用PearPlayer之前,需要获取token,通过调用提供的API接口(/v1/customer/login)并传入用户名和密码, 这里已经为访客提供了测试帐号(用户名:test 密码:123456),获取token的示例代码如下:
var xhr = new XMLHttpRequest();
xhr.open("POST", 'https://api.webrtc.win:6601/v1/customer/login');
var data = JSON.stringify({
user:'demo',
password:'demo'
});
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {
var res = JSON.parse(this.response);
if (!!res.token){
console.log('token:' +res.token);
}
} else {
alert('请求出错!');
}
};
xhr.send(data);
特别感谢以下项目,为本项目提供了部分灵感来源以及API设计参考:
MIT. Copyright (c) Pear Limited and snowinszu.
E-mail: service@pear.hk;用户QQ群:373594967
;CP/CDN接入、OEM与其他商务合作
FAQs
PearDownloader.js
The npm package peardownloader receives a total of 46 weekly downloads. As such, peardownloader popularity was classified as not popular.
We found that peardownloader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.