Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

断点续传和频道下载 #2

Open
roachsinai opened this issue May 21, 2019 · 10 comments
Open

断点续传和频道下载 #2

roachsinai opened this issue May 21, 2019 · 10 comments

Comments

@roachsinai
Copy link

是否考虑支持断点续传和频道下载呢?

@taseikyo
Copy link
Owner

是否考虑支持断点续传和频道下载呢?

断点续传我之前也想过但是不会 233,频道下载指的是 up 主的所有投稿吗

@roachsinai
Copy link
Author

网上看到的说以ab的方式打开:with open(file_path, "ab") as f:https://blog.csdn.net/qq_35203425/article/details/80987880

不过我的情况好象是,网络不好有时候会断,线程报异常中止了。

@taseikyo
Copy link
Owner

网上看到的说以ab的方式打开:with open(file_path, "ab") as f:https://blog.csdn.net/qq_35203425/article/details/80987880

不过我的情况好象是,网络不好有时候会断,线程报异常中止了。

看了下下载部分的代码,我当时的做法是如果已经存在就认为下载完成,直接设置进度条 100%
https://github.com/LewisTian/bili-box/blob/master/src/main.py#L637

然后有个问题是我是用的是 urllib.request.urlretrieve 来下载视频,我看里面是以 wb 方式打开
博客里面使用 requests 要换的话 感觉有点麻烦

有个想法是把后半部分下载为另一个视频,完了之后将两个合并
这个也有问题,就是怎么请求后半部分的视频数据

@roachsinai
Copy link
Author

频道是,比如我现在想下载这个链接看一下https://space.bilibili.com/97068901/channel/detail?cid=54167

@taseikyo
Copy link
Owner

频道是,比如我现在想下载这个链接看一下https://space.bilibili.com/97068901/channel/detail?cid=54167

这样子,感觉跟一个收藏差不多

@roachsinai
Copy link
Author

image

如上图,我的下载都是一部分然后失败了

Exception in thread 3:
Traceback (most recent call last):
  File "/usr/lib64/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "./src/main.py", line 640, in download
    urequest.urlretrieve(j, filename=f'{folder}/{filename}', reporthook=self.report)
  File "/usr/lib64/python3.7/urllib/request.py", line 288, in urlretrieve
    % (read, size), result)
urllib.error.ContentTooShortError: <urlopen error retrieval incomplete: got only 41549129 out of 110035888 bytes>

应该是网络的原因,然后我选中第一个再次下载直接显示100%了,如果没法再次下载。能否添加个清空的选项。然后就可以点击下载来重新下载了。

@taseikyo
Copy link
Owner

我上面说了啊 如果已经存在下载的文件 再次下载就会直接显示进度 100%
你可以删掉 main.py 中第 736 行的 if-else 这样每次都是直接重新下载

@roachsinai
Copy link
Author

抱歉,当时没看明白。。

@Jasonandy
Copy link

作者辛苦了
用的啥下载引擎

@taseikyo
Copy link
Owner

taseikyo commented May 7, 2020

作者辛苦了
用的啥下载引擎

urllib.request.urlretrieve 函数来进行下载

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants