# Bilibili Video Downloader (`scrapers-hub/bilibili-video-downloader`) Actor

🚀 Bilibili Video Downloader (bilibili-video-downloader) lets you download Bilibili videos fast and easily—save offline in high quality. 📥 Supports simple, secure workflows for creators and viewers. 🎬 Try it today.

- **URL**: https://apify.com/scrapers-hub/bilibili-video-downloader.md
- **Developed by:** [Scrapers Hub](https://apify.com/scrapers-hub) (community)
- **Categories:** Videos, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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: The Ultimate Metadata and Media Extraction Tool 🚀

In the rapidly evolving landscape of digital content, Bilibili has emerged as a cornerstone of global video sharing, particularly within the ACG (Anime, Comic, and Games) community and the burgeoning field of educational and professional content in Asia. 🌏 To navigate this vast ocean of data, developers, researchers, and content creators require a tool that is not only powerful but also precise and reliable. ⚓ The **Bilibili Video Downloader** is that tool—a professional-grade Apify actor engineered to bridge the gap between Bilibili's complex infrastructure and your data needs. 🌉

This documentation provides an exhaustive guide to the Bilibili Video Downloader, covering everything from basic configuration to advanced technical nuances. 📚 By leveraging industry-standard extraction libraries like `yt-dlp` and integrating seamlessly with the Apify platform's robust proxy and scaling capabilities, this actor ensures that you can extract high-fidelity video metadata, DASH stream links, and subtitles with unparalleled ease. 🚄

---

### ✨ Key Features and Capabilities 🛠️

The Bilibili Video Downloader is built with a focus on depth and accuracy. It doesn't just "scrape" a page; it performs a deep inspection of Bilibili's internal API responses to provide a complete picture of every video.

#### 1. 📊 High-Fidelity Metadata Extraction
The actor captures a wide array of metadata points, ensuring that you have all the context needed for analysis or archiving:
- 📌 **Core Info**: Video ID (BVID), Title, Description, and Thumbnail URLs.
- 📈 **Engagement Metrics**: Real-time View Counts, Like Counts, and Comment Counts.
- ⏱️ **Temporal Data**: Exact video duration and upload timestamps.
- 🏷️ **Categorization**: Full lists of video tags and categories.

#### 2. 🎥 Advanced DASH Stream Recovery
Unlike simple downloaders that only provide a single MP4 link, this tool extracts the full suite of DASH (Dynamic Adaptive Streaming over HTTP) formats. This includes:
- 🧩 **Multiple Codecs**: Support for AVC (H.264), HEVC (H.265), and the cutting-edge AV1.
- 📺 **Resolution Variety**: From 360P mobile-optimized streams to breathtaking 4K Ultra HD.
- ⚡ **Bitrate Precision**: Detailed bitrate information for both video and audio tracks, allowing you to choose the perfect balance between quality and file size.
- 🎵 **Separate Tracks**: Independent access to high-quality audio streams (AAC, FLAC where available).

#### 3. 💬 Comprehensive Subtitle Support
Bilibili is a global platform, and its content often features multilingual subtitles. Our downloader identifies and extracts:
- 📜 **Internal Subtitles**: Official subtitles provided by the uploader.
- 🤖 **Auto-Generated Captions**: Machine-translated or AI-generated captions where available.
- 🌐 **Multiple Languages**: Support for Chinese (Simplified/Traditional), English, Japanese, and more.

#### 4. 👤 Creator and Channel Insights
Understanding the source is as important as the content. The actor provides:
- 📛 **Uploader Name**: The display name of the content creator.
- 🆔 **Uploader ID**: The unique MID (Member ID) for the creator's profile.
- 🔗 **Channel Links**: Direct URLs to the creator's Bilibili space.

#### 5. 🏗️ Production-Ready Infrastructure
Built to run on the Apify platform, the actor benefits from:
- 🌐 **Proxy Integration**: Full support for Apify Proxy, including Residential and Datacenter groups, to ensure high success rates and bypass geo-restrictions.
- 📦 **Batch Processing**: The ability to process hundreds or thousands of URLs in a single run.
- 🛠️ **Robust Error Handling**: Sophisticated retry logic and error reporting to ensure your jobs finish even when faced with temporary network issues.

---

### ⚙️ Input and Output Configuration 📋

This section details the structure of the data you provide to the actor and the structured JSON data it returns. Proper configuration is key to maximizing the efficiency of your scraping tasks.

#### Input Parameters

The Bilibili Video Downloader uses a streamlined input schema designed for both ease of use and flexibility.

| Field | Type | Description | Required | Default |
|-------|------|-------------|----------|---------|
| `urls` | Array | A list of Bilibili video URLs (e.g., `https://www.bilibili.com/video/BV...`). | **Yes** | `[]` |
| `proxyConfiguration` | Object | Standard Apify Proxy configuration settings. Allows you to specify proxy groups (e.g., RESIDENTIAL) and country-specific exit nodes. | No | `{ "useApifyProxy": true }` |

#### JSON Input Example

```json
{
  "urls": [
    "https://www.bilibili.com/video/BV1hj411i7rX/",
    "https://www.bilibili.com/video/BV1uT411P79x/"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
````

#### Output Data Structure

The actor outputs a list of objects to the Apify dataset. Each object represents a single video and contains the following fields:

| Field | Type | Description |
|-------|------|-------------|
| `id` | String | The Bilibili video identifier (e.g., "BV1hj411i7rX"). |
| `title` | String | The full title of the video. |
| `description` | String | The video's description text (supports multi-line). |
| `thumbnail` | String | A high-resolution URL for the video thumbnail. |
| `duration` | Integer | Total length of the video in seconds. |
| `view_count` | Integer | The number of views at the time of scraping. |
| `like_count` | Integer | The number of likes. |
| `comment_count` | Integer | The number of comments. |
| `upload_date` | Integer | Unix timestamp of the video upload. |
| `uploader` | String | The username of the video uploader. |
| `uploader_id` | String | The unique numerical ID of the uploader. |
| `uploader_url` | String | Link to the uploader's Bilibili Space. |
| `medias` | Array | A list of DASH stream objects (video and audio). |
| `subtitles` | Object | A map of available subtitles by language code. |
| `tags` | Array | A list of strings representing the video's tags. |
| `url` | String | The original URL processed. |
| `source` | String | Always "bilibili". |
| `error` | Boolean | Whether an error occurred during processing. |

#### JSON Output Example

Below is a truncated example of the output generated for a high-quality video:

```json
{
  "id": "BV1hj411i7rX",
  "title": "【bilibili超级科学晚】全程回顾（上）",
  "description": "这里是，bilibili超级科学晚。\n实验，是检验科技的唯一标准。",
  "thumbnail": "http://i0.hdslb.com/bfs/archive/848f6f5517e2fac24da4da7c912a6187923defbe.jpg",
  "duration": 5966,
  "view_count": 2182089,
  "like_count": 22447,
  "comment_count": 354,
  "upload_date": 1698496200,
  "uploader": "哔哩哔哩弹幕网",
  "uploader_id": "8047632",
  "uploader_url": "https://space.bilibili.com/8047632",
  "medias": [
    {
      "format_id": "dash-video-80-avc",
      "url": "https://upos-hz-mirrorakam.akamaized.net/...",
      "extension": "m4s",
      "width": 1920,
      "height": 1080,
      "fps": "30",
      "vcodec": "avc1.640032",
      "acodec": "none",
      "quality": "1080P AVC",
      "type": "video"
    },
    {
      "format_id": "dash-audio-30216",
      "url": "https://upos-hz-mirrorakam.akamaized.net/...",
      "extension": "m4s",
      "quality": "41kbps",
      "type": "audio"
    }
  ],
  "tags": ["bilibili超级科学晚", "科技", "科普"],
  "url": "https://www.bilibili.com/video/BV1hj411i7rX/",
  "source": "bilibili",
  "error": false
}
```

***

### 🧬 Technical Architecture and Extraction Logic 💻

The Bilibili Video Downloader is not just a wrapper; it is a sophisticated extraction engine that handles the intricacies of modern web video delivery.

#### The Power of yt-dlp

At its core, the actor utilizes `yt-dlp`, the gold standard for video extraction. We have customized the configuration to handle Bilibili's specific security measures, including:

- 🖥️ **Custom User-Agents**: Mimicking modern web browsers to avoid "412 Precondition Failed" errors.
- 🔑 **Header Injection**: Providing appropriate `Referer` and `Origin` headers to satisfy Bilibili's CORS and anti-hotlinking policies.
- 📡 **Protocol Handling**: Correctly parsing DASH manifests to reconstruct high-quality media streams.

#### Codec and Quality Mapping

Bilibili provides multiple versions of the same video to ensure compatibility across devices. Our actor maps these to a standardized quality system:

- 🎞️ **AVC (Advanced Video Coding)**: Maximum compatibility, standard quality.
- 🚀 **HEVC (High Efficiency Video Coding)**: Superior compression, used for 4K and HDR content.
- 💎 **AV1**: The latest in open-source video compression, providing the highest quality at the lowest bitrate.

The actor automatically classifies streams into quality tiers (360P, 480P, 720P, 1080P, 4K) based on the height and internal quality numbers (QN) used by Bilibili.

#### Handling Asynchronous Operations

The scraper is built using Python's `asyncio` library. This allows it to:

- 🏎️ **Concurrent Processing**: Process multiple URLs in parallel (where allowed by platform limits).
- 🔄 **Non-blocking Retries**: Perform retries for failed requests without halting the entire scraping job.
- 🍃 **Efficient Resource Usage**: Minimal CPU and memory overhead compared to browser-based scrapers.

***

### 🛡️ Proxy Configuration and Anti-Blocking 🌐

Scraping Bilibili at scale requires a sophisticated approach to network management. Bilibili employs several layers of protection, including rate limiting and geo-fencing.

#### Why You Need Proxies

1. 🛑 **Rate Limiting**: Making too many requests from a single IP address will lead to temporary bans or CAPTCHAs.
2. 🗺️ **Geo-Restrictions**: Some content on Bilibili is restricted to specific regions (primarily Mainland China). Using a proxy with the correct exit node can bypass these limits.
3. 💎 **Data Integrity**: Proxies ensure that you are seeing the content as a regular user would, avoiding "shadow-banning" of your IP.

#### Apify Proxy Integration

The actor is fully integrated with Apify Proxy. We recommend the following settings for optimal performance:

- 🏠 **Residential Proxies**: These are the most reliable as they use IP addresses assigned to real households, making them nearly impossible to distinguish from genuine traffic.
- 🤖 **Automatic Group Selection**: Apify's smart proxy selection can automatically choose the best group for your needs.

#### Professional Best Practices

To ensure your scraper remains undetected and efficient:

- ⏳ **Randomized Delays**: The actor includes built-in random delays between requests to mimic human behavior.
- 🎭 **Rotating Identities**: By using a pool of proxies, the actor rotates its "identity" for every request, preventing pattern recognition by Bilibili's anti-bot systems.

***

### 🌟 Common Use Cases 📂

The Bilibili Video Downloader is used by a diverse range of professionals for various applications:

- 📚 **Media Archiving and Preservation**: Digital historians and hobbyists use the tool to save high-quality versions of videos that might otherwise be removed or censored.
- 📊 **Market and Content Analysis**: Marketing teams analyze view counts, likes, and tags to understand trending topics on Bilibili.
- 🎓 **Academic Research**: Sociologists and linguists use the metadata and subtitles for large-scale studies on cultural trends.
- 🤖 **AI and Machine Learning Training**: Developers use the extracted data to train recommendation algorithms.

***

### ⚡ Performance and Scalability 📈

When running large-scale scraping jobs, performance is paramount. The Bilibili Video Downloader is optimized for high-throughput operations.

#### Batch Processing

The actor can take a large list of URLs as input. Instead of starting a new actor for every video, it iterates through the list, reusing connections and maintaining efficiency.

#### Scaling on Apify

You can scale your scraping operations by:

- **Increasing Memory**: Allocating more memory to the actor allows it to handle larger datasets and more concurrent operations.
- **Parallel Runs**: Running multiple instances of the actor simultaneously to process tens of thousands of URLs in a fraction of the time.

***

### 🔗 Integration and API Usage 🔌

The Bilibili Video Downloader is designed to be a building block in your larger data pipeline.

#### Calling via Apify API

You can trigger the actor programmatically using a simple POST request:

```bash
curl --request POST \
  --url https://api.apify.com/v2/acts/YOUR_ACTOR_ID/runs?token=YOUR_TOKEN \
  --header 'Content-Type: application/json' \
  --data '{
    "urls": ["https://www.bilibili.com/video/BV1hj411i7rX/"]
  }'
