logo NodeSeekbeta

面向纯小白的自建片片库教程(Rclone+Jellyfin)

前言

该图文教程面向的是纯小白用户,使用Rclone和Jellyfin工具完成小电影库的搭建。

Jellyfin V.S. Emby

Jellyfin和Emby是目前最主流的两种影音库软件,两者各有各自的优缺点,下面总结如下:

功能项 Jellyfin(免费版) Emby(免费版)
许可证 完全开源(GPLv2) 部分开源(核心开源)
费用 完全免费 核心功能免费,部分功能需付费解锁
客户端应用支持 广泛支持,全部免费使用 某些应用(如 Android、Roku、Apple TV)需 Emby Premiere
直播电视与DVR录制 完全支持 提供直播功能,DVR录制需 Emby Premiere
硬件加速转码 免费完全支持 需要 Emby Premiere
插件支持 社区驱动,插件丰富且免费 提供官方与社区插件(部分插件在免费版中受限)
用户管理 完整支持,含用户资料与家长控制 可用
元数据获取 可自由定制,支持多种免费来源 支持
转码功能 支持,提供完整控制 支持,但硬件加速转码需 Emby Premiere
远程访问 免费支持,自行部署 免费支持,但推荐使用 Emby Connect 简化设置
界面与用户体验 现代、清爽,可自定义 界面精致,略显更专业
更新频率 社区活跃,更新频繁 官方维护,免费版更新较慢
社区支持 拥有强大的开源社区支持 提供官方论坛支持,免费用户支持有限
隐私保护 无默认数据收集,用户完全掌控 默认开启部分遥测(可手动关闭)

由于Jellyfin的完全开源的属性和客户端的广泛支持,所以多余新手和个人用户来说,Jellyfin个人认为是要好于Emby的。所以本教程以Jellyfin为基础进行搭建

丐版和畅享版

本教程将分成两个小教程,分别依次带领小白搭建丐版和畅用版。两者的区别所需要准备的东西如下:

丐版

1️⃣丐版介绍

丐版主要针对的是那些没有大盘鸡的用户,主要实现的思路是用rclone将网盘挂载到VPS本地,然后用挂载到本地的媒体作为Jellyfin的媒体库。

2️⃣丐版所需要的准备的:

1.一个足够容量的网盘。容量大小按照个人需求可能不同,如果同时需要有BT下载功能的,建议使用Pikpak,并且开通会员(只有会员支持WebDV)。如果选择先下载到本地再上传云端这种较为繁琐的方式的话,建议使用Google Drive 或 OneDrive 等海外网盘。当然如果你的资源正规,你也可以使用国内网盘例如我的网盘。但是从综合体验上来看,首先推荐海外网盘另外,为了获得足够的容量和网盘的上下传速度等性能,建议还是开通你选择网盘的会员,以满足储存媒体的需求。

2.一台VPS。确保你的本地直连效果不错,并且口子不要太小,100mbps左右即可。1C1G足够。

3.一个域名。也可以不要,用IP+端口使用,无法使用https。

畅享版

1️⃣畅享版介绍:使用大盘鸡用硬盘储存媒体,并用线路鸡反代。这样可以提高观看体验,同时提高扫库等操作的效率和速度。

2️⃣畅享版所需要的准备的:

1.大盘鸡。硬盘大小按照你的需求购买

2.线路鸡。如果直连大盘鸡无法达到很好的效果,那么推荐选用一个线路鸡,要求本地->线路鸡和线路鸡->大盘鸡速度和延迟都比较理想。例如欧洲大盘鸡用retn拉,美国大盘鸡用美西精品拉,等等。

3.一个域名。也可以不要,用IP+端口使用,无法使用https。

Rclone的安装和配置

Rclone简介

Rclone is a command-line program to manage files on cloud storage. It is a feature-rich alternative to cloud vendors' web storage interfaces. Over 70 cloud storage products support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols.

Rclone has powerful cloud equivalents to the unix commands rsync, cp, mv, mount, ls, ncdu, tree, rm, and cat. Rclone's familiar syntax includes shell pipeline support, and --dry-run protection. It is used at the command line, in scripts or via its API.

Rclone mounts any local, cloud or virtual filesystem as a disk on Windows, macOS, linux and FreeBSD, and also serves these over SFTP, HTTP, WebDAV, FTP and DLNA.

Rclone 是一个用于管理云存储上文件的命令行程序。它是云供应商 Web 存储界面的功能丰富的替代方案。 超过 70 种云存储产品支持 rclone,包括 S3 对象存储、企业和消费者文件存储服务以及标准传输协议。

Rclone 具有强大的云等效项,相当于 unix 命令 rsync、cp、mv、mount、ls、ncdu、tree、rm 和 cat。Rclone 熟悉的语法包括 shell 管道支持和 --dry-run 保护。它可以在命令行、脚本中或通过其 API 使用。

Rclone 挂载任何本地、云或 虚拟文件系统作为 Windows 上的磁盘, macOS、linux 和 FreeBSD,也为 SFTP 与 HTTP 的, WebDAV / FTPDLNA 的。

安装

服务器端

