{"id":20808400,"url":"https://github.com/std4453/jfdmk","last_synced_at":"2025-05-07T06:05:59.154Z","repository":{"id":45582161,"uuid":"425280948","full_name":"std4453/jfdmk","owner":"std4453","description":"jfdmk is danmaku for jellyfin","archived":false,"fork":false,"pushed_at":"2021-12-08T02:43:27.000Z","size":404,"stargazers_count":18,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T06:05:53.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/std4453.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-06T15:37:39.000Z","updated_at":"2023-11-22T04:15:01.000Z","dependencies_parsed_at":"2022-09-09T22:03:39.765Z","dependency_job_id":null,"html_url":"https://github.com/std4453/jfdmk","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/std4453%2Fjfdmk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/std4453%2Fjfdmk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/std4453%2Fjfdmk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/std4453%2Fjfdmk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/std4453","download_url":"https://codeload.github.com/std4453/jfdmk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252823918,"owners_count":21809713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T19:48:24.634Z","updated_at":"2025-05-07T06:05:59.132Z","avatar_url":"https://github.com/std4453.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jfdmk\n\n_jfdmk_ 在 [_Jellyfin_](https://jellyfin.org/) 中添加了弹幕功能。\n\n它使用 [CommentCoreLibrary](https://github.com/jabbany/CommentCoreLibrary) 作为弹幕渲染引擎，用 [Bilibili 弹幕](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/danmaku/danmaku_xml.md) 作为数据源。\n\n## 使用\n\n### 构建数据库\n\n为了使用它，你需要创建 `data/db.json` ，内容例如：\n\n```json\n{\n  \"seasons\": [\n    {\n      \"series\": \"Banished from the Hero's Party, I Decided to Live a Quiet Life in the Countryside\",\n      \"season\": 1,\n      \"bilibili_ss\": \"39461\"\n    }\n  ]\n}\n```\n\n这里的 `series` 需要与 Jellyfin 中的剧集名称 **完全一致** ，如果你按照 [我的博客](https://blog.std4453.com:444/nas-from-zero-media-part/) 配置媒体栈，它应当与 [TheTVDB](https://thetvdb.com/) 中的名称相同。\n\n`season` 为 1 开始的季度编号，同样与 TheTVDB 中的数据相同。\n\n这两个字段用于匹配 bilibili 的季度，可以根据 Jellyfin 中的实际情况调整。\n\n`bilibili_ss` 是 Bilibili 上对应视频的 `ss` ，你可以打开对应的番剧季度介绍页然后在 console 中输入：\n\n```js\nconsole.log(__INITIAL_STATE__.mediaInfo.season_id);\n```\n\n默认情况下，我们假定 Jellyfin 上的剧集顺序与 bilibili 上的一一对应，如果不对应的话可以使用 `ranges` 字段进行匹配，例如：\n\n```json\n{\n  \"seasons\": [\n    {\n      \"series\": \"Banished from the Hero's Party, I Decided to Live a Quiet Life in the Countryside\",\n      \"season\": 1,\n      \"ranges\": [\n        {\n          \"from\": 2,\n          \"to\": 6,\n          \"bilibili_ss\": \"39461\",\n          \"bilibili_from\": 3\n        }\n      ]\n    }\n  ]\n}\n```\n\n这里的 `from` 、 `to` 和 `bilibili_from` 参数均为 1 开始的集数，如上的例子即表示：\n\n\u003e Jellyfin 中的第 2 ~ 6 集（包括头尾）对应 bilibili 上 ss=39461 的第 3 ~ 7 集\n\n注意：\n- `bilibili_ss` 字段和 `ranges` 字段只能存在一个。\n- 如果 `ranges` 中的对象不包含 `from` 字段，则视为从第一集开始。\n- 如果不包含 `to` 字段，则视为 `from` 后的所有集数。\n- 如果不包含 `bilibili_ss` 字段，则视为从 bilibili 的第 1 集开始。\n- `ranges` 中的所有条目会从前到后匹配，直到找到第一个符合要求的。\n- 相同的 `series` 和 `season` 只能存在一条，多余的会被忽略。\n\n_TODO: 这一数据库内容应当可以公开，之后会考虑提供公共的数据库。_\n\n### 启动服务\n\n你可以使用 docker 镜像 `std4453/jfdmk:latest` 运行，这样的话可以跳过下面的步骤。\n\n首先你需要安装依赖：\n\n```bash\n$ yarn install --production=true\n```\n\n然后需要编译前端：\n\n```bash\n$ yarn build\n```\n\n现在可以启动服务器了：\n\n```bash\n$ yarn start\n```\n\n默认端口为 10086，你也可以通过 `PORT` 环境变量更改端口。\n\n请注意，使用 docker 运行时， `data/db.json` 需要从外部挂载。\n\n### 修改 Jellyfin\n\n最后，你需要修改 Jellyfin 的 HTML 文件，在 `index.html` 的 `\u003c/body\u003e` 前加入：\n\n```html\n\u003cscript src=\"//your_jfdmk_host/dist/index.js\" defer\u003e\u003c/script\u003e\n```\n\n刷新之后，打开对应的视频，就应该能看到弹幕了。\n\n如果你使用容器部署 Jellyfin，你需要修改的文件位于 `/usr/share/jellyfin/web/index.html` ，不过这样的问题在于并不能持久化，对此你可以在本地 build 包含 jfdmk 的 Jellyfin 镜像，例如：\n\n```bash\ndocker build \\\n\t-f Dockerfile.Jellyfin \\\n\t--build-arg JELLYFIN_IMAGE=linuxserver/jellyfin:latest \\\n\t--build-arg JFDMK_HOST=\u003cyour_jfdmk_host\u003e \\\n\t-t \u003cyour_scope\u003e/jellyfin-jfdmk:latest \\\n\t.\n```\n\n这里的 `JELLYFIN_IMAGE` 可以替换成其他的 Jellyfin 镜像，默认是 `linuxserver/jellyfin:latest` ，以及由于 jfdmk 本体部署在其他域名下，你需要在 build 时指定它。之所以需要本地 build 而非提供公用镜像，是因为没有什么简单的动态配置手段，如果你对自己的 jfdmk 部署域名没有保密需求，你也可以配置 CI 自动 build 并 push 到 docker hub。\n\n镜像 build 完成之后，你可以将原先的 Jellyfin 镜像替换成 `\u003cyour_scope\u003e/jellyfin_jfdmk:latest` 。\n\n注意这样 build 得到的镜像无法自动更新 Jellyfin 版本，你可以写一个脚本定期自动运行上述 build 流程。\n\njfdmk 只在 Web 端启用，手机端的渲染效果比较差，之后可能会启用。\n\n## 开发\n\n开发后端时使用：\n\n```bash\n$ yarn dev:server\n```\n\n它使用 `nodemon` 监听 `server/index.js` 的变化，在变化时自动重启服务器。\n\n它也默认在 10086 端口上运行，注意不要和运行中的服务冲突。\n\n开发前端时首先需要启动后端，然后：\n\n```bash\n$ yarn dev:frontend\n```\n\n它会在 3000 端口启动 `webpack-dev-server` \b，自动打包前端代码，并反代后端请求。\n\n开发时你需要在 Jellyfin 中插入：\n\n```html\n\u003cscript src=\"//your_jfdmk_dev_host/index.js\" defer\u003e\u003c/script\u003e\n```\n\n配置里允许从任何地址访问后端，请注意权限问题。\n\n为了从 Jellyfin 中访问 `webpack-dev-server` 的 WebSocket，你需要在 `.env` 中配置：\n\n```\nDEV_WEBSOCKET_URL=ws://your_jfdmk_dev_host/ws\n```\n\n如果不进行配置，可能无法获得 HMR 支持。\n## 作者\n\n张海川 - Haichuan Zhang - [me@std4453.com](mailto:me@std4453.com) - [Homepage](https://blog.std4453.com:444)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstd4453%2Fjfdmk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstd4453%2Fjfdmk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstd4453%2Fjfdmk/lists"}