```

#### Webhooks for Automation

Set up webhooks to automatically notify your backend systems when a scraping job is complete. This allows for fully automated data ingestion pipelines.

***

### 🛠️ Error Handling and Troubleshooting 🔍

Even the best scrapers encounter issues. Here's how the Bilibili Video Downloader handles them:

#### Common Error Messages

- 🚫 **"Video unavailable"**: The video may have been deleted, set to private, or restricted in your proxy's region.
- 🛑 **"412 Precondition Failed"**: Bilibili has detected the scraper. Try switching to Residential proxies or reducing the frequency of requests.
- ⏲️ **"Timeout"**: The network connection was lost. The actor will automatically retry up to 3 times before giving up.

#### Troubleshooting Steps

1. 🛡️ **Check Your Proxies**: Ensure your Apify Proxy subscription is active and that you have enough data.
2. ✅ **Verify URLs**: Ensure the URLs are correct and follow the `bilibili.com/video/BV...` format.
3. 📜 **Review Logs**: The actor provides detailed logs in the Apify console. Look for specific error messages from `yt-dlp`.

***

### 🤔 Why Choose Bilibili Video Downloader? 🏆

In a market saturated with browser extensions and generic "all-in-one" video downloaders, the **Bilibili Video Downloader** stands out as a specialized, server-side solution. Here’s why professional users prefer this actor over other alternatives:

#### 1. 🏗️ Server-Side Reliability

Browser extensions are often brittle, breaking every time Bilibili updates its frontend. 🧩 Because our actor interacts with Bilibili's underlying data streams and APIs, it is far more resilient to UI changes. 🛡️ Furthermore, running on Apify's infrastructure means you don't need to keep your computer on; the actor runs in the cloud, handling heavy lifting and large batches while you focus on other tasks. ☁️

#### 2. 📺 High-Resolution DASH Support

Many generic downloaders only grab the "legacy" MP4 stream, which is often capped at 720P or has poor bitrate. 📉 Bilibili uses DASH (Dynamic Adaptive Streaming over HTTP) to deliver its high-quality content. 🎥 Our tool is specifically designed to parse these complex manifests, giving you access to the true 1080P, 4K, and high-frame-rate (60FPS) versions that other tools miss. 💎

#### 3. 🚫 No Installation Required

There’s no need to install shady software or bloatware on your machine. 💻 Everything happens within the secure, sandboxed environment of the Apify platform. 🔒 This is particularly important for corporate users and researchers who must adhere to strict security protocols. 📑

#### 4. 📊 Comprehensive Metadata, Not Just Video

Most tools only give you a video file. 🎞️ We give you the entire context. 🧠 Knowing the view count, tags, and uploader history is often just as valuable as the video itself for data scientists and market researchers. 📉

***

### 📖 Detailed Step-by-Step Guide for New Users 🚀

If you are new to the Apify platform or web scraping in general, follow this guide to get your first dataset in minutes.

#### Step 1: Sign up for an Apify Account 👤

Visit [Apify.com](https://apify.com) and create a free account. You will receive a starting balance of trial credits that you can use to run this actor. 🎁

#### Step 2: Navigate to the Bilibili Video Downloader 🔍

Search for "Bilibili Video Downloader" in the Apify Store. Once you’re on the actor page, click "Try for free." 🚀

#### Step 3: Configure Your Input ⌨️

In the "Input" tab, you will see a field for "Bilibili Video URLs." Copy and paste the URLs of the videos you want to scrape. You can enter one URL per line or provide them as a JSON array. 📋

- **Example URL**: `https://www.bilibili.com/video/BV1hj411i7rX/`