运行下面脚本以安装(Linux/macOS/BSD):sudo -v ; curl https://rclone.org/install.sh | sudo bash

本地

1️⃣如果你是MacOS或者Linux,可以直接运行上面的命令来完成安装:sudo -v ; curl https://rclone.org/install.sh | sudo bash

2️⃣如果你是Windows,则需来到Rclone的发布页面,选择合适的版本进行下载,并且将rlcone.exe的目录添加到环境变量中去,确保在cmd中运行rclone不会报错即可

配置——Google Drive

安装完成后运行rclone config添加配置。

n) New remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
n/r/c/s/q> n

选择n,新建一个remote。

Type of storage to configure.
Choose a number from below, or type in your own value
[snip]
XX / Google Drive
   \ "drive"
[snip]

选择storage的类型,选择Google Drive,注意Google Drive和Google Cloud Storage、Google Photos不同。

Google Application Client Id - leave blank normally.
client_id>
Google Application Client Secret - leave blank normally.
client_secret>

之后的client_id和client_secret直接留空回车就可以。

Scope that rclone should use when requesting access from drive.
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
 2 / Read-only access to file metadata and file contents.
   \ "drive.readonly"
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ "drive.file"
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ "drive.appfolder"
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ "drive.metadata.readonly"
scope> 1

下面是关于访问权限的设置。选择1是可以访问Google Drive上的所有文件。如果没有什么特殊需求,直接选择1就可以,如果想要read-only那么选择2.想要rclone可以访问的内容更少的可以选择后面的选项。

Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login.
service_account_file>

这里也直接留空回车就可以

Use web browser to automatically authenticate rclone with remote?
 * Say Y if the machine running rclone has a web browser you can use
 * Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.
y) Yes
n) No
y/n> n

由于使用的VPS默认都是Linux,无GUI,所有这里要选择no,要在我们的电脑上完成token的获取。Rclone的返回信息如下:

0yq204RPc0xpSaLAIOoQhf5GwoHKnmy9.png

只需要将Rclone返回的命令复制到终端中即可。PS:请确保终端可以访问Google,即终端可以走代理。最简单的办法就是开启TUN模式

od9TrAQt7FH8Jykux51OgyPxFAE2XZ5m.png

复制进终端回车后,会自动跳转到浏览器,登录Google Drive的账号,请选择你需要挂载网盘的账号即可。挂载完成后会有Success的提示:

0r5ZKLydzpvZBAN0mOkHUe81kjXu6E2X.png

此时终端中会显示获取到的Token,将得到的Token复制到VPS中去即可。

配置——Pikpak

最早的操作都一样,新建一个remote,我这里命名为pikpak,选择选项:

58 / WebDAV
   \ (webdav)

之后来到pikpak官网,进入Settings->Experimental Features->WebDAV,PS:此功能需要Pikpak会员才可以使用,且目前read-only

zyIHXghT7iH2ff5Qgy7UjGvUeZWzDs8R.png

获取以下信息:Endpoint,Username,Password,Bearer Token

将URL填入rlcone:

Option url.
URL of http host to connect to.
E.g. https://example.com.
Enter a value.
url> https://your_endpoint

之后选择8.Others

Name of the WebDAV site/service/software you are using.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / Fastmail Files
   \ (fastmail)
 2 / Nextcloud
   \ (nextcloud)
 3 / Owncloud 10 PHP based WebDAV server
   \ (owncloud)
 4 / ownCloud Infinite Scale
   \ (infinitescale)
 5 / Sharepoint Online, authenticated by Microsoft account
   \ (sharepoint)
 6 / Sharepoint with NTLM authentication, usually self-hosted or on-premises
   \ (sharepoint-ntlm)
 7 / rclone WebDAV server to serve a remote over HTTP via the WebDAV protocol
   \ (rclone)
 8 / Other site/service or software
   \ (other)

然后,依次将user,password和bearer token输入进去:

Option user.
User name.
In case NTLM authentication is used, the username should be in the format 'Domain\User'.
Enter a value. Press Enter to leave empty.
user> your_name

Option pass.
Password.
Choose an alternative below. Press Enter for the default (n).
y) Yes, type in my own password
g) Generate random password
n) No, leave this optional password blank (default)
y/g/n> y
Enter the password:
password:
Confirm the password:
password:

Option bearer_token.
Bearer token instead of user/pass (e.g. a Macaroon).
Enter a value. Press Enter to leave empty.
bearer_token> your_bearer_token

Edit advanced config?
y) Yes
n) No (default)
y/n> 

Configuration complete.
Options:
- type: webdav
- url: 
- vendor: other
- user: 
- pass: *** ENCRYPTED ***
- bearer_token: 
Keep this "pikpak" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>

挂载到VPS本地

这一点对于任何配置好的网盘都是一样的。首先先创建一个挂载点:

mkdir -p /mnt/pikpak

然后运行一下命令进行挂载:

rclone mount pikpak: /mnt/pikpak --daemon --allow-other --vfs-cache-mode writes --dir-cache-time 1000h

如果运行产生报错,则先安装fuse:sudo apt install -y fuse3*

命令参数详解

