记录一下搭TJUPT发种🐔的过程

Posted by

作用

在TJUPT搭一个自动发布美剧的发种🐔。

实现方式

用R酱的Python版种🐔:Rhilip: Pt-Autoseed。自动监控Trasmission的任务,下载完成后在原站寻找有无相应的种子,有的话就复制简介发布,没有的话就不发。

步骤

    • 配置服务器环境,安装发种机依赖
      – Transmission
      – Flexget
      – MediaInfo
      – ffmpeg
      当然可以直接用星大脚本安装
      – Mysql

      apt-get -y install mysql-server

      – Python3(一般都有)和依赖的库

      apt-get -y install python3-pip python3-lxml
      pip3 install pymysql transmissionrpc requests bs4 html2bbcode
    • 获取Autoseed
      git clone https://github.com/Rhilip/Pt-Autoseed.git
      cd Pt-Autoseed
      cp setting.py usersetting.py

配置

nano usersetting.py #dbq我不会用vim
# -*- coding: utf-8 -*-
# Copyright (c) 2017-2020 Rhilip <rhilipruan@gmail.com>
# Licensed under the GNU General Public License v3.0
 
import time
 
# -*- Main Setting about Autoseed,Transmission,Database -*-
# Autoseed
SLEEP_TIME = 60 * 3  #可以改
CYCLE_CHECK_RESEEDER_ONLINE = 60 * 5 #可以改
CYCLE_DEL_TORRENT_CHECK = 60 * 60 * 24 #可以改
REQUESTS_TIMEOUT = 20 #不用改
 
# Transmission
trans_address = "127.0.0.1" 
trans_port = 9099
trans_user = "hhhhhhhh"
trans_password = "12345678"
trans_watchdir = "" # 不用写
trans_downloaddir = "/" # 下载到哪应该和你flexget下载的目录一样
 
# Database_MySQL
db_address = "localhost"
db_port = 3306
db_user = "root" 
db_password = "" 
db_name = "TJUPT" # 数据库你要自己建,到时候source导入数据就行
# -*- End of Main Setting -*-
 
# -*- Reseed Site Setting -*-
# """Byrbt"""
site_byrbt = {
    "status": False,  # default: False
    "cookies": "",  # raw_cookies
    "passkey": "",
}
# """NPUBits"""
site_npubits = {
    "status": False,
    "cookies": "",
    "passkey": "",
}
# """MTPT(nwsuaf6)"""
site_nwsuaf6 = {
    "status": False,
    "cookies": "",
    "passkey": "",
}
# """TJUPT"""
site_tjupt = {
    "status": True, # 开开开
    "cookies": "", # 当然这个cookie你就要一直保持登陆了
    "passkey": "", # 写就行
}
# """HUDBT"""
site_hudbt = {
    "status": False,
    "cookies": "",
    "passkey": "",
}
# """OurBits"""
site_ourbits = {
    "status": False,
    "cookies": "",
    "passkey": "",
}
# -*- End of Reseed Site Setting -*-
 
# -*- Feeding Torrent Setting -*-
# Reseed_Torrent_Setting
torrent_maxUploadRatio = 3 #这部分主要问你打算做种多久
torrent_minSeedTime = 561600
torrent_maxSeedTime = 604800
# -*- End of Feeding Torrent Setting -*-
 
# -*- Show status Setting -*-
# Show Site
web_url = "http://"  # demo网站的url 这部分不用写
web_loc = "/var/www"  # demo网站在服务器上的地址
 
# Logging
logging_debug_level = False  # debug model
logging_filename = "autoseed.log"
logging_file_maxBytes = 5 * 1024 * 1024
logging_format = "%(asctime)s - %(levelname)s - %(threadName)s - %(funcName)s - %(message)s"
logging_datefmt = "%m/%d/%Y %I:%M:%S %p"
 
# ServerChan
"具体见:http://sc.ftqq.com/,用于向微信通知发种机发布状态"
ServerChan_status = False
ServerChan_SCKEY = ""
# -*- End of Show status Setting -*-
 
# -*- Extended description Setting -*-
min_time = int(torrent_minSeedTime / 86400)
max_time = int(torrent_maxSeedTime / 86400)
 