#### Step 4: Set Up Proxies (Optional but Recommended) 🛡️

For a few videos, the default settings will work fine. However, if you are scraping more than 10-20 videos, go to the "Proxy configuration" section and select "Residential." This ensures your requests are not blocked by Bilibili. 🌐

#### Step 5: Click "Run" ▶️

Hit the big green "Run" button at the bottom of the page. The actor will start up, and you can watch the live logs as it processes each URL. ⚙️

#### Step 6: Download Your Data 📥

Once the status changes to "Succeeded," go to the "Dataset" tab. Here, you can preview your data and export it in your preferred format: JSON, CSV, Excel, XML, or even HTML table. 📊

***

### 🔒 Data Security and Privacy Compliance 📑

We take data privacy and security seriously. When using the Bilibili Video Downloader, you can rest assured that:

- 🛡️ **No Personal Data Stored**: The actor does not store any of your personal Bilibili account information. It operates entirely on publicly available data unless you explicitly provide session cookies (advanced feature). 🕵️
- 🔒 **Secure Infrastructure**: All scraping occurs within Apify's SOC 2 Type II compliant infrastructure. Your input URLs and output data are encrypted at rest and in transit. 🔐
- 📜 **Compliance with Robots.txt**: While the actor is designed to be efficient, we encourage users to follow ethical scraping practices and respect the `robots.txt` files and rate limits of the target platform. ⚖️

