A small Playwright-based keepalive daemon for MT-PT / M-Team accounts.
MT-PT accounts can be disabled when they stay inactive for too long. This tool keeps an already-authenticated browser session warm by visiting authenticated pages every day, opening one detail page, and alerting you when the session expires.
It does not bypass captcha, solve anti-bot challenges, or store your tracker password. You log in manually once, then Keeper reuses the local browser profile.
- Manual session bootstrap for captcha-protected login
- Persistent Playwright browser profile with cookies, localStorage, and IndexedDB
- Daily cron keepalive with configurable timezone
- Optional detail-page interaction for more realistic activity
- Ant Design modal handling with click, DOM click, and direct navigation fallbacks
- Telegram alerts for every run, including successful keepalive runs
- Successful Telegram alerts include current downloaded, uploaded, and ratio stats when available
- Slack/Discord-compatible webhook support
- Docker Compose and PM2 friendly
- Debug logs for selectors, candidate detail links, modals, and navigation
pnpm install
pnpm exec playwright install chromium
cp .env.template .envEdit .env:
MT_PT_BASE_URL=https://kp.m-team.cc/
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=Initialize the session on a machine with a display:
pnpm init-sessionLog in manually in the opened browser and complete captcha. Keeper saves the browser profile in .keeper/browser-profile.
Verify the saved session:
pnpm onceRun continuously:
pnpm daemonBy default it runs immediately on startup, then every day at 09:00 in Asia/Shanghai.
init-sessionopens a headed browser with a persistent profile.- You complete login and captcha manually.
onceordaemonopens the same profile in headless mode.- Keeper visits configured keepalive URLs.
- If still authenticated, it opens one detail link from the list page.
- If a login form, captcha page,
401, or403appears, the run is marked asexpiredand an alert is sent.
Keeper tries to click one detail/torrent link after the session check passes. This gives the site a more realistic interaction than loading only the index page.
Default link detection covers common patterns like /detail, /torrent, and text such as 详情 / Detail. Override it when needed:
KEEPER_DETAIL_LINK_SELECTOR='a[href*="/profile/detail/"]'If an announcement modal blocks the click, Keeper tries to close common Ant Design modal buttons first. Override the close target when needed:
KEEPER_MODAL_CLOSE_SELECTOR='.ant-modal-wrap button:has-text("我知道了")'If the modal still intercepts the pointer click, Keeper logs the modal summary, then falls back to a DOM click. If that still does not navigate, it opens the detail href directly.
Disable detail interaction:
KEEPER_INTERACTION_ENABLED=falseBy default Keeper visits MT_PT_BASE_URL. If your tracker refreshes tokens only on specific pages or API endpoints, configure multiple URLs:
KEEPER_KEEPALIVE_URLS=https://kp.m-team.cc/,https://kp.m-team.cc/user/profileUse comma-separated URLs.
Telegram:
TELEGRAM_BOT_TOKEN=123456:xxx
TELEGRAM_CHAT_ID=123456789Generic JSON webhook:
KEEPER_WEBHOOK_URL=https://example.com/webhookTelegram sends success notifications whenever TELEGRAM_BOT_TOKEN and
TELEGRAM_CHAT_ID are configured. Successful Telegram messages include the
current downloaded, uploaded, and ratio stats when they are available on the
page.
Generic webhook success notifications are disabled by default. Enable them with:
KEEPER_NOTIFY_SUCCESS=trueRun with debug logs:
LOG_LEVEL=debug pnpm onceThe logs include:
- keepalive URLs
- detail selectors and candidate links
- clicked detail target
- blocking modal text and close buttons
- fallback navigation result
When session detection needs tuning, use regex overrides:
MT_PT_SUCCESS_URL_PATTERN=
MT_PT_SUCCESS_TEXT_PATTERN=
MT_PT_EXPIRED_URL_PATTERN=
MT_PT_EXPIRED_TEXT_PATTERN=docker compose up -d --buildThe .keeper directory is mounted so browser session data and the latest status survive restarts.
You still need to initialize the session first on a machine that can show the browser, then keep or copy .keeper/browser-profile for the daemon.
pnpm build
pm2 start dist/index.js --name mt-pt-keeper -- daemon
pm2 saveWhen you get an expiry alert:
pnpm init-session| Variable | Default | Description |
|---|---|---|
MT_PT_BASE_URL |
https://kp.m-team.cc/ |
Site entry URL. |
KEEPER_KEEPALIVE_URLS |
MT_PT_BASE_URL |
Comma-separated authenticated URLs to visit. |
KEEPER_CRON |
0 9 * * * |
Daily schedule. |
KEEPER_TIMEZONE |
Asia/Shanghai |
Cron timezone. |
KEEPER_HEADLESS |
true |
Headless mode for once and daemon; init-session is always headed. |
KEEPER_USER_DATA_DIR |
.keeper/browser-profile |
Persistent Playwright profile path. |
KEEPER_STATE_FILE |
.keeper/state.json |
Last run status. |
KEEPER_SCREENSHOT_DIR |
.keeper/screenshots |
Failure screenshot path. |
KEEPER_INTERACTION_ENABLED |
true |
Click one detail link after the session check. |
KEEPER_DETAIL_LINK_SELECTOR |
auto | Optional selector for detail links. |
KEEPER_MODAL_CLOSE_SELECTOR |
auto | Optional selector for closing announcement modals. |
LOG_LEVEL |
info |
Set to debug for selector scan details. |
MT_PT_USERNAME_SELECTOR |
auto | Optional selector to help detect a login page. |
MT_PT_PASSWORD_SELECTOR |
auto | Optional selector to help detect a login page. |
MT_PT_SUCCESS_URL_PATTERN |
empty | Optional regex that marks session valid by URL. |
MT_PT_EXPIRED_URL_PATTERN |
empty | Optional regex that marks session expired by URL. |
MT_PT_SUCCESS_TEXT_PATTERN |
empty | Optional regex that marks session valid by page text. |
MT_PT_EXPIRED_TEXT_PATTERN |
empty | Optional regex that marks session expired by page text. |
KEEPER_NOTIFY_SUCCESS |
false |
Send success notifications to the generic webhook too. Telegram success notifications are always sent when Telegram is configured. |
KEEPER_WEBHOOK_URL |
empty | Optional Slack/Discord-compatible JSON webhook. |
TELEGRAM_BOT_TOKEN |
empty | Telegram bot token for alerts. |
TELEGRAM_CHAT_ID |
empty | Telegram chat id for alerts. |
- Do not commit
.envor.keeper. .keeper/browser-profilecontains authenticated session data.- This project is intended for personal account maintenance, not for bypassing tracker rules, captcha, or access controls.
- Respect the rules of the tracker you use.
MIT