yt-dlp: [BiliBili] unable to extract play info

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

China

Provide a description that is worded well enough to be understood

I was able to download videos normally at first, but this afternoon I found that the video download started to report errors. I tested a video on three different IP hosts, and this video was able to download correctly yesterday, but today it fails with an error. I tried different types of URLs and also attempted to add cookies to download the video, but none of them worked. I suspect that Bilibili may have updated its anti-scraping mechanism.And I am very sure that my yt-dlp is the latest version.

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

yt-dlp -Uv --extract-audio --audio-format mp3 -o "%(id)s-%(title)s.%(ext)s" "https://www.bilibi
li.com/video/BV1HB4y1N7CY/" --ffmpeg-location "D:\workhome\ffmpeg\ffmpeg-master-latest-win64-gpl\bin"
[debug] Command-line config: ['-Uv', '--extract-audio', '--audio-format', 'mp3', '-o', '%(id)s-%(title)s.%(ext)s', 'https://www.bilibili.com/video/BV1HB4y1N7CY/', '--ffmpeg-location', 'D:\\workhome\\ffmpeg\\ffmpeg-master-latest-win64-gpl\\bin']
[debug] Encodings: locale cp936, fs utf-8, pref cp936, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.11.18 from yt-dlp/yt-dlp [7ea278792] (pip)
[debug] Python 3.11.0 (CPython AMD64 64bit) - Windows-10-10.0.22631-SP0 (OpenSSL 1.1.1w  11 Sep 2023)
[debug] exe versions: ffmpeg N-117770-g322b240cea-20241114 (setts), ffprobe N-117770-g322b240cea-20241114
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.08.30, requests-2.32.3, sqlite3-3.45.3, urllib3-1.26.20, websockets-10.4
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests
[debug] Loaded 1837 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2024.11.18 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.11.18 from yt-dlp/yt-dlp)
[BiliBili] Extracting URL: https://www.bilibili.com/video/BV1HB4y1N7CY/
[BiliBili] 1HB4y1N7CY: Downloading webpage
WARNING: [BiliBili] unable to extract play info; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
ERROR: [BiliBili] 1HB4y1N7CY: Failed to extract play info; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "D:\workhome\anaconda3\envs\crawl11\Lib\site-packages\yt_dlp\extractor\common.py", line 742, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\workhome\anaconda3\envs\crawl11\Lib\site-packages\yt_dlp\extractor\bilibili.py", line 664, in _real_extract
    raise ExtractorError('Failed to extract play info')

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 10
  • Comments: 39 (2 by maintainers)

Commits related to this issue

Most upvoted comments

the extractor should have provided a fallback… EDIT: this patch is outdated. please use pr 11667 instead

show patch
diff --git a/yt_dlp/extractor/bilibili.py b/yt_dlp/extractor/bilibili.py
index 02ea67707..7de609a6c 100644
--- a/yt_dlp/extractor/bilibili.py
+++ b/yt_dlp/extractor/bilibili.py
@@ -644,7 +644,8 @@ def _real_extract(self, url):
             video_data = initial_state['videoInfo']
         else:
             play_info_obj = self._search_json(
-                r'window\.__playinfo__\s*=', webpage, 'play info', video_id, fatal=False)
+                r'window\.__playinfo__\s*=', webpage, 'play info', video_id, default=None)
+            play_info = None
             if not play_info_obj:
                 if traverse_obj(initial_state, ('error', 'trueCode')) == -403:
                     self.raise_login_required()
@@ -652,7 +653,9 @@ def _real_extract(self, url):
                     raise ExtractorError(
                         'This video may be deleted or geo-restricted. '
                         'You might want to try a VPN or a proxy server (with --proxy)', expected=True)
-            play_info = traverse_obj(play_info_obj, ('data', {dict}))
+                play_info = self._download_playinfo(video_id, initial_state['cid'], headers=headers)
+            else:
+                play_info = traverse_obj(play_info_obj, ('data', {dict}))
             if not play_info:
                 if traverse_obj(play_info_obj, 'code') == 87007:
                     toast = get_element_by_class('tips-toast', webpage) or ''

EDIT: why am I getting downvoted? Is the patch not working as expected? If so, please attach a verbose log

@2333-Del Please don’t close this issue yet. This is just a temporary patch and you shouldn’t close this issue until it’s merged into master so that the users and the maintainers can see this issue

I made a custom build for those who don’t want to run/build from source. Run yt-dlp --update-to grqz/yt-dlp@ie/bilibili/pi_fallbk to switch to that channel and run yt-dlp --update-to nightly to switch back afterwards if necessary.

yt-dlp --update-to grqz/yt-dlp@ie/bilibili/pi_fallbk i get this error: You installed yt-dlp with pip or using the wheel from PyPi; Use that to update How fix it?

pip install --force-reinstall --break-system-packages git+https://github.com/grqz/yt-dlp.git@ie/bilibili/pi_fallbk

@grqz When can we expect your patch to be merged into master branch?

You could ask the maintainers. They’ve been quite busy recently so don’t expect the patch to be merged very soon. I will make a yt-dlp plugin later if there’s no progress on the pr for a long time

don’t use --break-system-packages

@hhhnaad that’s not a full verbose log. pass -v to yt_dlp and post the full log here, starting with [debug]

EDIT: I think the issue is caused by using the raw video_id instead of bvid. i’ll update the code shortly

seems like window.__playinfo__ is removed from the page source now

I also encountered the same problem

My cue is this.

[BiliBili] Extracting URL: https://www.bilibili.com/video/BV1ALzVYUEZf
[BiliBili] 1ALzVYUEZf: Downloading webpage
WARNING: [BiliBili] unable to extract play info; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
ERROR: [BiliBili] 1ALzVYUEZf: Failed to extract play info; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U

Excitely,The mistake that happened yesterday is answered so much when you look at it.

There was no such error yesterday. I woke up today and found an error when running. I suspect that Bilibili has updated its web page strategy.

I also encountered the same problem