***

### 🌍 Bilibili's Content Ecosystem: What Can You Extract? 📺

Bilibili is more than just a "Chinese YouTube." It is a cultural phenomenon with a unique structure. Understanding this ecosystem helps you make the most of the data you extract.

#### 🧠 The Rise of "Knowledge" Content

In recent years, Bilibili has seen a massive surge in educational content. 🎓 From university-level mathematics to professional software engineering tutorials, the "Knowledge" partition is one of the most active on the site. 📚 Researchers use our tool to archive these tutorials before they are moved behind paywalls. 🔓

#### 🎭 Virtual YouTubers (VTubers)

Bilibili is a primary hub for VTubers. 🦊 The metadata extracted by our tool—particularly engagement metrics like likes and comments—is used by talent agencies to track the performance of their virtual idols and understand audience sentiment. 📊

#### 🎞️ PGC vs. UGC

The platform features both Professional Generated Content (PGC) like officially licensed anime and User Generated Content (UGC). 🎥 Our downloader is optimized for UGC, providing deep insights into the creative output of millions of independent creators. 🎨

***

### 💡 Advanced Proxy Tips: Country-Specific Scraping 🗺️

For users with specific needs, Apify Proxy allows for granular control over your exit nodes.

#### Bypassing "Not Available in Your Region"

