Skip to content

Commit

Permalink
限制一下日志显示的高度,以防挡住工具栏
Browse files Browse the repository at this point in the history
增加支持的客户端说明
  • Loading branch information
Izumiko committed Mar 2, 2024
1 parent 7663ba5 commit 2d83839
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 35 deletions.
66 changes: 41 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# jellyfin-danmaku

## Jellyfin弹幕插件

![image](/Simple.png)

## 界面

**请注意Readme上方截图可能与最新版存在差异,请以实际版本与说明为准**
> 请注意Readme上方截图可能与最新版存在差异,请以实际版本与说明为准
左下方新增如下按钮,若按钮透明度与"暂停"等其他原始按钮存在差异,说明插件正在进行加载

Expand All @@ -25,6 +26,12 @@

**除0级外均带有每3秒6条的垂直方向弹幕密度限制,高于该限制密度的顶部/底部弹幕将会被转为普通弹幕*

## 支持的客户端

- Jellyfin Web
- Jellyfin Android (播放器类型仅限网页播放器)
- Jellyfin iOS

## 弹幕

弹幕来源为 [弹弹 play](https://www.dandanplay.com/) ,已开启弹幕聚合(Acfun/Bili/Tucao/Baha/5DM/iQIYI等不知名网站弹幕融合)
Expand All @@ -47,65 +54,76 @@
### 2. 反向代理处理(推荐)

#### 2.1 Nginx

使用Nginx反向代理`Jellyfin`并在`location`块中插入:
```

```conf
proxy_set_header Accept-Encoding "";
sub_filter '</body>' '<script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>';
sub_filter_once on;
```

- [`完整示例`](https://github.com/Izumiko/jellyfin-danmaku/issues/8)

#### 2.2 Caddy

下载Caddy二进制文件时,增加第三方模块[`sjtug/caddy2-filter`](https://github.com/sjtug/caddy2-filter),之后,在`Caddyfile`中按如下内容修改
```

```Caddyfile
# 全局设置
{
order filter after encode
order filter after encode
}
# 网站设置
example.com {
filter {
path .*/web/index.html.*
search_pattern </body>
replacement "<script src=\"https://jellyfin-danmaku.pages.dev/ede.user.js\" defer></script></body>"
content_type text/html
}
reverse_proxy localhost:8096 {
header_up Accept-Encoding identity
}
filter {
path .*/web/index.html.*
search_pattern </body>
replacement "<script src=\"https://jellyfin-danmaku.pages.dev/ede.user.js\" defer></script></body>"
content_type text/html
}
reverse_proxy localhost:8096 {
header_up Accept-Encoding identity
}
}
```

### 3. 修改服务端启动命令

[思路来源](https://github.com/Izumiko/jellyfin-danmaku/issues/20)

#### 3.1 Docker模式启动的服务端

官方镜像的Entrypoint是`/jellyfin/jellyfin``hotio/jellyfin`镜像的Entrypoint是`/init`,可在`docker-compose.yml`的jellyfin部分增加一行如下代码,用带sed的Entrypoint替换默认的Entrypoint。

官方镜像:
```

```yaml
entrypoint: sed -i 's#</div></body>#</div><script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /jellyfin/jellyfin-web/index.html && /jellyfin/jellyfin
```
`hotio/jellyfin`镜像:
```

```yaml
entrypoint: sed -i 's#</div></body>#</div><script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /usr/share/jellyfin/web/index.html && /init
```

#### 3.2 直接用包管理器安装,并使用systemd管理的服务端

部分用户使用deb包或者Arch Linux的aur包安装Jellyfin,可以修改systemd service文件来实现启动时追加js脚本。
运行`systemctl edit jellyfin.service`,进入编辑界面,然后输入如下内容:

deb包安装的版本:
```

```ini
[Service]
ExecStartPre=-/usr/bin/sed -i 's#</div></body>#</div><script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /usr/share/jellyfin/web/index.html
```

aur安装的版本:
```

```ini
[Service]
ExecStartPre=-/usr/bin/sed -i 's#</div></body>#</div><script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /usr/lib/jellyfin/jellyfin-web/index.html
```
Expand All @@ -126,31 +144,29 @@ ExecStartPre=-/usr/bin/sed -i 's#</div></body>#</div><script src="https://jellyf
<script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script>
```

**Shell中的操作命令为**
**Shell中的操作命令为:**

*Official Docker:*

```bash
sed -i 's#</body>#<script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /jellyfin/jellyfin-web/index.html
```
*(Official Docker)*

*Default:*

```bash
sed -i 's#</body>#<script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /usr/share/jellyfin/web/index.html
```
*(Default)*

该方式安装与浏览器插件安装**可同时使用不冲突**

### 5. 修改客户端

类似服务端方式,解包后修改 dashboard-ui/index.html 再重新打包即可,iOS 需要通过类似 AltStore 方式自签,请自行 Google 解决

## 常见弹幕加载错误/失败原因

1. 译名导致的异常: 如『よふかしのうた』 Emby 识别为《彻夜之歌》后因为弹弹 play 中为《夜曲》导致无法匹配
2. 存在多季/剧场版/OVA 等导致的异常: 如『OVERLORD』第四季若使用S[N]格式归档(如OVERLORD/S4E1.mkv或OVERLORD/S4/E1.mkv),可能出现匹配失败/错误等现象
3. 其他加载BUG: ~~鉴定为后端程序猿不会前端还要硬写JS~~,有BUG麻烦 [开个issue](https://github.com/Izumiko/jellyfin-danmaku/issues/new/choose) THX

**首次播放时请检查当前弹幕信息是否正确匹配,若匹配错误请尝试手动匹配**
> 首次播放时请检查当前弹幕信息是否正确匹配,若匹配错误请尝试手动匹配

## 鸣谢

Expand Down
13 changes: 3 additions & 10 deletions ede.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// ------ configs start------
let isInTampermonkey = true;
const corsProxy = 'https://ddplay-api.930524.xyz/cors/';
let apiPrefix = corsProxy;
let apiPrefix = '';
let logQueue = [];
let logLines = 0;
let ddplayStatus = localStorage.getItem('ddplayStatus') ? JSON.parse(localStorage.getItem('ddplayStatus')) : {isLogin: false, token: '', tokenExpire: 0};
Expand Down Expand Up @@ -104,7 +104,6 @@
showDebugInfo('正在加载,请稍后再试');
return;
}
// showDebugInfo('切换日志开关');
window.ede.logSwitch = (window.ede.logSwitch + 1) % 2;
window.localStorage.setItem('logSwitch', window.ede.logSwitch);
document.querySelector('#displayLog').children[0].className = spanClass + log_icons[window.ede.logSwitch]
Expand Down Expand Up @@ -396,8 +395,7 @@
// 检测是否在Tampermonkey中运行
if (typeof GM_xmlhttpRequest === 'undefined') {
isInTampermonkey = false;
} else {
apiPrefix = '';
apiPrefix = corsProxy;
}

class EDE {
Expand Down Expand Up @@ -470,12 +468,6 @@
}
return;
}
// if (!container.getAttribute('ede_listening')) {
// showDebugInfo('正在初始化Listener');
// container.setAttribute('ede_listening', true);
// container.addEventListener('play', reloadDanmaku);
// showDebugInfo('Listener初始化完成');
// }
}

function initUI() {
Expand Down Expand Up @@ -540,6 +532,7 @@
span.style.color = '#fff';
span.style.padding = '20px';
span.style.borderRadius = '.3em';
span.style.maxHeight = '50%'
window.ede.logSwitch == 1 ? (span.style.display = 'block') : (span.style.display = 'none');
_container.appendChild(span);

Expand Down

0 comments on commit 2d83839

Please sign in to comment.