1️⃣rclone mount: rclone 的挂载命令。

2️⃣pikpak:: 您在 rclone 中配置的网盘名称。末尾的冒号 : 代表网盘的根目录。

3️⃣/mnt/pikpak: 本地挂载点目录。

4️⃣--daemon: 使 rclone 在后台作为守护进程运行,这样关闭终端后挂载不会断开。

5️⃣--allow-other: 允许其他用户(包括系统服务,如 Plex、Jellyfin 等)访问挂载点。需要完成上述前提条件中的第3步。如果只有您自己使用,可以去掉此参数。

6️⃣--vfs-cache-mode writes: VFS(虚拟文件系统)缓存模式设置为 writes`。这会在上传文件时先将其完整缓存到本地,上传成功后再删除,可以提高文件写入的稳定性和速度,避免因网络问题导致上传失败。

7️⃣--dir-cache-time 1000h`: 目录结构缓存时间。大幅延长缓存时间(这里是1000小时)可以显著减少对 PikPak API 的请求次数,加快文件列表的显示速度。

8️⃣--log-file /var/log/rclone.log: 指定日志文件的路径,方便排查问题。

9️⃣--log-level INFO: 设置日志级别为 INFO,记录一般信息和错误。如果需要调试,可以改为 DEBUG

可以自行选择加入或者减少参数的设置,也可以对参数进行修改。

此时你就会发现你已经成功挂载网盘到本地了!!!

oYXWbjmu0vVkVCsFFNjo8qMjJYNciCfP.png

安装和配置Jellyfin

安装Jellyfin

运行curl -s https://repo.jellyfin.org/install-debuntu.sh | sudo bash

如果您没有安装 curl,则可以使用 wget -q -O- 而不是 curl -s。对于更高级的用户,可以在文档中找到完整的步骤。安装后,Jellyfin 将作为服务运行。使用 sudo systemctl {action} jellyfin.servicesudo service jellyfin {action} 进行管理。

配置Jellyfin

运行完毕后默认端口为8096,无需更改,打开浏览器访问http://your_ip:8096即可进行配置。添加媒体库时将媒体所在的位置选择为在你本地挂载绝对路径即可。

畅享版

将Pikpak网盘上的文件复制到本地

运行以下命令:rclone copy pikpak:path_to_your_file /media/paht_to_your_dir --progress --checksum --transfers=8 --checkers=8

命令详解

1️⃣rclone copy: 这是 rclone 用于复制文件的命令。它只会复制源端(PikPak)有而目标端(本地)没有或不同的文件,不会删除目标端多余的文件。

2️⃣pikpak:: 您在 rclone 中配置的 PikPak 网盘的名称。末尾的冒号 : 代表网盘的根目录

/media/: 您本地的目标文件夹。请确保您对该目录有写入权限。

3️⃣--progress (或 -P): 在终端实时显示传输进度,包括传输速度、已用时间、预计剩余时间等,强烈建议使用

4️⃣--checksum: rclone 默认通过文件大小和修改时间来判断文件是否相同。使用此参数会强制 rclone 在复制后比较文件的哈希值(checksum),确保文件在传输过程中没有损坏。这会增加一点点CPU负担,但极大地提高了数据的可靠性。

5️⃣--transfers=8: 设置同时进行的文件传输数量(并发数)。默认是 4。如果您的网络好,且有很多小文件,适当提高此数值可以显著提升总的传输速度。816 是常见选择。

6️⃣--checkers=8: 设置并行检查文件的线程数。当需要对比大量文件时,提高此数值可以加快任务开始前的检查阶段。

使用线路鸡反代

安装Caddy

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
chmod o+r /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

或者安装Testing releases

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/testing/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-testing-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/testing/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-testing.list
chmod o+r /usr/share/keyrings/caddy-testing-archive-keyring.gpg
chmod o+r /etc/apt/sources.list.d/caddy-testing.list
sudo apt update
sudo apt install caddy

配置Caddyfile

使用nano或者vim编辑Caddyfile:

your_domin:8066 {
    reverse_proxy your_ip:8096 {
        transport http {
            read_buffer 0
            read_timeout 300s
            write_buffer 0
            write_timeout 300s
        }

        # 移除敏感头部
        header_up -X-Real-IP
        header_up -X-Forwarded-For
        header_up -X-Forwarded-Proto
        header_up Host {host}
        header_up X-Forwarded-Host {host}
    }
}

保存退出后运行systemctl reload caddy即可。最后在客户端用your_domin:8066登录即可,可以开启HTTPS!

更改媒体路径

由于媒体文件已经存在大盘鸡本地,请将媒体路径换成本机存储到路径而非网盘挂载到路径!本地的文件可以大大加快扫库的速度。


后记

本教程为面向纯小白的自建片片库教程,用到的工具都比较基础,并且没有详细后续的优化配置,大佬见了还多包涵🙏🙏🙏
完结撒花🎉🎉🎉

123
123

你好啊,陌生人!

我的朋友,看起来你是新来的,如果想参与到讨论中,点击下面的按钮!

📈用户数目📈

目前论坛共有60489位seeker

🎉欢迎新用户🎉