Open awei78 opened 5 years ago
@dstftw Can you modify it? thanks
if 'anime/' not in url:
page_number = int(self._search_regex(
r'/\?p=(\d+)$', url, 'page_number', '0'))
pattern = r'\bcid(?:["\']:|=)(\d+)' if page_number == 0 else r'\bcid(?:["\']:|=)(\d+),"page":%d' % page_number
cid = self._search_regex(
pattern, webpage, 'cid',
default=None
) or compat_parse_qs(self._search_regex(
[r'EmbedPlayer\([^)]+,\s*"([^"]+)"\)',
r'EmbedPlayer\([^)]+,\s*\\"([^"]+)\\"\)',
r'<iframe[^>]+src="https://secure\.bilibili\.com/secure,([^"]+)"'],
webpage, 'player parameters'))['cid'][0]
else:
@awei78 , I think it would be quicker if you go and edit the file in the code repository yourself which would automatically create a pull request that the maintainers can approve. We really need this bug fix applied. Also, a little note about this bug fix, if you want to download more then one page of a multi-page video (IE https://www.bilibili.com/video/av4050443/?p=85 and https://www.bilibili.com/video/av4050443/?p=86), you need to do each separately and use the -o parameter to give them different titles so youtube-dl doesn't think you are trying to download the same video again.
Please follow the guide below
x
into all the boxes [ ] relevant to your issue (like this:[x]
)Make sure you are using the latest version: run
youtube-dl --version
and ensure your version is 2019.04.01. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.In the file bilibili.py, line 116, the code of get "cid" is:
cid = self._search_regex( r'\bcid(?:["\']:|=)(\d+)', webpage, 'cid', default=None ) or compat_parse_qs(self._search_regex( [r'EmbedPlayer\([^)]+,\s*"([^"]+)"\)', r'EmbedPlayer\([^)]+,\s*\\"([^"]+)\\"\)', r'<iframe[^>]+src="https://secure\.bilibili\.com/secure,([^"]+)"'], webpage, 'player parameters'))['cid'][0]
If there is only one video on the page, it works fine. However, if the video is part of the list, such as url: https://www.bilibili.com/video/av4050443/?p=86 It's cid is: 6534658. part of it's data is: {"cid":6534658,"page":86,"from":"vupload"...}
Use Regex pattern r'\bcid(?:["\']:|=)(\d+)', it only get the cid of the first video in the list, it is wrong. Then I found, if there is only one video on the page, it video data like this: {"cid":45915709,"page":1,"from":"vupload"...}, That is, it has a page number.
So, I think, can pattern be changed? add a page number limit, suck as:
In this way, the correct cid can be achieved, and the whole playlist can be downloaded.
I am looking forward to it.