Communitygithub.com

sunrisever/bilibili-favorites

Export Bilibili favorites, classify with ChatGPT/Claude/Gemini or other frontier LLMs, then sync folders back | 导出B站收藏夹,交给ChatGPT/Claude/Gemini等通用大模型分类,再同步回文件夹

bilibili-favorites 是什么?

bilibili-favorites is a Claude Code agent skill that export Bilibili favorites, classify with ChatGPT/Claude/Gemini or other frontier LLMs, then sync folders back | 导出B站收藏夹,交给ChatGPT/Claude/Gemini等通用大模型分类,再同步回文件夹.

兼容平台✓Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add sunrisever/bilibili-favorites

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

bilibili-favorites 是做什么的?

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

相关技能