CLI tool for downloading videos from the bilibili.com website. although you can download directly from the mobile app, but you'il see annoying watermark and limited video quality (unless you subscribe to bilibili).
for example see:
graph TB
A[bilibili url] --> B[Without Login]
B ---> C[32/480p, 16/360P]
A ---> D[With Login]
D ---> E[80/1080P, 64/720P, 32/480P, 16/360P]
D ---> F((Subscribe))
F ---> G[120/2160P, 116/1080P60FPs, 80/1080P, 64/720P, 32/480P, 16/360P]
so, to get high quality from webpage you need a login and set cookie. see How to get and set cookies
git clone https://github.com/motebaya/bilibili-dl
cd bilibili-dl
composer i
php7.4.33
: https://www.php.net/releases/#7.4.33
composer
: https://getcomposer.org/download/
main
: php7.4 cli.php
-u
,--url/userid
: url video or user id-b
,--bookmark
: action to download from bookmark/favorite list-t
,--type
: method type [webpage, api, site]
-
Method list
-
webpage
:direct scrape from url video, this method will be download separated media (video and audio). then merger it using PHP-FFMpeg
if you see an error:
Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutableNotFoundException: Executable not found, proposed :
try change
ffmpeg
andffprobe
default path to this line with your binary path.see official docs.e.g :
https://www.bilibili.com/video/BV<videoid>
-
api
: download using bilibili api -
site
: download from external downloader website: youtube4kdownloader
-
-
Example Usage:
download from url with method webpage:
php7.4 cli.php -u https://www.bilibili.com/video/BV<videoid> -t webpage
download from bookmark by userid with method api:
php7.4 cli.php -u 32638440 -t api -b
downloaded media will saved in default folder "src/Downloader/media" with name "media-title.[ext]", you can move it manually.
this is optional, for used to get more high quality only.
- Login you account to bilibili.com, you can using addon/extension Cookiedough.
- copy your cookies and put (overwrite) to file cookies
- not all stream audio or video from webpage always work, sometime you'il see unavailabe response. e.g:
An error occurred while processing your request.<p>
Reference #132.e6eece17.1694877766.1654822b
</BODY></HTML>
and
<html>
<head><title>403 Forbidden</title></head>
<body>
<h1>403 Forbidden</h1>
<p>You don't have permission to access the URL on this server.<hr/>Powered by Tengine</body>
</html>
- also for external site youtube4kdownloader sometime give error response, e.g:
An error occurred from remote video site. Please try with other download link
- and last, for Api's. it's seem not work with hotspot network. bcs im try it in my mobile network it's work as well, but in my PC stuck loading. idk, why ??
This project is licensed under the MIT License.