解决 up 主个人主页 URL 变化及其他问题 Solve URL Changes and Other Error Issues on Up - master's Personal Homepage#3039
Open
shengrihui wants to merge 5 commits intosoimort:developfrom
Open
解决 up 主个人主页 URL 变化及其他问题 Solve URL Changes and Other Error Issues on Up - master's Personal Homepage#3039shengrihui wants to merge 5 commits intosoimort:developfrom
shengrihui wants to merge 5 commits intosoimort:developfrom
Conversation
…li.com 2.更新部分 APIs,Update some APIs 3.格式化,formatting file
…stream_sorted list is empty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
1. URL 变化问题
也许是由于 B 站更新,部分页面的 URL 发生了改变。在我的电脑上,Chrome 和 Edge 浏览器显示的 URL 存在新旧差异。具体变化如下表所示:
https://space.bilibili.com/22179951/channel/serieshttps://space.bilibili.com/22179951/listsid=3152230的合集https://space.bilibili.com/22179951/channel/collectiondetail?sid=3152230https://space.bilibili.com/22179951/lists/3152230?type=seasonid=485635的视频列表https://space.bilibili.com/22179951/channel/seriesdetail?sid=485635https://space.bilibili.com/22179951/lists/485635?type=serieshttps://space.bilibili.com/22179951/videohttps://space.bilibili.com/22179951/upload/video新的 URL 无法被 you-get 匹配,会报错
you-get: [Error] Unsupported URL pattern.。旧的 URL 也存在部分无法匹配和报错的情况。报错示例如下:
2.
playlist下载结束问题在
playlist下载结束后,由于仍会在download_by_url函数中执行self.extract(**kwargs)和self.download(**kwargs),会导致self.stream_sorted为空,在stream_id = self.streams_sorted[0]['id'] if 'id' in self.streams_sorted[0] else self.streams_sorted[0]['itag'](位于download函数中)导致IndexError: list index out of range错误。site: Bilibili title: None streams: # Available quality and codecs3. 视频跳转和缺失问题
在下载所有视频(或合集等)时,会遇到部分视频跳转到课程页面,或者视频已不存在但仍在合集里显示的情况,进而导致程序出错。
解决方案
1. URL 重定向与 API 更新
如果输入的是旧的 URL,将其重定向到对应的新 URL。并更新部分 API。
2. 空列表判断
加入判断
if not self.streams_sorted: return,避免因self.stream_sorted为空而引发错误。3. 异常处理
使用
try...except...语句暂时处理视频缺失问题,将课程下载标记为 TODO。待解决问题
1. 下载速度问题
下载速度较慢,不理解
skip_existing_file_size_check参数的作用。代码中多处存在类似file_size == os.path.getsize(filepath) or skip_existing_file_size_check语句,感觉在使用该参数时仍需检查文件大小,没有体现出 “跳过” 的作用。2. 下载结果反馈问题
建议在下载结束时列出哪些视频下载成功、哪些视频下载失败,以便用户了解下载情况。
Problem Description
1. URL Changes
Perhaps due to the update of Bilibili, the URLs of some pages have changed. On my computer, there are differences between the old and new URLs displayed in Chrome and Edge browsers. The specific changes are as shown in the table above:
The new URLs cannot be matched by the program, resulting in the error
you-get: [Error] Unsupported URL pattern.. Some of the old URLs also cannot be matched and will cause errors.Examples of error reports can be found above.
2. Issue after
playlistDownload CompletionAfter the
playlistdownload is completed, sinceself.extract(**kwargs)andself.download(**kwargs)will still be executed in thedownload_by_urlfunction, it will lead to the following problems:self.stream_sortedis empty, in the statementstream_id = self.streams_sorted[0]['id'] if 'id' in self.streams_sorted[0] else self.streams_sorted[0]['itag'](located in thedownloadfunction), it will result in anIndexError: list index out of rangeerror.3. Video Redirection and Missing Issues
When downloading all videos (or collections, etc.), some videos may jump to course pages, or some videos may no longer exist but are still displayed in the list, causing the program to error.
Solutions
1. URL Redirection and API Update
If an old URL is entered, redirect it to the corresponding new URL and update some APIs.
2. Empty List Check
Add the check
if not self.streams_sorted: returnto the relevant code to avoid errors caused by an emptyself.stream_sortedlist.3. Exception Handling
Use
try...except...statements to temporarily handle video redirection and missing issues. Mark course downloads as TODO.Outstanding Issues
1. Download Speed Issue
The download speed is slow, and I don't understand the function of the
skip_existing_file_size_checkparameter. There are many statements likefile_size == os.path.getsize(filepath) or skip_existing_file_size_checkin the code. It seems that the file size still needs to be checked when using this parameter, and the "skip" function is not reflected.2. Download Result Feedback Issue
It is recommended to list which videos were downloaded successfully and which failed at the end of the download so that users can understand the download status.