Skip to content

Commit 5667d9e

Browse files
committed
Rename numeric-prefixed pipeline scripts to clean module names
The 00_/01_/02_/03_/05_ prefixes read like a course assignment and can never be imported as modules (an identifier can't start with a digit). Renamed: 00_resolve_creators.py -> resolve_creators.py 01_fetch_videos.py -> fetch_videos.py 02_classify_and_stats.py -> classify_and_stats.py 03_subtitle.py -> subtitle.py 05_comments.py -> comments.py These are standalone steps run as files (not imported, and not in viralens.py's subprocess pipeline, which dispatches fetch_multi / compare_form / etc.). All references were string mentions in docs/comments — README.md and the headers/ cross-references in resolve_creators.py, fetch_videos.py, classify_and_stats.py, subtitle.py, comments.py, creators.py, fetch_bilibili.py — all updated. Verified: no numeric-prefix tokens remain anywhere, compileall passes, `viralens --help` works.
1 parent 430ccaf commit 5667d9e

8 files changed

Lines changed: 16 additions & 16 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ python scripts/compare_meme.py # (opt-in, slow) cross-creator comment-enga
185185
python scripts/fetch_covers.py # (opt-in, slow) cover-image metrics
186186
```
187187

188-
Don't know a Bilibili creator's UID? Run `python scripts/00_resolve_creators.py` — it searches by
188+
Don't know a Bilibili creator's UID? Run `python scripts/resolve_creators.py` — it searches by
189189
name and prints the top candidates by follower count so you pick the real account, not an impersonator.
190190

191191
---
@@ -216,7 +216,7 @@ creators.py ──▶ fetch_multi.py ──▶ data/<alias>_videos.json (
216216
- **Signal scanner** (`scan_signals`): turns each video into a universal feature vector, then auto-tests
217217
every dimension (title patterns, length buckets, daypart, cover metrics…) for high/low-play separation,
218218
ranks by effect size, and reports which levers are *universal* vs *creator-specific*.
219-
- **L2 — text** (`03_subtitle`, `05_comments`): subtitles + hot comments → `jieba` keyword analysis.
219+
- **L2 — text** (`subtitle`, `comments`): subtitles + hot comments → `jieba` keyword analysis.
220220
- **Cross-creator / cross-zone gate**: a pattern earns a ✅ only if it survives the *same test* on
221221
multiple independent creators **and** more than one zone.
222222

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
viralens · 02_classify_and_stats.py
2+
viralens · classify_and_stats.py
33
读 bidao_videos.json,自动给视频打类型标签,按多个维度算对比统计。
44
纯本地,零成本,零网络。
55
6-
跑: python 02_classify_and_stats.py
6+
跑: python classify_and_stats.py
77
88
输出:
99
- data/classified.json (每个视频加了 type / 派生指标字段)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
2-
viralens · 05_comments.py
2+
viralens · comments.py
33
抓 pilot 10 个视频(2025正经科普 高5+低5)的热评,做三类成分分析:
44
共同 = 跨视频高频词(创作者标签性反馈,如"涨知识""哈哈哈")
55
典型 = 单视频 TF-IDF top 词(这条视频独有的记忆点)
66
差异 = 高播放组 vs 低播放组 词频差(观众"买账/不买账"时各说什么)
77
88
依赖: bilibili-api-python jieba
99
SESSDATA: 从 config_local.py 读(不进 git)
10-
跑: python 05_comments.py
10+
跑: python comments.py
1111
输出: data/comments_raw.json + data/comment_components.json + 终端三类成分
1212
"""
1313
import asyncio

scripts/creators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
⚠️ 跨平台别混用 zone:B站和 YouTube 受众体量不同,给 YouTube 用各自的 zone 名
1414
(例:B站知识区写 "知识",YouTube 科普写 "STEM-YT"),否则基准就是在跨平台硬比。
1515
—— Bilibili 专用 ——
16-
uid B站用户 UID(数字)。留 None 由 00_resolve_creators.py 按 name 搜索补全
16+
uid B站用户 UID(数字)。留 None 由 resolve_creators.py 按 name 搜索补全
1717
—— YouTube 专用 ——
1818
channel "@handle"(推荐,稳定可核对) / "UCxxxx频道ID" / 频道名(兜底搜索)
1919
min_duration_sec 可选:过滤短视频(同时发 Shorts 的频道建议 180,排除 Shorts)
2020
"""
2121
# 下面是示例 —— 换成你想分析的创作者。
22-
# B站 UID:用 00_resolve_creators.py 按名字搜;YouTube @handle:在频道主页地址栏能看到。
22+
# B站 UID:用 resolve_creators.py 按名字搜;YouTube @handle:在频道主页地址栏能看到。
2323
CREATORS = [
2424
# —— Bilibili(uid 留 None 会自动按 name 搜索补全)——
2525
{"name": "示例UP主A", "platform": "bilibili", "uid": None, "alias": "demo_b1", "zone": "知识"},

scripts/fetch_bilibili.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def fetch_creator(c, sessdata, num=40, tries=4):
3333
raise RuntimeError("没读到 SESSDATA(config_local.py)")
3434
uid = c.get("uid")
3535
if not uid:
36-
raise RuntimeError("缺 UID,先跑 00_resolve_creators.py")
36+
raise RuntimeError("缺 UID,先跑 resolve_creators.py")
3737
cred = Credential(sessdata=sessdata)
3838
u = user.User(uid=uid, credential=cred)
3939
raw = None
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
viralens · 01_fetch_videos.py
2+
viralens · fetch_videos.py
33
抓一个 B 站 UP 主最近 N 个视频的元数据,输出 JSON 给后续分析用。
44
(这是早期单人脚本;多创作者请用 fetch_multi.py。)
55
@@ -11,7 +11,7 @@
1111
2. F12 → Application/存储 → Cookies → https://www.bilibili.com → 找 SESSDATA
1212
复制 Value(看起来像 "abc123%2Cxxxx%2Cyyy...")
1313
3. 把 Value 粘贴到下方 SESSDATA 变量(引号内)
14-
4. 跑: python 01_fetch_videos.py
14+
4. 跑: python fetch_videos.py
1515
1616
输出: ../data/<alias>_videos.json
1717
"""
@@ -24,7 +24,7 @@
2424
from bilibili_api import user, Credential
2525

2626
# ============ 配置 ============
27-
UID = 0 # 换成你要抓的 UP 主 UID(00_resolve_creators.py 可按名字查)
27+
UID = 0 # 换成你要抓的 UP 主 UID(resolve_creators.py 可按名字查)
2828
NUM_VIDEOS = 30 # 抓最近多少个
2929
try:
3030
from config_local import SESSDATA # ← SESSDATA 统一放 config_local.py(已 gitignore,不进 git)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""
2-
viralens · 00_resolve_creators.py
2+
viralens · resolve_creators.py
33
按创作者名字搜 B站,补全 UID(选粉丝最多的账号,防同名假号)。
44
跑完核对候选 → 我帮你把正确 UID 写回 creators.py。
55
66
依赖: bilibili-api-python / SESSDATA 从 config_local.py 读
7-
跑: python 00_resolve_creators.py
7+
跑: python resolve_creators.py
88
"""
99
import asyncio
1010
import sys
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""
2-
viralens · 03_subtitle.py
2+
viralens · subtitle.py
33
抓 pilot 视频(2025正经科普 高5+低5)的 B站字幕,算"实验 vs 思辨"密度、语速、开场钩子。
44
验证假设:高播放组 是不是 思辨密度更高、实验奇观更少。
55
66
依赖: bilibili-api-python aiohttp (已装)
77
SESSDATA: 从 01 脚本复制粘贴到下方
88
9-
跑: python 03_subtitle.py
9+
跑: python subtitle.py
1010
输出: data/subtitle_features.json + 终端高低组对比
1111
"""
1212
import asyncio

0 commit comments

Comments
 (0)