如何优雅地刷 PT

本文最后更新于:2023年2月20日 中午

前言

各大 PT 站一直是我下载高清影视资源、动漫 BD 的好帮手,玩了几年了,虽然没买啥设备,但是当刷子还是有了不少经验(

PT(英语:Private Tracker)是一种改良自 BitTorrent 协议P2P下载方式,“Private Tracker”指私有种子服务器。与 BT 最大的不同点为:可进行私密范围下载,并且记录每一个用户的详细数据。

From Wikipedia

以前刷 PT 都是用的星大的一键脚本,安装好后就基本上有了需要的环境,自己在安装一下Autoremove-torrents,基本可以满足我的需求。

不过每次更换服务器都需要很多时间再次编译安装,总归还是麻烦了。最近发现了一个 大佬的项目,基本上把自动 RSS 免费热种、自动删除旧种子、自动签到做齐了,功能十分强大。

我最终采用的是 qBittorrent+Flexget 的方案,用 Docker 搭建,上述大佬的项目为 Flexget 插件,目前已经整合到镜像中。

qBittorrent

由于用 Deluge 总是把机器刷死机,可能是 3O 配置太差了。。。所以我就改用 qBittorrent 了。同时也建议将 Flexget 搭建在不同的机器,因为 Flexget 也很吃内存和 CPU(毕竟是万恶的 Python)。

首先安装好 DockerDocker Compose,这里就不赘述。

然后写docker-compose.yml

version: '3'

services:
  qbittorrent:
    image: linuxserver/qbittorrent:14.2.3.99202004172232-6962-29e9594ubuntu18.04.1-ls73
    container_name: qbittorrent
    restart: always
    ports:
      - 8080:8080
      - 53168:53168/udp
      - 53168:53168
    environment:
      PUID: 1000
      PGID: 1000
      TZ: Asia/Shanghai
      UMASK_SET: 022
      WEBUI_PORT: 8080
    volumes:
      - /path/to/config:/config
      - /path/to/downloads:/downloads

注意 qBittorrent 要看你的 PT 站具体要求什么版本,我用的是 4.2.3,其他的可以去 这里 查。

然后输入命令:

docker-compose up -d

默认登陆端口为 8080,账户密码为:admin/adminadmin,登录qBittorrent 的 Web 后记得将用于传入连接的端口改为53168

Flexget

Flexget 安装

在一台配置较好的 VPS 上(我用的是 GCP)安装Flexget

docker-compose.yml

version: '3'

services:
    flexget:
      image: ghcr.io/apocalypsor/flexget
      container_name: flexget
      environment:
        FG_WEBUI_PASSWD: PASSWD # 替换为你自己的密码,登录 Web 用
        FG_LOG_LEVEL: INFO
        TZ: Asia/Shanghai
        PUID: 1000
        PGID: 1000
      volumes:
        - ./config:/config
        - /config/plugins
        - ./downloads:/downloads
      ports:
        - 127.0.0.1:53539:3539
      restart: always
      logging:
        driver: "json-file"
        options:
          max-size: "200k"

然后输入命令:

docker-compose up -d

Flexget将监听在 3539 端口。

Flexget 配置

以下是我的 Flexget 配置文件的示例:

web_server:
  bind: '0.0.0.0'
  port: 3539

schedules:
  - tasks: [U2, MTeam]
    interval:
      minutes: 1

  - tasks: [ol_resume, nas_resume, ol_delete, nas_delete, ol_modify, nas_modify, ol_clean, nas_clean]
    interval:
      minutes: 5
  
  - tasks: [sign_in]
    schedule:
      hour: 8-23/1

variables:
  headers:
    user_agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36'

templates:
  ## Online
  # 从 qBittorrent 获取数据
  ol_from_qbittorrent_template:
    from_qbittorrent_mod: &ol_from_qbittorrent_mod
      host: <OL_HOST>
      port: <OL_PORT>
      use_ssl: false
      username: <OL_USERNAME>
      password: <OL_PASSWORD>

  # 基础
  ol_qbittorrent_base_template:
    qbittorrent_mod:
      <<: *ol_from_qbittorrent_mod

  # 添加
  ol_qbittorrent_add_template:
    qbittorrent_mod:
      action:
        add:
          category: RSS
          autoTMM: yes
          reject_on:
            dl_limit: 5242880
            dl_speed: no

  # 删除
  ol_qbittorrent_delete_keeper_template:
    qbittorrent_mod:
      action:
        remove:
          keeper:
            delete_files: yes
            keep_disk_space: 36
            dl_limit_interval: 900
  
  ## NAS
  # 从 qBittorrent 获取数据
  nas_from_qbittorrent_template:
    from_qbittorrent_mod: &nas_from_qbittorrent_mod
      host: <NAS_HOST>
      port: <NAS_PORT>
      use_ssl: false
      username: <NAS_USERNAME>
      password: <NAS_PASSWORD>

  # 基础
  nas_qbittorrent_base_template:
    qbittorrent_mod:
      <<: *nas_from_qbittorrent_mod

  # 添加
  nas_qbittorrent_add_template:
    qbittorrent_mod:
      action:
        add:
          category: RSS
          autoTMM: yes
          reject_on:
            dl_limit: no
            dl_speed: no
  
  # 删除
  nas_qbittorrent_delete_keeper_template:
    qbittorrent_mod:
      action:
        remove:
          keeper:
            delete_files: yes
            keep_disk_space: 90
            alt_dl_limit_on_succeeded: 5242880
            dl_limit_interval: 900

  ## 多种操作
  # 清理
  qbittorrent_delete_cleaner_template:
    qbittorrent_mod:
      action:
        remove:
          cleaner:
            delete_files: yes

  # 修改
  qbittorrent_modify_template:
    qbittorrent_mod:
      action:
        modify:
          tag_by_tracker: true

  # 恢复
  qbittorrent_resume_template:
    qbittorrent_mod:
      action:
        resume:
          recheck_torrents: true

  # 种子大小筛选
  content_size:
    content_size:
      min: 10
      max: 50000
      strict: no

tasks:
  U2:
    rss: 
      url: https://u2.dmhy.org/torrentrss.php?rows=50&trackerssl=1&passkey=<PASSKEY>&linktype=dl
      other_fields:
        - link
    nexusphp:
      cookie: '<U2_COOKIE>'
      user-agent: '{? headers.user_agent ?}'
      comment: yes
      discount:
        - free
        - 2xfree
      seeders:
        min: 1
    verify_ssl_certificates: no
    content_size:
      min: 10
      max: 120000
      strict: no
    template:
      - nas_qbittorrent_base_template
      - nas_qbittorrent_add_template

  MTeam:
    rss: https://pt.m-team.cc/
    accept_all: true
    verify_ssl_certificates: no
    content_size:
      min: 10
      max: 50000
      strict: no
    template:
      - ol_qbittorrent_base_template
      - ol_qbittorrent_add_template

  resume: &resume
    priority: 2
    disable: [seen, seen_info_hash, retry_failed]
    if:
      - qbittorrent_state == 'pausedUP' and qbittorrent_downloaded == 0 and qbittorrent_added_on > now - timedelta(hours=1): accept

  delete: &delete
    priority: 3
    disable: [seen, seen_info_hash, retry_failed]
    if:
      - qbittorrent_category in ['RSS'] and (qbittorrent_last_activity < now - timedelta(days=2) or qbittorrent_added_on < now - timedelta(days=7)): accept
      - qbittorrent_state == 'missingFiles' or (qbittorrent_state in ['pausedDL'] and qbittorrent_completed == 0): accept
    sort_by: qbittorrent_last_activity

  modify: &modify
    priority: 4
    disable: [seen, seen_info_hash, retry_failed]
    accept_all: yes

  clean: &clean
    priority: 5
    disable: [seen, seen_info_hash, retry_failed]
    regexp:
      accept:
        - '[Tt]orrent not registered with this tracker'
        - 'Torrent banned'
        - 'Unregistered torrent'
      from: qbittorrent_tracker_msg

  ol_resume:
    <<: *resume
    template:
      - ol_from_qbittorrent_template
      - ol_qbittorrent_base_template
      - qbittorrent_resume_template
  
  nas_resume:
    <<: *resume
    template:
      - nas_from_qbittorrent_template
      - nas_qbittorrent_base_template
      - qbittorrent_resume_template

  
  ol_delete:
    <<: *delete 
    template:
      - ol_from_qbittorrent_template
      - ol_qbittorrent_base_template      
      - ol_qbittorrent_delete_keeper_template
  
  nas_delete:
    <<: *delete
    template:
      - nas_from_qbittorrent_template
      - nas_qbittorrent_base_template
      - nas_qbittorrent_delete_keeper_template
  
  ol_modify:
    <<: *modify
    template:
      - ol_from_qbittorrent_template
      - ol_qbittorrent_base_template
      - qbittorrent_modify_template
  
  nas_modify:
    <<: *modify
    template:
      - nas_from_qbittorrent_template
      - nas_qbittorrent_base_template
      - qbittorrent_modify_template

  ol_clean:
    <<: *clean
    template:
      - ol_from_qbittorrent_template
      - ol_qbittorrent_base_template
      - qbittorrent_delete_cleaner_template
  
  nas_clean:
    <<: *clean
    template:
      - nas_from_qbittorrent_template
      - nas_qbittorrent_base_template
      - qbittorrent_delete_cleaner_template
  
  # 自动签到
  sign_in:
    auto_sign_in:
      user-agent: '{? headers.user_agent ?}'
      # command_executor: 'http://standalone-chrome:4444/wd/hub'
      max_workers: 4
      # baidu ocr 参数
      aipocr:
        app_id: '<BAIDU_APP_ID>'
        api_key: '<BAIDU_API_KEY>'
        secret_key: '<BAIDU_SECRET_KEY>'
      sites:
        pthome: '<PTHOME_COOKIE>'
    accept_all: yes
    seen:
      fields:
        - title

❗注意:

  • 自行将形如 <foobar> 的变量替换为自己的信息,关于 Cookie 的获取可以看 此教程
  • 务必要申请自行 Baidu OCR,申请网址: 百度 AI 开放平台
  • 自动签到已经适配的站点可在 此文件夹 中找到。
  • 该配置具有时效性,请自行参考 项目 wiki

这样子 Flexget 就会定时自行下载 PT 站的免费种子、自行删除旧种,全自动辅种,还能够帮我们签到等,无需其他额外的软件。

后记

经过这一波折腾,可以说是彻底的解放了双手,同时有需要的话还可以用 TG 通知签到情况、机器占用情况等,可以说是十分好用了。

感谢各位大佬们写的好用的插件~


如何优雅地刷 PT
https://blog.dov.moe/posts/27725/
作者
Dov
发布于
2020年6月30日
许可协议