# Turn a Bilibili JSON export into a creator review sheet with Python

A video search export gives you video rows. If you want to review the creators behind those videos, counting display names isn't enough: one creator can appear several times, and different people can use the same name.

In an existing 20-video mechanical-keyboard search test, grouping by creator ID produced 19 groups. That is the number of creators represented in the file, not the number of keyboard creators on Bilibili. I hadn't fetched their profiles or full upload histories.

I maintain the paid Bilibili Scraper on Apify and the companion analysis code used here. This walkthrough starts offline. You can run the included synthetic fixture without an Apify account or a paid collection, then import an export you are allowed to process.

<https://github.com/lexang/bilibili-data-analysis>

## Run the synthetic fixture first

Download the repository. From its directory, using Python 3.10 or later:

```shell
python analyze.py
python -m unittest -v test_example
```

The script reads `data/synthetic-videos.json` and creates a new `output` directory. CSV export uses Python's standard library. The tests block real socket connections; without the optional Excel dependencies, the Excel test is skipped.

The nine fabricated records include a duplicate video ID, a non-video record and an invalid identifier. Six video-format records survive validation and deduplication, producing four creator-ID groups and three video review rows. These counts exercise the code, not a research finding. Synthetic video and profile links stay blank, and the outputs carry `is_synthetic` markers.

The script refuses to overwrite an existing output directory. For a second run, choose a new one:

```shell
python analyze.py --output-dir second-analysis
```

## Keep the grouping key separate from the name

The first pass keeps the first record for each valid `bvid`. Later duplicates are skipped, not merged into a newer snapshot. The creator pass groups those unique video rows by `authorMid`, the numeric creator ID. Bilibili calls a creator an `UP主`.

Two records in the synthetic fixture share a display name but have different creator IDs. They remain separate groups. Two videos with the same ID go into the same group even if a display name changes. Names are labels for review, not identity keys.

Creator IDs remain strings in the tables. The fixture includes IDs above JavaScript's safe-integer range to check that export handling preserves them. That doesn't mean real Bilibili IDs need to be that large. If another tool has already rounded an ID, converting it to a string cannot restore the original digits.

## Read the creator table with its coverage columns

Open `creators.csv`. It is a summary of this input file, not a fetched creator profile.

| Column | What it tells you |
| --- | --- |
| `sample_video_count` | Unique videos assigned to this ID in the file |
| `observed_views_sum` | Sum of available, valid view counts |
| `videos_with_views` | Number of videos contributing to that sum |
| `observed_likes_sum`, `videos_with_likes` | The corresponding observed like sum and coverage |
| `representative_bvid`, `representative_views` | The group's highest-view video among measured rows; an ID tie-breaker makes the choice deterministic |
| `profile_url`, `profile_status` | For imported data, a URL constructed from the ID, marked as not visited |

The synthetic two-video group has 2,000 and 800 views, so its observed sum is 2,800 with coverage of two videos. One like count is missing, so its like sum covers only one video. Another group has no measured view count; its sum is blank. A valid zero stays zero.

Read a sum together with its coverage. It cannot tell you the creator's total views, follower count, unique audience or sales. The table sorts by observed sample view sums for convenience; that order is not an influencer recommendation.

`has_review_candidate` means the group has at least one video meeting the example's 1,000-view threshold. It does not mean the creator has been checked for audience fit. The separate `review.csv` also requires a known favorites count and orders video rows by favorites/views. These are different checks; neither establishes commercial suitability.

## Import your own JSON without collecting again

Provide a JSON array with the Actor's video fields, including `type`, `bvid` and `authorMid`:

```shell
python analyze.py --input path/to/videos.json --output-dir imported-analysis
```

The script reads that file without visiting the video or creator links. It rejects files mixing synthetic and unmarked records. Do not add `is_synthetic: true` to real data.

The original author-test file produced 20 unique video rows, 19 creator groups and 10 video review rows. Those are historical offline results, not a new collection or customer case. The repository deliberately excludes that file and its real-data CSV/Excel outputs. Its bundled fixture is a separate fabricated dataset.

Before treating any row as a creator candidate, open the permitted source links yourself. Check the topic, publication date, recent relevant uploads and any disclosed commercial relationship. None of those checks has been completed by this script. A generated profile URL isn't proof that the profile is available.

## Add Excel when you need it

CSV output uses UTF-8 with a BOM. Formula-like external text gets an apostrophe prefix in exported tables; the source JSON remains unchanged. Excel is an optional output using the repository's pinned dependencies:

```shell
python -m pip install -r requirements-excel.txt
python analyze.py --excel --output-dir excel-analysis
```

Dependency installation downloads packages; it does not start the Actor. The workbook contains `videos`, `review` and `creators` sheets alongside the CSV files. Check `summary.json` for the source hash, missing-count audit and whether the input was synthetic or imported.

## If you need a new export

The paid Actor can collect public video metadata. Running it normally requires an Apify account, but you supply no Bilibili account login cookies; it manages guest cookies internally. Video and creator-profile records each cost $0.002, or $2 per 1,000, with platform usage included for the run. Exactly 20 returned videos at that listed price cost $0.04. Check the Store price, permissions and charge limit before a collection.

<https://apify.com/zlexang/bilibili-scraper-no-login>

For the earlier keyword-search walkthrough, including the limits of the 20-video relevance sample:

<https://lexang.hashnode.dev/sorting-bilibili-videos-with-python-a-20-result-keyboard-research-sample>

No new run is needed to follow this article. The metadata tool does not download videos, subtitles or comment text. Public visibility doesn't grant redistribution, commercial-use or AI-training rights; assess your intended use before storing or sharing an export. Start by checking what is actually in the file and which creator facts are still missing.
