Communitygithub.com

sunrisever/bilibili-favorites

Export Bilibili favorites, classify them with ChatGPT/Claude/Gemini or other frontier LLMs, then sync the organized folders back.

What is bilibili-favorites?

This skill automates the management of Bilibili (B站) user favorites by exporting them and leveraging advanced large language models (LLMs) such as ChatGPT, Claude, or Gemini for intelligent classification. It is designed for developers and power users who want to organize large collections of bookmarked videos without manual effort. The tool supports exporting favorites data, sending each item to an LLM for categorization, and then syncing the newly structured folders back to Bilibili. It works as a standalone CLI command or can be integrated into AI agent platforms like Claude Code or Codex. The workflow involves configurable prompts and API keys, making it flexible for different classification needs. This skill is especially useful for content creators, researchers, or anyone who curates Bilibili content and needs an efficient way to sort and access their favorites.

Works with✓Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add sunrisever/bilibili-favorites

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

What does bilibili-favorites do?

Export Bilibili favorites, classify them with ChatGPT/Claude/Gemini or other frontier LLMs, then sync the organized folders back.

Overview

This tool helps you take control of your Bilibili favorites by automatically exporting them, using a powerful LLM (like ChatGPT, Claude, or Gemini) to intelligently categorize each video based on its title and description, and then syncing the resulting folders back to your Bilibili account. The entire process is configurable, allowing you to define custom classification prompts.

Requirements

  • Python 3.9+
  • A Bilibili account with favorites to manage
  • An API key for one of the supported LLMs (OpenAI, Anthropic, Google AI, or any compatible API)

Installation

pip install bilibili-favorites

Configuration

Create a .env file in your working directory or set the following environment variables:

BILIBILI_SESSDATA=your_bilibili_sessdata
LLM_API_KEY=your_llm_api_key
LLM_MODEL=gpt-4-turbo  # or claude-3-opus-20240229, gemini-pro, etc.

Note: To obtain your Bilibili SESSDATA, log in to bilibili.com, open your browser's developer tools, go to the Application tab, find the Cookies for bilibili.com, and copy the value of the SESSDATA cookie.

Usage

Step 1: Export all favorites

bilibili-favorites export

This will save your favorites to a local JSON file.

Step 2: Classify with an LLM

bilibili-favorites classify --prompt "Categorize these Bilibili videos into topics like technology, gaming, music, education, and entertainment. Group similar topics together."

You can also provide a custom prompt file:

bilibili-favorites classify --prompt-file my_prompt.txt

Step 3: Sync folders back to Bilibili

bilibili-favorites sync

This will create or update folders in your Bilibili account according to the LLM's classification.

Configuration Options

OptionDescriptionDefault
BILIBILI_SESSDATAYour Bilibili session cookieRequired
LLM_API_KEYAPI key for the LLM providerRequired
LLM_MODELModel identifier (e.g., gpt-4-turbo, claude-3-opus-20240229, gemini-pro)gpt-4-turbo
LLM_BASE_URLBase URL for the LLM API (for custom endpoints)Optional
OUTPUT_DIRDirectory for exported data./bilibili_favorites

Custom Prompts

To tailor the classification to your needs, provide a custom prompt. The prompt should instruct the LLM on how to categorize videos. For example:

You are a Bilibili content organizer. Given the following video title and description, assign it to exactly one of these categories:
- Technology & Programming
- Gaming & Esports
- Music & Dance
- Education & Knowledge
- Entertainment & Lifestyle
- Animation & Comics

Respond with only the category name, nothing else.

Troubleshooting

  • Authentication errors: Ensure your BILIBILI_SESSDATA is correct and not expired. Re-log in to Bilibili and update it if necessary.
  • LLM API errors: Double-check your LLM_API_KEY and that the model name is correct. For Claude or Gemini, verify the API endpoint.
  • Sync failures: Some Bilibili folders have limits on the number of videos. If a folder exceeds the limit, the sync may fail. Try reducing the number of categories or splitting large categories.

License

MIT

Related Skills