Skip to content

Replace PCDN domains on Bilibili #12421

@jyxjjj

Description

@jyxjjj

Checklist

  • I'm requesting a site-specific feature
  • I've verified that I have updated yt-dlp to nightly or master (update instructions)
  • I've checked that all provided URLs are playable in a browser with the same IP and same login details
  • I've searched the bugtracker for similar requests including closed ones. DO NOT post duplicates
  • I've read about sharing account credentials and I'm willing to share it if required

Region

China

Example URLs

https://www.bilibili.com/video/BV1RvAzeAEa2

Provide a description that is worded well enough to be understood

Recently i found i cannot download videos from Bilibili.
It is due to AdRules of PCDN blacklist.
Related to: Cats-Team/AdRules#217

Full URL Lists
ID     EXT RESOLUTION FPS │   FILESIZE   TBR PROTO │ VCODEC          VBR ACODEC      ABR
────────────────────────────────────────────────────────────────────────────────────────
30216  m4a audio only     │ ≈900.10KiB   53k https │ audio only          mp4a.40.5   53k
30232  m4a audio only     │ ≈  1.66MiB  100k https │ audio only          mp4a.40.2  100k
30280  m4a audio only     │ ≈  3.33MiB  202k https │ audio only          mp4a.40.2  202k
100046 mp4 640x360     30 │ ≈  4.33MiB  262k https │ avc1.64001E    262k video only
30011  mp4 640x360     30 │ ≈  3.68MiB  223k https │ hev1.1.6.L120  223k video only
100022 mp4 640x360     30 │ ≈  3.46MiB  210k https │ av01.0.00M.10  210k video only
100047 mp4 852x480     30 │ ≈  7.27MiB  441k https │ avc1.64001F    441k video only
30033  mp4 852x480     30 │ ≈  4.94MiB  300k https │ hev1.1.6.L120  300k video only
100023 mp4 852x480     30 │ ≈  4.70MiB  285k https │ av01.0.00M.10  285k video only
100048 mp4 1280x720    30 │ ≈ 10.38MiB  629k https │ avc1.640028    629k video only
30066  mp4 1280x720    30 │ ≈  5.75MiB  349k https │ hev1.1.6.L120  349k video only
100024 mp4 1280x720    30 │ ≈  5.34MiB  324k https │ av01.0.00M.10  324k video only
100050 mp4 1920x1080   30 │ ≈ 18.24MiB 1105k https │ avc1.640032   1105k video only
30077  mp4 1920x1080   30 │ ≈  9.13MiB  553k https │ hev1.1.6.L150  553k video only
100026 mp4 1920x1080   30 │ ≈  8.37MiB  508k https │ av01.0.00M.10  508k video only
30112  mp4 1920x1080   30 │ ≈ 44.50MiB 2696k https │ avc1.640032   2696k video only
30102  mp4 1920x1080   30 │ ≈ 25.13MiB 1523k https │ hev1.1.6.L150 1523k video only
100027 mp4 1920x1080   30 │ ≈ 22.14MiB 1342k https │ av01.0.00M.10 1342k video only
https://xy153x35x231x78xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-100027.m4s?[PARAMS_ARE_HIDDEN]
https://xy112x85x127x140xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30102.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-30112.m4s?[PARAMS_ARE_HIDDEN]
https://xy118x182x248x145xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-100026.m4s?[PARAMS_ARE_HIDDEN]
https://xy36x156x75x162xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30077.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100050.m4s?[PARAMS_ARE_HIDDEN]
https://xy123x138x84x17xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-100024.m4s?[PARAMS_ARE_HIDDEN]
https://xy153x35x231x79xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30066.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100048.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100023.m4s?[PARAMS_ARE_HIDDEN]
https://xy125x74x62x245xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30033.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100047.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100022.m4s?[PARAMS_ARE_HIDDEN]
https://xy61x52x133x57xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30011.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100046.m4s?[PARAMS_ARE_HIDDEN]
https://xy153x35x231x78xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30280.m4s?[PARAMS_ARE_HIDDEN]
https://xy153x35x231x78xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30232.m4s?[PARAMS_ARE_HIDDEN]
https://xy123x138x84x143xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30216.m4s?[PARAMS_ARE_HIDDEN]

I am here to request a feature to replace the source url.

Here is a User Script from greasyfork:

