Skip to main content

funflix

影视资源分享文本的结构化采集、解析与网盘链接校验。

完整设计见 docs/DESIGN.md

流水线

source ──采集──> raw_document ──LLM 抽取──> extraction
(频道/水位)      (原始文本)                  │
                                              ▼
                                    media + resource ──校验──> link_check
                                   (作品)  (网盘链接)

每一层各自幂等、可单独重跑。当前进度:

阶段 状态
M0 采集源 + Telegram 采集器 + 水位 ✅ 已完成
M1 数据模型 + 迁移 + 原始文本接口 ✅ 已完成
M2 链接扫描 + 文本分段 + 剧名归一 ✅ 已完成
M3 LLM 抽取 待开发
M4 网盘校验(夸克 / 阿里云盘,匿名探针) 待开发
M5 worker 租约 + 启动补偿 待开发
M6 查询接口 待开发

快速开始

pip install -e ".[dev]"

# 建库
alembic upgrade head

# 登记一个 Telegram 频道并采集一次
funflix source add https://t.me/s/<频道名>
funflix source collect
funflix source list

# 起服务
funflix serve --reload
# 接口文档 http://127.0.0.1:8000/docs

配置

所有配置项走 FUNFLIX_ 前缀的环境变量或 .env

变量 默认值 说明
FUNFLIX_DATABASE_URL sqlite+aiosqlite:///./funflix.db 切 PG 改成 postgresql+asyncpg://...
FUNFLIX_ADMIN_API_KEY 管理接口的 key,不配则管理接口关闭
FUNFLIX_LOG_LEVEL INFO
FUNFLIX_INGEST_MAX_BATCH 200 单批提交上限
FUNFLIX_INGEST_MAX_CONTENT_LENGTH 100000 单条文本长度上限

接口

采集源

方法 路径 说明
POST /api/v1/sources 登记采集源,只给 url 即可自动识别类型与标识
GET /api/v1/sources 列表
GET /api/v1/sources/supported 当前支持的源类型
PATCH /api/v1/sources/{id} 改配置;回拨 cursor_message_id 即可重采历史
POST /api/v1/sources/{id}/collect 立即采集一次
DELETE /api/v1/sources/{id} 删除(已采文本保留)

原始文本

方法 路径 说明
POST /api/v1/raw 提交一条;命中 content_hash 返回 duplicated=true
POST /api/v1/raw/bulk 批量提交
GET /api/v1/raw 按状态 / 来源翻页,不返回全文
GET /api/v1/raw/{id} 详情,含全文

设计要点

  • 水位用消息 ID 而不是时间。ID 单调且精确,不受时钟漂移、同秒多条消息、消息编辑改时间戳的影响。
  • 水位按「见到的最大 ID」推进,不是「成功落库的最大 ID」。否则一条无正文的纯图片消息会永久卡住采集。
  • 首次接入只取最新一页。想补历史就显式回拨 cursor_message_id,避免接入老频道时把整个历史拉下来。
  • 入口按 content_hash 去重。同一条分享被多个源重复抓到时在这里挡住,不会走到后面按次计费的 LLM 抽取。
  • 时间统一 UTC-awareUTCDateTime 抹平了 SQLite(读回 naive)与 PostgreSQL(读回 aware)的行为差异,写入 naive 会直接报错。

开发

pytest              # 测试
ruff check .        # lint
ruff format .       # 格式化

# 改了模型后生成迁移
alembic revision --autogenerate -m "描述"

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

funflix-0.1.1-py3-none-any.whl (113.2 kB view details)

Uploaded Python 3

File details

Details for the file funflix-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: funflix-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 113.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for funflix-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 560a2a7b63466fa1a63b327800ae3d0180cfefdc81abc38f4909e422d85d75f0
MD5 b34baa375e3c714893de3c836efe7560
BLAKE2b-256 1e199c026d2ea820f1d8b2605b963562d2cdd70699af05f52f1ae79ec82d6530

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.20

1 file

0.1.19

1 file

0.1.18

1 file

0.1.17

1 file

0.1.16

1 file

0.1.15

1 file

0.1.14

1 file

0.1.13

1 file

0.1.12

1 file

0.1.11

1 file

0.1.10

1 file

0.1.9

1 file

0.1.8

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

This release

0.1.1 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page