If you encounter videos that are only viewable in Mainland China, you can configure the actor to use a proxy located in China. In the `proxyConfiguration` object, you can specify the country:

```json
{
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"],
    "targetCountry": "CN"
  }
}
```

#### Improving Speed with Datacenter Proxies

If you are scraping non-restricted, public videos and need high speed at a lower cost, Datacenter proxies are a viable option. However, be aware that Bilibili is more likely to challenge these IPs with CAPTCHAs.

***

### 🛠️ Extending the Actor for Custom Needs 🧩

The Bilibili Video Downloader is built on a modular Python codebase. If you are a developer, you can extend its functionality in several ways:

#### 1. Adding Custom Metadata Fields

By modifying the `map_format` and `main.py` files, you can extract additional fields from the `yt-dlp` info dictionary, such as "chapters," "heatmaps," or "live status."

#### 2. Integration with Cloud Storage

You can modify the actor to automatically upload the extracted media files to an S3 bucket or Google Cloud Storage instead of just providing the URLs.

#### 3. Sentiment Analysis Pipeline

Connect the output of this actor to a Natural Language Processing (NLP) actor to perform real-time sentiment analysis on the video descriptions and comments.

***

### Frequently Asked Questions (FAQ) - Continued

#### Can I extract "Bullet Comments" (Danmaku)? 💬