#后面这就是你要发布的模板了,True代表那部分启用。
extend_descr_raw = {
    "before": {  # Key : min_reseed_time, max_reseed_time
        "status": True,
        "bbcode": """
        [quote]
        [*]这是一个自动发种的文件,所有信息以主标题或者文件名为准,简介信息采用本站之前相关种子信息,若发现有误请以"举报"或"留言"的形式通知工作人员审查和编辑。
        [*]欢迎下载、辅种、分流。保种{min_reseed_time}-{max_reseed_time}天。断种恕不补种。
        [*]如果发布档较大,请耐心等待校验。
        [*]有关更新说明请查看对应 Github :[url=https://github.com/Rhilip/Pt-Autoseed]Rhilip/Pt-Autoseed[/url],申请搬运,请发Issues留言。
        [/quote]""".format(min_reseed_time=min_time, max_reseed_time=max_time),
        "html": """
        <fieldset class="autoseed">
            <legend><b>Quote:</b></legend>
            <ul>
                <li>这是一个远程发种的文件,所有信息以主标题或者文件名为准,简介信息采用本站之前信息,若发现有误请以"举报"或"留言"的形式通知工作人员审查和编辑。</li>
                <li>欢迎下载、辅种、分流。保种{min_reseed_time}-{max_reseed_time}天。断种恕不补种。</li>
                <li>如果发布档较大,请耐心等待校验。</li>
                <li>请勿上传机翻字幕,如有发现请"举报"。</li>
                <li>有关更新说明请查看对应 Github : <a href="https://github.com/Rhilip/Pt-Autoseed" target="_blank">Rhilip/Pt-Autoseed</a> ,申请搬运,请发Issues留言。</li>
            </ul>
        </fieldset>
        """.format(min_reseed_time=min_time, max_reseed_time=max_time)
    },
    "thumbnails": {  # Key : img_url
        "status": False,
        "bbcode": """
        [quote][color=Red]以下是Autoseed自动完成的截图,不喜勿看 [/color]
        [img]{img_url}[/img]
        [/quote]""",
        "html": """
        <fieldset class="autoseed">
            <legend><b>自动截图</b></legend>
                <ul>
                    <li><span style="color:red">以下是<a href="//github.com/Rhilip/Byrbt-Autoseed" target="_blank">Autoseed</a>自动完成的截图,不喜勿看。</span></li>
                </ul>
                <img src="{img_url}" style="max-width: 100%">
        </fieldset>
        """
    },
    "mediainfo": {  # Key : info
        "status": True,
        "bbcode": "[quote=MediaInfo (自动生成,仅供参考)]{info}[/quote]",
        "html": """
        <fieldset class="autoseed">
            <legend><b>MediaInfo:(自动生成,仅供参考)</b></legend>
            <div id="mediainfo">{info}</div>
        </fieldset>
        """
    },
    "clone_info": {  # Key : torrent_id
        "status": True,
        "bbcode": "[quote=Clone Info]该种子信息克隆自本站种子: [url=/details.php?id={torrent_id}&hit=1]{torrent_id}[/url][/quote]",
        "html": """
        <div class="byrbt_info_clone autoseed" data-clone="{torrent_id}" data-version="Autoseed" style="display:none">
            <a href="https://github.com/Rhilip/Pt-Autoseed" target="_blank">Powered by Rhilip's Autoseed</a>
        </div>
        """
    }
}
# -*- End of Extended description Setting -*-
 
 
# Other Function
def pre_delete_judge(torrent) -> bool:
    """
    According to the incoming torrent's information to determine whether can be deleted or not,
    Default process: Match Minimal time -> Match Maximum time or Maximum upload Ratio
 
    :param torrent: class transmissionrpc.Torrent
    :return: bool, True if Meet the criteria
    """
    judge = False
    # Determine conditions
    if torrent.status == "seeding":
        torrent_live_time = int(time.time() - torrent.addedDate)
        if torrent_live_time >= torrent_minSeedTime and \
                (torrent.uploadRatio >= torrent_maxUploadRatio or torrent_live_time >= torrent_maxSeedTime):
            judge = True  # Meet the criteria, return True
 
    return judge[/py]
