magicalex / rtorrent-cleaner
rtorrent-cleaner 是一个用于清理 rtorrent 中不必要的文件的工具
Requires
- php: >=5.5.9
- ext-iconv: *
- ext-json: *
- ext-xmlrpc: *
- symfony/console: 3.4.* || 5.1.*
- symfony/finder: 3.4.* || 5.1.*
- symfony/stopwatch: 3.4.* || 5.1.*
README
rtorrent-cleaner 是一个用于清理 rtorrent 中不必要的文件的工具
要求
- php 5.5.9 及以上版本(推荐使用 php 7.2)
- php 扩展:
php-cli
,php-xmlrpc
和php-mbstring
安装
从 Phar 文件安装 rtorrent-cleaner(推荐)
首选的安装方法是使用 rtorrent-cleaner PHAR,可以从最新的
检查 GitHub 发布.
使用 composer 安装 rtorrent-cleaner
全局安装 rtorrent-cleaner
composer global require magicalex/rtorrent-cleaner
从 DockerHub 安装 rtorrent-cleaner
要求
- docker 安装 docker
docker run -it --rm magicalex/rtorrent-cleaner:latest
详细信息请见这里
使用方法
显示帮助
_ _ _ _ __| |_ ___ _ __ _ __ ___ _ __ | |_ ___| | ___ __ _ _ __ ___ _ __ | '__| __/ _ \| '__| '__/ _ \ '_ \| __| / __| |/ _ \/ _` | '_ \ / _ \ '__| | | | || (_) | | | | | __/ | | | |_ | (__| | __/ (_| | | | | __/ | |_| \__\___/|_| |_| \___|_| |_|\__| \___|_|\___|\__,_|_| |_|\___|_| rtorrent-cleaner version x.x.x Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: debug Debug torrents help Displays help for a command list Lists commands mv Move your unnecessary files in a specified folder report Create a report on unnecessary files and missing files rm Delete your unnecessary files in your download folder torrents Delete torrents or redownload the missing files
命令 report
用于创建关于不必要的文件和丢失文件的报告
(在您的 rtorrent.rc 配置中设置,例如:network.scgi.open_port = localhost:5000
)
rtorrent-cleaner report localhost:5000
使用套接字示例(rtorrent.rc 文件中的 network.scgi.open_local = /home/user/rpc.socket
)
rtorrent-cleaner report /home/user/rpc.socket
您可以使用 --log 选项将控制台输出记录到文件(路径:./rtorrent-cleaner.log)
您可以定义路径(路径:/var/log/rtorrent-cleaner.log)
rtorrent-cleaner report --log -- 127.0.0.1:5000 rtorrent-cleaner report -l /var/log/rtorrent-cleaner.log 127.0.0.1:5000 rtorrent-cleaner report --log=/var/log/rtorrent-cleaner.log 127.0.0.1:5000
命令 rm
用于删除下载文件夹中的不必要的文件
rtorrent-cleaner rm 127.0.0.1:5000
# delete without confirmation --assume-yes or -y
rtorrent-cleaner rm --assume-yes 127.0.0.1:5000
命令 mv
用于将不必要的文件移动到指定的文件夹中(例如:/home/user/old)
rtorrent-cleaner mv 127.0.0.1:5000 /home/user/old
# move without confirmation --assume-yes or -y
rtorrent-cleaner mv -y 127.0.0.1:5000 /home/user/old
命令 torrents
用于删除种子或重新下载丢失的文件
rtorrent-cleaner torrents 127.0.0.1:5000
命令 mv
,rm
和 report
的选项用于忽略文件:--exclude-files=
rtorrent-cleaner report --exclude-files=*.srt 127.0.0.1:5000 rtorrent-cleaner report -f *.sub -f *.srt 127.0.0.1:5000
第二个示例排除了输出中的所有 .sub
和 .srt
文件
命令 mv
,rm
和 report
的选项用于忽略目录:--exclude-dirs=
目录必须是相对于 rtorrent 默认目录的相对路径(在 rtorrent.rc 中的 directory.default
)
rtorrent-cleaner report --exclude-dirs=movies 127.0.0.1:5000 rtorrent-cleaner report -d movies -d series 127.0.0.1:5000
第二个示例排除了 movies
和 series
目录
使用 Docker 的使用方法
环境变量
信息:将 <container_name>
替换为您 rtorrent 容器的名称
信息:将 </home/user/downloads>
替换为您的下载文件夹
信息:将 </data/downloads>
替换为 rtorrent 的 directory.default
。请参阅您的 rtorrent.rc 文件
显示帮助的命令:rtorrent-cleaner
docker run -it --rm \ -v </home/user/downloads>:</data/downloads> \ --link <container_name>:rtorrent \ magicalex/rtorrent-cleaner
如果您使用带有网络的网络容器,您可以像这样连接 rtorrent-cleaner
信息:将 <network_name>
替换为您的网络(您可以列出所有 docker 网络 docker network ls
)
docker run -it --rm \ -v </home/user/downloads>:</data/downloads> \ --network <network_name> \ --link <container_name>:rtorrent \ magicalex/rtorrent-cleaner
创建报告的命令:rtorrent-cleaner report rtorrent:5000
docker run -it --rm \ -v </home/user/downloads>:</data/downloads> \ --network <network_name> \ --link <container_name>:rtorrent \ magicalex/rtorrent-cleaner report rtorrent:5000
如果您需要,可以使用 PHP_MEMORY_LIMIT 环境变量增加 PHP 内存限制。
默认情况下,内存限制为 128M。
docker run -it --rm \ -e PHP_MEMORY_LIMIT=256M \ -v </home/user/downloads>:</data/downloads> \ --network <network_name> \ --link <container_name>:rtorrent \ magicalex/rtorrent-cleaner
您可以使用 PHP_TIMEZONE 环境变量更改时区。
默认情况下,时区为 UTC。
docker run -it --rm \ -e PHP_TIMEZONE=Europe/Paris \ -v </home/user/downloads>:</data/downloads> \ --network <network_name> \ --link <container_name>:rtorrent \ magicalex/rtorrent-cleaner
您可以为使用 Docker 运行 rtorrent-cleaner 创建一个脚本
#!/usr/bin/env sh docker run -it --rm \ -v </home/user/downloads>:</data/downloads> \ --network <network_name> \ --link <container_name>:rtorrent \ magicalex/rtorrent-cleaner $*
或者如果您使用 rtorrent 的套接字 /run/php/.rtorrent.sock
。
#!/usr/bin/env sh docker run -it --rm \ -v </home/user/downloads>:</data/downloads> \ -v /run/php:/run/php \ magicalex/rtorrent-cleaner $*
chmod +x /usr/local/bin/rtorrent-cleaner
使用方法
rtorrent-cleaner report rtorrent:5000
rtorrent-cleaner rm rtorrent:5000
rtorrent-cleaner torrents rtorrent:5000
rtorrent-cleaner mv rtorrent:5000 /home/user/old
或者使用套接字
rtorrent-cleaner report /run/php/.rtorrent.sock
rtorrent-cleaner rm /run/php/.rtorrent.sock
rtorrent-cleaner torrents /run/php/.rtorrent.sock
rtorrent-cleaner mv /run/php/.rtorrent.sock /home/user/old
使用 docker 镜像的示例 linuxserver/rutorrent
配置您的 docker-compose.yml
version: "3" services: rutorrent: image: linuxserver/rutorrent:latest container_name: rutorrent environment: - PUID=1000 - PGID=1000 volumes: - /path/to/rutorrent/config:/config - /path/to/rutorrent/downloads:/downloads - /run/php:/run/php ports: - 80:80 - 51413:51413 - 6881:6881/udp restart: unless-stopped
运行 linuxserver/rutorrent
docker-compose up -d
在 /usr/local/bin
文件夹中创建您的 rtorrent-cleaner 脚本
#!/usr/bin/env sh docker run -it --rm \ -e PHP_MEMORY_LIMIT=128M \ -e PHP_TIMEZONE=Europe/Paris \ -v /path/to/rutorrent/downloads:/downloads \ -v /run/php:/run/php \ magicalex/rtorrent-cleaner $*
完成此步骤后,您可以运行 rtorrent-cleaner
chmod +x /usr/local/bin/rtorrent-cleaner rtorrent-cleaner report /run/php/.rtorrent.sock
构建 Docker 镜像
docker build -t magicalex/rtorrent-cleaner:latest https://github.com/Magicalex/rtorrent-cleaner.git
构建 Phar 归档 (rtorrent-cleaner.phar)
要构建归档 phar,需要 php 7.2 和 php-phar
扩展。
git clone https://github.com/Magicalex/rtorrent-cleaner.git
cd rtorrent-cleaner
composer build
许可证
rtorrent-cleaner 在 MIT 许可证 下发布。