# Bilibili Video Downloader & Stream Extractor (Cheapest) (`ahmed_jasarevic/bilibili-video-downloader`) Actor

Extracts Bilibili video metadata, available video/audio streams, and generates ffmpeg merge commands for downloading videos in multiple qualities.

- **URL**: https://apify.com/ahmed\_jasarevic/bilibili-video-downloader.md
- **Developed by:** [Ahmed Jasarevic](https://apify.com/ahmed_jasarevic) (community)
- **Categories:** Videos, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## 📺 Bilibili Video Downloader & Stream Extractor

A fast and reliable **Bilibili video scraper API actor** that extracts high-quality video and audio streams directly from Bilibili without using a browser. Perfect for downloading videos, building media tools, or integrating streaming data into your applications.

---

### 🚀 Features

* ⚡ Fast extraction using Bilibili official API endpoints
* 🎥 Retrieves multiple video qualities (360p, 480p, etc.)
* 🔊 Separate audio stream extraction
* 🧠 Auto-selects best available quality
* 🔗 Provides direct downloadable media URLs
* ⏱ Expiration tracking for signed URLs
* 📦 Clean structured JSON output
* 🪶 Lightweight (no browser / Playwright required)

---

### 📥 Input

Provide a list of Bilibili video URLs.

#### Example Input JSON

```json
{
  "links": [
    "https://www.bilibili.com/video/BV1hj411i7rX/",
    "https://www.bilibili.com/video/BV1xxxxxxx/"
  ]
}
````

***

### 📤 Output

Each video returns structured metadata + stream links.

#### Example Output JSON

```json
{
	"url": "https://www.bilibili.com/video/BV1hj411i7rX/",
	"result": {
		"title": "【bilibili超级科学晚】全程回顾（上）",
		"duration": 5967,
		"url": "https://www.bilibili.com/video/BV1hj411i7rX",
		"expiresAt": 1777806744,
		"best": {
			"quality": "852x480",
			"video": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-100047.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&platform=pc&deadline=1777806744&nbs=1&mid=0&oi=86732298&gen=playurlv3&trid=4edb0169c88349ed83a8434f1a5efceu&uipk=5&os=akam&og=cos&upsig=b968add5b339755c3c1c592d4bb1cbe4&uparams=e,platform,deadline,nbs,mid,oi,gen,trid,uipk,os,og&hdnts=exp=1777806744~hmac=c65e3139850f157db27dbe2fe537456351e389222da1d3c06ccf925dc25dba5f&bvc=vod&nettype=0&bw=322400&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2",
			"audio": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&gen=playurlv3&platform=pc&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&oi=86732298&os=akam&og=hw&nbs=1&uipk=5&mid=0&upsig=e1cdacd366bfee0ee9072235e20cdaa0&uparams=e,gen,platform,trid,deadline,oi,os,og,nbs,uipk,mid&hdnts=exp=1777806744~hmac=9a819795fb9ea7624af5f970c4a37f57c3a7c638f2d2d513f38c40eaa6f5d6cf&bvc=vod&nettype=0&bw=194512&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&agrr=1&buvid=&orderid=0,2",
			"mergeHint": "ffmpeg -i \"https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-100047.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&platform=pc&deadline=1777806744&nbs=1&mid=0&oi=86732298&gen=playurlv3&trid=4edb0169c88349ed83a8434f1a5efceu&uipk=5&os=akam&og=cos&upsig=b968add5b339755c3c1c592d4bb1cbe4&uparams=e,platform,deadline,nbs,mid,oi,gen,trid,uipk,os,og&hdnts=exp=1777806744~hmac=c65e3139850f157db27dbe2fe537456351e389222da1d3c06ccf925dc25dba5f&bvc=vod&nettype=0&bw=322400&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2\" -i \"https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&gen=playurlv3&platform=pc&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&oi=86732298&os=akam&og=hw&nbs=1&uipk=5&mid=0&upsig=e1cdacd366bfee0ee9072235e20cdaa0&uparams=e,gen,platform,trid,deadline,oi,os,og,nbs,uipk,mid&hdnts=exp=1777806744~hmac=9a819795fb9ea7624af5f970c4a37f57c3a7c638f2d2d513f38c40eaa6f5d6cf&bvc=vod&nettype=0&bw=194512&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&agrr=1&buvid=&orderid=0,2\" -c copy output.mp4"
		},
		"medias": [
			{
				"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-100047.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&platform=pc&deadline=1777806744&nbs=1&mid=0&oi=86732298&gen=playurlv3&trid=4edb0169c88349ed83a8434f1a5efceu&uipk=5&os=akam&og=cos&upsig=b968add5b339755c3c1c592d4bb1cbe4&uparams=e,platform,deadline,nbs,mid,oi,gen,trid,uipk,os,og&hdnts=exp=1777806744~hmac=c65e3139850f157db27dbe2fe537456351e389222da1d3c06ccf925dc25dba5f&bvc=vod&nettype=0&bw=322400&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2",
				"bandwidth": 322374,
				"mimeType": "video/mp4",
				"width": "852",
				"height": "480",
				"is_audio": false,
				"type": "video",
				"extension": "mp4"
			},
			{
				"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-100046.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&nbs=1&uipk=5&gen=playurlv3&os=akam&og=ali&platform=pc&mid=0&oi=86732298&upsig=8e9d326d02b5cd8df64226a8588a6809&uparams=e,trid,deadline,nbs,uipk,gen,os,og,platform,mid,oi&hdnts=exp=1777806744~hmac=793519258ab45e796c26a0502f82c6ba1496681d16ecf3b06902b81dd0ca90f6&bvc=vod&nettype=0&bw=198406&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2",
				"bandwidth": 198391,
				"mimeType": "video/mp4",
				"width": "640",
				"height": "360",
				"is_audio": false,
				"type": "video",
				"extension": "mp4"
			},
			{
				"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-30216.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&mid=0&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&gen=playurlv3&os=akam&og=hw&nbs=1&uipk=5&oi=86732298&platform=pc&upsig=f9f2ff2e708b19bba1fbaf7177fd9520&uparams=e,mid,trid,deadline,gen,os,og,nbs,uipk,oi,platform&hdnts=exp=1777806744~hmac=93d2cebea576347ad11b5762e06b0aa69c0f101934885fb9546b6938337dcae1&bvc=vod&nettype=0&bw=41947&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2",
				"bandwidth": 41943,
				"mimeType": "audio/mp4",
				"codecs": "mp4a.40.5",
				"is_audio": true,
				"type": "audio",
				"extension": "mp3"
			},
			{
				"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-30232.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&oi=86732298&gen=playurlv3&os=akam&nbs=1&mid=0&platform=pc&og=cos&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&upsig=b24197b6680d8c443800e84827d4c402&uparams=e,uipk,oi,gen,os,nbs,mid,platform,og,trid,deadline&hdnts=exp=1777806744~hmac=28f36b29c0d74e2c9153fe8a12e7fd78997e85e3217a8b90d076720e42aa52b2&bvc=vod&nettype=0&bw=95322&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2",
				"bandwidth": 95313,
				"mimeType": "audio/mp4",
				"codecs": "mp4a.40.2",
				"is_audio": true,
				"type": "audio",
				"extension": "mp3"
			},
			{
				"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&gen=playurlv3&platform=pc&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&oi=86732298&os=akam&og=hw&nbs=1&uipk=5&mid=0&upsig=e1cdacd366bfee0ee9072235e20cdaa0&uparams=e,gen,platform,trid,deadline,oi,os,og,nbs,uipk,mid&hdnts=exp=1777806744~hmac=9a819795fb9ea7624af5f970c4a37f57c3a7c638f2d2d513f38c40eaa6f5d6cf&bvc=vod&nettype=0&bw=194512&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&agrr=1&buvid=&orderid=0,2",
				"bandwidth": 194493,
				"mimeType": "audio/mp4",
				"codecs": "mp4a.40.2",
				"is_audio": true,
				"type": "audio",
				"extension": "mp3"
			}
		],
		"streams": {
			"video": [
				{
					"quality": "852x480",
					"bandwidth": 322374,
					"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-100047.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&platform=pc&deadline=1777806744&nbs=1&mid=0&oi=86732298&gen=playurlv3&trid=4edb0169c88349ed83a8434f1a5efceu&uipk=5&os=akam&og=cos&upsig=b968add5b339755c3c1c592d4bb1cbe4&uparams=e,platform,deadline,nbs,mid,oi,gen,trid,uipk,os,og&hdnts=exp=1777806744~hmac=c65e3139850f157db27dbe2fe537456351e389222da1d3c06ccf925dc25dba5f&bvc=vod&nettype=0&bw=322400&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2"
				},
				{
					"quality": "640x360",
					"bandwidth": 198391,
					"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-100046.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&nbs=1&uipk=5&gen=playurlv3&os=akam&og=ali&platform=pc&mid=0&oi=86732298&upsig=8e9d326d02b5cd8df64226a8588a6809&uparams=e,trid,deadline,nbs,uipk,gen,os,og,platform,mid,oi&hdnts=exp=1777806744~hmac=793519258ab45e796c26a0502f82c6ba1496681d16ecf3b06902b81dd0ca90f6&bvc=vod&nettype=0&bw=198406&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2"
				}
			],
			"audio": [
				{
					"quality": "mp4a.40.5",
					"bandwidth": 41943,
					"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-30216.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&mid=0&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&gen=playurlv3&os=akam&og=hw&nbs=1&uipk=5&oi=86732298&platform=pc&upsig=f9f2ff2e708b19bba1fbaf7177fd9520&uparams=e,mid,trid,deadline,gen,os,og,nbs,uipk,oi,platform&hdnts=exp=1777806744~hmac=93d2cebea576347ad11b5762e06b0aa69c0f101934885fb9546b6938337dcae1&bvc=vod&nettype=0&bw=41947&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2"
				},
				{
					"quality": "mp4a.40.2",
					"bandwidth": 95313,
					"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-30232.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&oi=86732298&gen=playurlv3&os=akam&nbs=1&mid=0&platform=pc&og=cos&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&upsig=b24197b6680d8c443800e84827d4c402&uparams=e,uipk,oi,gen,os,nbs,mid,platform,og,trid,deadline&hdnts=exp=1777806744~hmac=28f36b29c0d74e2c9153fe8a12e7fd78997e85e3217a8b90d076720e42aa52b2&bvc=vod&nettype=0&bw=95322&agrr=1&buvid=&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&orderid=0,2"
				},
				{
					"quality": "mp4a.40.2",
					"bandwidth": 194493,
					"url": "https://upos-hz-mirrorakam.akamaized.net/upgcxcode/69/09/1318890969/1318890969-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&gen=playurlv3&platform=pc&trid=4edb0169c88349ed83a8434f1a5efceu&deadline=1777806744&oi=86732298&os=akam&og=hw&nbs=1&uipk=5&mid=0&upsig=e1cdacd366bfee0ee9072235e20cdaa0&uparams=e,gen,platform,trid,deadline,oi,os,og,nbs,uipk,mid&hdnts=exp=1777806744~hmac=9a819795fb9ea7624af5f970c4a37f57c3a7c638f2d2d513f38c40eaa6f5d6cf&bvc=vod&nettype=0&bw=194512&build=0&dl=0&f=u_0_0&qn_dyeid=519f4b3e11f659cc00b123cc69f71178&agrr=1&buvid=&orderid=0,2"
				}
			]
		}
	}
}
```

***

### 🧠 How it works

This actor:

1. Extracts **BV ID** from input URL
2. Calls Bilibili metadata API:

   - `/x/web-interface/view`
3. Retrieves streaming data:

   - `/x/player/playurl`
4. Parses DASH video/audio streams
5. Deduplicates qualities
6. Returns best + all available streams

***

### ⚡ Use Cases

- Video downloading tools
- Media processing pipelines
- Dataset creation (Bilibili content archive)
- Streaming URL extraction
- FFmpeg automation systems

***

### 🛠 Tech Stack

- Node.js (ESM)
- Apify SDK
- Got HTTP client
- Bilibili public APIs

***

### 📊 Performance

- No browser required 🚀
- Low memory usage
- High concurrency support
- Fast API-based scraping

***

### ⚠️ Notes

- Video URLs are **time-limited (signed links)**
- You should download media before expiration
- Some videos may have restricted access depending on region or login requirements

***

### 📦 Output Fields Reference

| Field         | Description                    |
| ------------- | ------------------------------ |
| title         | Video title                    |
| duration      | Duration in seconds            |
| expiresAt     | URL expiration timestamp       |
| best          | Best available quality streams |
| streams.video | All video qualities            |
| streams.audio | All audio qualities            |

***

### 🔥 SEO Keywords (for Apify store)

bilibili scraper, bilibili downloader, bilibili video extractor, bilibili api, video downloader api, streaming url extractor, m4s downloader, bilibili dash stream, video scraping tool

# Actor input Schema

## `links` (type: `array`):

List of Bilibili video URLs

## Actor input object example

```json
{
  "links": [
    "https://www.bilibili.com/video/BV1hj411i7rX/"
  ]
}
```

# Actor output Schema

## `datasetItems` (type: `string`):

No description

## `datasetUrl` (type: `string`):

No description

## `totalItems` (type: `string`):

No description

## `runId` (type: `string`):

No description

## `successfulItems` (type: `string`):

No description

## `failedItems` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "links": [
        "https://www.bilibili.com/video/BV1hj411i7rX/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ahmed_jasarevic/bilibili-video-downloader").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "links": ["https://www.bilibili.com/video/BV1hj411i7rX/"] }

# Run the Actor and wait for it to finish
run = client.actor("ahmed_jasarevic/bilibili-video-downloader").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "links": [
    "https://www.bilibili.com/video/BV1hj411i7rX/"
  ]
}' |
apify call ahmed_jasarevic/bilibili-video-downloader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=ahmed_jasarevic/bilibili-video-downloader",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Bilibili Video Downloader & Stream Extractor (Cheapest)",
        "description": "Extracts Bilibili video metadata, available video/audio streams, and generates ffmpeg merge commands for downloading videos in multiple qualities.",
        "version": "1.0",
        "x-build-id": "nIXljXfswwGEVlnOi"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/ahmed_jasarevic~bilibili-video-downloader/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-ahmed_jasarevic-bilibili-video-downloader",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/ahmed_jasarevic~bilibili-video-downloader/runs": {
            "post": {
                "operationId": "runs-sync-ahmed_jasarevic-bilibili-video-downloader",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/ahmed_jasarevic~bilibili-video-downloader/run-sync": {
            "post": {
                "operationId": "run-sync-ahmed_jasarevic-bilibili-video-downloader",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "links"
                ],
                "properties": {
                    "links": {
                        "title": "Video Links",
                        "type": "array",
                        "description": "List of Bilibili video URLs",
                        "items": {
                            "type": "string"
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
