用于从服务器下载文件,只要总带宽不超过ISP上限,这些服务器就不会限制每个连接的带宽。

mfd的Python项目详细描述


多线程文件下载器

<;徽章>;versionlicensepyversions
donatepoweredmade <;/badges>

对于从不限制每个连接的带宽的服务器下载文件非常有用,只要总带宽不超过ISP上限。

<;u>;不支持cookie或会话。<;/u>

Example:
ISP cap: 2MBps
File server bandwidth per connection: 2MBps
Number of connections: 8
Expected download speed per connection: 256KBps
Expected download speed of the file: 2MBps
Download speed is capped by ISP

ISP cap: 10MBps
File server bandwidth per connection: 1MBps
Number of connections: 8
Expected download speed per connection: 1MBps
Expected download speed of the file: 8MBps
Download speed is capped by file server, can be enhanced by using more connections (which may be limited by the file server)

等级制度

^{pr2}$

示例

Python

<;u>;MFD()不是线程安全的。
不要在线程中使用相同的MFD()实例。<;/u>

frommfdimportMFDmfd=MFD(# file saving directorysave_dir="I:\\test",# piece size of each download connection# adjust with hard disk speed and Internet bandwidth# size in bytespiece_size=1024*1024*(2**4),# number of retry when a piece is failed to downloadretry=2)info=mfd.download(# file urlurl="direct download url",# number of download connectionsconnections=2**3,# whether to calculate SHA1 after downloadingcal_hash=False)print(info)# {"file_path": "I:\\test\\file"}# {"file_path": "I:\\test\\file", "sha1": "checksum"}# if it is failed to download after the specified retries,# an exception is raised# additional retry can be like thistry:mfd.download(...)except:mfd.retry_download(# number of download connectionsconnections=2**3)# necessary to stop the downloader after downloadingmfd.stop()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在表被注释到配置之前获取表的元数据?   java滚动条不会出现在JList上   java JOGL监视器GPU内存   java为什么要使用RecyclerView onDraw延迟   java定制Oppo Reno 2 Z CPH1951(手机型号)的固件(闪存文件)   java自定义线程池执行器   java如何解决发布版本中重复的jar条目[com/安卓/volley/R.class]?   java如何使用Bukkit API触发事件?   java在blazemeter jmeter RTE插件中使用ctrl+w输入   C#/Visual Studio的java JDT等价物   java为什么当maxread值很大而收到的消息数量很小时,卡夫卡消费者会无限期消费?   java游戏2。x:包含模板列表的绑定模型   带压缩的java日志旋转   运行时。exec用java运行程序读取它正在做什么