Skip to content

Commit

Permalink
添加temp参数
Browse files Browse the repository at this point in the history
  • Loading branch information
tanyiqu committed Nov 17, 2020
1 parent 9514676 commit 8021413
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 8 additions & 0 deletions docs/HowToUse_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,25 @@ mdown https://mei.huazuida.com/20191220/19588_51b84e32/index.m3u8 -t 128





如果你想下载更快速一点,你可以在后面追加 ```-t 128``` 来指定下载使用的线程为128,当然也可以更快,这取决于你的电脑性能和网络带宽





如果你想要给下载好的文件命名,你可以再追加 ```-n xxx.ts``` 来指定下载视频的名称





如果你想要下载到 D:/video 这个文件夹下,你可以再追加 ```-o D:/video``` 来指定下载的位置





以上需要追加的参数没有顺序限制,但是url链接一定要在第一位

7 changes: 5 additions & 2 deletions mdown/downloader/M3u8Downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def __init__(self,
filename: str,
maxWorkers: int,
timeout: int,
interval: float = 0.5):
interval: float = 0.5,
temp: bool = False):
"""
构造器
:param tsList: 下载链接的list
Expand All @@ -29,6 +30,7 @@ def __init__(self,
:param maxWorkers: 最大的线程数
:param timeout: 等待几秒
:param interval: 时间间隔,用于记录网速等
:param temp: 是否保留临时文件 为True时保留
"""

self.tsList = tsList
Expand All @@ -37,6 +39,7 @@ def __init__(self,
self.maxWorkers = maxWorkers
self.timeout = timeout
self.interval = interval # 计时器停顿时间间隔
self.temp = temp
self.dataPerInterval = 0 # 每一个时间间隔所下载的流量
# 文件输出路径
self.outPath = ('%s\\%s' % (self.path, self.filename)).replace('\\', '/')
Expand Down Expand Up @@ -82,7 +85,7 @@ def isFinished(self):
# 下载成功回调
def __onFinished(self):
# 清除临时文件
if not Configuration.temp:
if not self.temp:
OSUtil.rmDir(self.tmpPath)
pass

Expand Down
5 changes: 4 additions & 1 deletion mdown/mdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ def main():
filename=Configuration.name,
maxWorkers=Configuration.thread,
timeout=Configuration.timeout,
interval=0.2)
interval=0.2,
temp=Configuration.temp)

# 下载视频
print('downloading...')
downloader.download()

Expand Down

0 comments on commit 8021413

Please sign in to comment.