因为TJUPT套了Cloudfare,所以我们还要打开下载种子的选项:
<pre lang="bash" line="0" escaped="true" >nano ./Pt-Autoseed/extractors/base/nexusphp.py[/bash]
<pre lang="python" line="0" escaped="true" >...
def __init__(self, status, cookies, passkey, **kwargs):
        super().__init__(status, cookies, **kwargs)
 
        # -*- Assign the based information -*-
        self.passkey = passkey
 
        # -*- Assign Enhanced Features -*-
        """
        Enhance Feature for `NexusPHP` Reseeder.
        Those key-values will be set as default value unless you change it in your user-settings.
        The name of those key should be start with "_" and upper.
 
        Included:
        1. _UPLVER                : default "no",  Enable to Release anonymously.
        2. _AUTO_THANK            : default True,  Enable to Automatically thanks for additional Bones.
        3. _DEFAULT_CLONE_TORRENT : default None,  When not find the clone torrent, use it as default clone_id
        4. _FORCE_JUDGE_DUPE_LOC  : default False, Judge torrent is dupe or not in location before post it to PT-site.
        5. _GET_CLONE_ID_FROM_DB  : default True,  Enable to get clone torrent's id from database first, then search.
        6. _ALLOW_CAT             : default None,  Used to limit the reseed torrent category
        7. _DOWNLOAD_TORRENT      : default False, Download Torrent to temp folder then add to transmission
 
        """
        self._UPLVER = "yes" if kwargs.setdefault("anonymous_release", True) else "no"
        self._AUTO_THANK = kwargs.setdefault("auto_thank", True)
        self._DEFAULT_CLONE_TORRENT = kwargs.setdefault("default_clone_torrent", None)
        self._FORCE_JUDGE_DUPE_LOC = kwargs.setdefault("force_judge_dupe_loc", False)
        self._GET_CLONE_ID_FROM_DB = kwargs.setdefault("get_clone_id_from_db", True)
        self._ALLOW_CAT = kwargs.setdefault("allow_cat", None)
        self._DOWNLOAD_TORRENT = kwargs.setdefault("download_torrent", True) # 这里改成True
...

默认的只发布HDTV/WEB-DL,但你可以改,加上Webrip/WEB之类的

nano ./Pt-Autoseed/utils/pattern.py
...
pattern_group = [
    re.compile(  # Series (Which name match with 0day Source,see https://scenerules.org/t.html?id=tvx2642k16.nfo 16.4)
        "\.?(?P<full_name>(?P<search_name>[\w\-. ]+?)[. ]"
        "(?P<episode>([Ss]\d+)?[Ee][Pp]?\d+(-[Ee]?[Pp]?\d+)?|[Ss]\d+|Complete).+?"
        "(HDTV|hdtv|BluRay|WEB|WEB-DL|HDTVrip|web|Webrip|webrip|WEBRip).+?(-(?P<group>.+?))?)" # 这里就可以随便改
        "(\.(?P<filetype>\w+)$|$)"
    ),
    re.compile(  # Anime - One_piece(Skytree)
        "(?P<full_name>\[(?P<group>Skytree)\]\[海贼王\]\[(?P<search_name>One_Piece)\]"
        "\[(?P<episode>\d+)\]\[GB_JP\]\[X264_AAC\]\[720P\]\[CRRIP\]\[天空树双语字幕组\])"
        "(\.(?P<filetype>mp4)$|$)"
    ),
    re.compile(  # Anime - Group: 八重樱字幕组
        "(?P<full_name>\[(?P<group>八重[樱櫻]字幕[组組])\]\[.+?\]\[(?P<search_name>[^\[\]]+?)\]"
        "\[?(?P<episode>\d+(\.?\d+|-\d+|[ _]?[Vv]2)?)\]?.+?)"
        "(\.(?P<filetype>\w+)$|$)"
    ),
    re.compile(  # Anime - Foreign Group or group list Kamigami, LoliHouse
        "(?P<full_name>\[(?P<group>[^\[\]]+?)\] (?P<search_name>.+) - "
        "(?P<episode>\d+(\.?\d+|-\d+|[ _]?[Vv]2)?) \[.+?[Pp].+?\])"
        "(\.(?P<filetype>\w+)$|$)"
    ),
    re.compile(  # Anime - Normal Pattern
        "(?P<full_name>\[(?P<group>[^\[\]]+?)\](?P<n_s>\[)?(?P<search_name>[^\[\]]+)(?(n_s)\])"
        "\[?(?P<episode>\d+(\.?\d+|-\d+|[ _]?[Vv]2)?)\]?.+?)"
        "(\.(?P<filetype>\w+)$|$)"
    )
]

然后建立个数据库,source导入table.sql,这个就不用我写了吧

使用

直接运行

python3 run.py

其他问题

经常会碰到Autoseed自动暂停了种子但没有把他们删掉的情况,emmmm自己手动删应该就好了。
记录一下,下次直接照做就行了。

One comment

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注