Currently, this actor focuses on video metadata and media streams. Danmaku extraction is a complex task due to the high volume of comments and their unique XML format. This feature is on our roadmap for future updates. 🗺️

#### Does it support 60FPS or HDR? 📺

Yes! If the uploader has provided a 60FPS or HDR version, the actor will identify and extract the corresponding DASH streams. Look for these details in the `format_note` or `quality` fields of the `medias` array. ✨

#### Why are some media URLs expiring? ⏱️

Bilibili's media URLs are signed with a temporary token. They are intended for immediate use. If you need to access the video later, you should download the media file to your own storage immediately after scraping. 💾

***

### 💰 Pricing and Resources 💎

The Bilibili Video Downloader is available on the Apify platform. Usage is billed based on:

- **Compute Units**: The amount of CPU and RAM used during the run.
- **Proxy Data**: The volume of data transferred through Apify Proxy.

#### Trial Credits

Every new Apify user gets $5 in trial credits every month. This is enough to scrape hundreds of Bilibili videos for free.

#### Support and Custom Development

For issues, feature requests, or custom scraper development, please contact the developer or open an issue in the project repository. We offer bespoke scraping solutions for enterprise clients with unique data requirements.

Happy scraping!

# Actor input Schema

## `urls` (type: `array`):

List of Bilibili video URLs to scrape.

## Actor input object example

```json
{
  "urls": [
    "https://www.bilibili.com/video/BV1wPLQ64EDi/"
  ]
}
```

# 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 = {
    "urls": [
        "https://www.bilibili.com/video/BV1wPLQ64EDi/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapers-hub/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 = { "urls": ["https://www.bilibili.com/video/BV1wPLQ64EDi/"] }

# Run the Actor and wait for it to finish
run = client.actor("scrapers-hub/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 '{
  "urls": [
    "https://www.bilibili.com/video/BV1wPLQ64EDi/"
  ]
}' |
apify call scrapers-hub/bilibili-video-downloader --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Bilibili Video Downloader",
        "description": "🚀 Bilibili Video Downloader (bilibili-video-downloader) lets you download Bilibili videos fast and easily—save offline in high quality. 📥 Supports simple, secure workflows for creators and viewers. 🎬 Try it today.",
        "version": "0.1",
        "x-build-id": "M3ae4l4umhCT8VleY"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scrapers-hub~bilibili-video-downloader/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scrapers-hub-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/scrapers-hub~bilibili-video-downloader/runs": {
            "post": {
                "operationId": "runs-sync-scrapers-hub-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/scrapers-hub~bilibili-video-downloader/run-sync": {
            "post": {
                "operationId": "run-sync-scrapers-hub-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",
                "properties": {
                    "urls": {
                        "title": "Bilibili Video URLs",
                        "type": "array",
                        "description": "List of Bilibili video URLs to scrape.",
                        "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