function replaceP2PUrl(url) {
        cdnDomain ||= document.head.innerHTML.match(/up[\w-]+\.bilivideo\.com/)?.[0];
 
        try {
            const urlObj = new URL(url);
            const hostName = urlObj.hostname;
            if (urlObj.hostname.endsWith(".mcdn.bilivideo.cn")) {
                urlObj.host = cdnDomain || 'upos-sz-mirrorcoso1.bilivideo.com';
                urlObj.port = 443;
                console.warn(`更换视频源: ${hostName} -> ${urlObj.host}`);
                return urlObj.toString();
            } else if (urlObj.hostname.endsWith(".szbdyd.com")) {
                urlObj.host = urlObj.searchParams.get('xy_usource');
                urlObj.port = 443;
                console.warn(`更换视频源: ${hostName} -> ${urlObj.host}`);
                return urlObj.toString();
            }
            return url;
        } catch (e) {
            return url;
        }
    }

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 --cookies-from-browser Chrome https://www.bilibili.com/video/BV1RvAzeAEa2 -F -f all --get-url -vU
[debug] Command-line config: ['--cookies-from-browser', 'Chrome', 'https://www.bilibili.com/video/BV1RvAzeAEa2', '-F', '-f', 'all', '--get-url', '-vU']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2025.02.19 from yt-dlp/yt-dlp [4985a4041] (pip)
[debug] Python 3.13.2 (CPython arm64 64bit) - macOS-15.3.1-arm64-arm-64bit-Mach-O (OpenSSL 3.4.1 11 Feb 2025)
[debug] exe versions: ffmpeg 7.1 (setts), ffprobe 7.1, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.21.0, brotli-1.1.0, certifi-2025.01.31, mutagen-1.47.0, requests-2.32.3, sqlite3-3.49.0, urllib3-2.3.0, websockets-15.0
[debug] Proxy map: {'http': 'http://127.0.0.1:7890', 'https': 'http://127.0.0.1:7890', 'socks': 'http://127.0.0.1:7890'}
Extracting cookies from chrome
[debug] Extracting cookies from: "/Users/jyxjjj/Library/Application Support/Google/Chrome/Default/Cookies"
[debug] using find-generic-password to obtain password from OSX keychain
Extracted 3384 cookies from chrome
[debug] cookie version breakdown: {'v10': 3613, 'other': 0, 'unencrypted': 0}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1841 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2025.02.19 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2025.02.19 from yt-dlp/yt-dlp)
[BiliBili] Extracting URL: https://www.bilibili.com/video/BV1RvAzeAEa2
[BiliBili] 1RvAzeAEa2: Downloading webpage
[BiliBili] BV1RvAzeAEa2: Extracting videos in anthology
[BiliBili] 114030140199908: Extracting chapters
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec, channels, acodec, size, br, asr, proto, vext, aext, hasaud, source, id
[info] Available formats for BV1RvAzeAEa2:
ID     EXT RESOLUTION FPS │   FILESIZE   TBR PROTO │ VCODEC          VBR ACODEC      ABR
────────────────────────────────────────────────────────────────────────────────────────
30216  m4a audio only     │ ≈900.10KiB   53k https │ audio only          mp4a.40.5   53k
30232  m4a audio only     │ ≈  1.66MiB  100k https │ audio only          mp4a.40.2  100k
30280  m4a audio only     │ ≈  3.33MiB  202k https │ audio only          mp4a.40.2  202k
100046 mp4 640x360     30 │ ≈  4.33MiB  262k https │ avc1.64001E    262k video only
30011  mp4 640x360     30 │ ≈  3.68MiB  223k https │ hev1.1.6.L120  223k video only
100022 mp4 640x360     30 │ ≈  3.46MiB  210k https │ av01.0.00M.10  210k video only
100047 mp4 852x480     30 │ ≈  7.27MiB  441k https │ avc1.64001F    441k video only
30033  mp4 852x480     30 │ ≈  4.94MiB  300k https │ hev1.1.6.L120  300k video only
100023 mp4 852x480     30 │ ≈  4.70MiB  285k https │ av01.0.00M.10  285k video only
100048 mp4 1280x720    30 │ ≈ 10.38MiB  629k https │ avc1.640028    629k video only
30066  mp4 1280x720    30 │ ≈  5.75MiB  349k https │ hev1.1.6.L120  349k video only
100024 mp4 1280x720    30 │ ≈  5.34MiB  324k https │ av01.0.00M.10  324k video only
100050 mp4 1920x1080   30 │ ≈ 18.24MiB 1105k https │ avc1.640032   1105k video only
30077  mp4 1920x1080   30 │ ≈  9.13MiB  553k https │ hev1.1.6.L150  553k video only
100026 mp4 1920x1080   30 │ ≈  8.37MiB  508k https │ av01.0.00M.10  508k video only
30112  mp4 1920x1080   30 │ ≈ 44.50MiB 2696k https │ avc1.640032   2696k video only
30102  mp4 1920x1080   30 │ ≈ 25.13MiB 1523k https │ hev1.1.6.L150 1523k video only
100027 mp4 1920x1080   30 │ ≈ 22.14MiB 1342k https │ av01.0.00M.10 1342k video only
https://xy153x35x231x78xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-100027.m4s?[PARAMS_ARE_HIDDEN]
https://xy112x85x127x140xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30102.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-30112.m4s?[PARAMS_ARE_HIDDEN]
https://xy118x182x248x145xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-100026.m4s?[PARAMS_ARE_HIDDEN]
https://xy36x156x75x162xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30077.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100050.m4s?[PARAMS_ARE_HIDDEN]
https://xy123x138x84x17xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-100024.m4s?[PARAMS_ARE_HIDDEN]
https://xy153x35x231x79xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30066.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100048.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100023.m4s?[PARAMS_ARE_HIDDEN]
https://xy125x74x62x245xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30033.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100047.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100022.m4s?[PARAMS_ARE_HIDDEN]
https://xy61x52x133x57xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30011.m4s?[PARAMS_ARE_HIDDEN]
https://xy58x221x77x134xy.mcdn.bilivideo.cn:4483/upgcxcode/42/76/28472577642/28472577642-1-100046.m4s?[PARAMS_ARE_HIDDEN]
https://xy153x35x231x78xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30280.m4s?[PARAMS_ARE_HIDDEN]
https://xy153x35x231x78xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30232.m4s?[PARAMS_ARE_HIDDEN]
https://xy123x138x84x143xy.mcdn.bilivideo.cn:8082/v1/resource/28472577642-1-30216.m4s?[PARAMS_ARE_HIDDEN]

Metadata

Metadata

Assignees

No one assigned

    Labels

    site-enhancementFeature request for some websitetriageUntriaged issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions