diff --git a/10-systems/hosts/transmission.md b/10-systems/hosts/transmission.md index f85a93e..2b5ce7c 100644 --- a/10-systems/hosts/transmission.md +++ b/10-systems/hosts/transmission.md @@ -46,6 +46,32 @@ Adding a rutor.info **magnet** via `torrent-add` (filename=magnet:...) can stall forever: metadata never arrives, `peersConnected` stays 0 even though trackers report peers. Root cause observed: the swarm peers were unreachable from the VM (TCP connect to every peer timed out/refused — NAT deadlock, both sides behind NAT), and the magnet carried only 2 trackers. Fix that worked: download the **.torrent file directly on the VM** (`curl -o /tmp/x.torrent https://d.rutor.info/download/` — VM has working internet) and add it via `metainfo` (base64). Note: re-adding the same info_hash while the magnet torrent exists returns `torrent-duplicate` and does NOT refresh metadata — remove the stalled torrent first (`torrent-remove`, `delete-local-data: false`), then add the .torrent. Extra public trackers can be attached with `torrent-set` `trackerAdd`. +## Helper script: add-torrent.py (2026-09-30) + +Deployed at `/home/ubuntu/bin/add-torrent.py` on the VM (master copy in Navi workspace, `workspace/add-torrent.py`). Wraps the whole manual cycle into one command; prefer it over hand-rolled RPC calls. + +Usage: + +``` +add-torrent.py [--dir DIR] [--paused] [--no-trackers] [--dry-run] [--json] +add-torrent.py ls +add-torrent.py move +``` + +What it does: + +- rutor page URL (`rutor.info/torrent//...`) is auto-converted to the direct link `d.rutor.info/download/` and the .torrent is downloaded on the VM (avoids the magnet-stall gotcha above); +- downloaded file is bencode-validated (rejects HTML error pages); +- duplicates are detected by info_hash BEFORE adding (exit 3, prints existing id/name/dir); +- free space is checked on the target mount (min 5 GB or size×1.1 when known); +- target dir: explicit `--dir`, else films → `secraid5_storage/films`, season/serial in the name → `NetTera8/serials`; +- adds via RPC `metainfo`, attaches 10 public trackers (`trackerAdd`), prints status (peers, speed, ETA); +- RPC credentials are read from the Flood config `torrentClient` section; session id cached in `/tmp/.tr_rpc_session`. + +Exit codes: 0 ok, 1 bad args/not found, 2 download/parse fail, 3 duplicate, 4 no space, 5 RPC failure. + +Tested 2026-09-30: `ls`, dry-run (rutor URL → download → parse → dir choice), dedup via both .torrent and magnet, magnet btih parsing, `move` with bad id. Two bugs found and fixed during testing: multi-file size parsing (bencode decoder returns `(value, raw)` tuples), and `move` of a non-existent id silently succeeded (Transmission RPC ignores unknown ids) — now checked via `torrent-get` first. + ## Known incident (2026-09-29) Torrent `Twilight.2008.BDRip.1080p.Rus.mkv` (id 8) was added to `firstraid5_storage/films` and failed with `error=3 No space left on device` — firstraid5 was 100% full. Moved to `secraid5_storage/films` via `torrent-set-location` and restarted; download resumed normally (~4.3 MB/s, 9 peers). Rule: check `df` on the target mount before adding torrents. @@ -54,3 +80,4 @@ - 2026-09-30: torrent id 9 `The Gentlemen (Season 2) WEB-DL 1080p` (rutor.info 1107212, WEB-DL 1080p, dub Red Head Sound, 8 episodes, 24.69 GB) added to `/home/ubuntu/jf_storage/NetTera8/serials`, downloading normally (~0.5 MB/s at start, 52 seeds). Season 1 of the same show already lives on the same mount. - 2026-09-30: torrent id 12 `Кобра.Cobra.1986.UHD.BDRip-HEVC.1080p.mkv` (rutor.info 780564, UHD BDRip-HEVC 1080p from RIPS CLUB, Arrow Films remaster, D/P/P2/A/L1, 10.32 GB) added to `/home/ubuntu/jf_storage/secraid5_storage/films`, downloading (~1.2 MB/s, 3 peers). First attempt with rutor 1043082 (BDRip 1080p x264, 12.32 GB) stalled at 0 peers — magnet-only add + dead swarm (see gotcha above); removed. +- 2026-09-30: helper script `add-torrent.py` deployed to `/home/ubuntu/bin/` on the VM and tested (see section above). diff --git a/90-maintenance/pending-changes/20260930205451-da215198.json b/90-maintenance/pending-changes/20260930205451-da215198.json new file mode 100644 index 0000000..cfdeebb --- /dev/null +++ b/90-maintenance/pending-changes/20260930205451-da215198.json @@ -0,0 +1,19 @@ +{ + "id": "20260930205451-da215198", + "kind": "doc", + "target": "10-systems/hosts/transmission.md", + "summary": "transmission.md: добавлена секция про helper-скрипт add-torrent.py (деплой, usage, логика, exit-коды, тесты)", + "reason": "Задеплоен и протестирован helper-скрипт add-torrent.py на Transmission VM — документирую его использование, чтобы следующие добавления торрентов шли через одну команду вместо ручного RPC-цикла.", + "payload": { + "content": "---\nowner: gmikcon\nstatus: active\nlast_reviewed: 2026-09-30\nreview_interval: 90d\nconfidence: high\nsource_of_truth: ssh-host\n---\n\n# Transmission VM\n\nKVM VM on `hp-proliant-dl380-g6` (libvirt, `qemu:///system`), 2 vCPU / 2 GiB RAM, autostart enabled. Verified live over SSH 2026-09-29.\n\n## Address and access\n\n- LAN: `192.168.1.154`\n- SSH: `ubuntu@192.168.1.154` (password same as Navi swarm peers, see gnexus-creds secret `79875411-a4bd-46d3-b89d-4b2d286ca11c`)\n\n## Services\n\n- **Flood** (web UI for the torrent client): `node /usr/bin/flood --host 0.0.0.0 --port 3000 --config /home/ubuntu/.flood/config.json --allowedpath /home/ubuntu/jf_storage`. Public URL: https://transmission.gnexus.space (nginx on internal-proxy-vps `.226` → `http://192.168.1.154:3000`).\n- **transmission-daemon 2.94**: RPC on `127.0.0.1:9091`, path `/transmission/rpc`, rpc-version 15. Credentials are in the Flood config (`torrentClient` section of `/home/ubuntu/.flood/config.json`): user `gmikcon`.\n- Gotcha: Flood config points the client at `http://192.168.68.210:9091`, which does not respond from the VM; the RPC is reachable on `127.0.0.1:9091`. Flood itself works.\n\n## Storage (NFS mounts on the VM)\n\n| Mount on VM | NFS export | Free space (2026-09-30) | Contents |\n| --- | --- | --- | --- |\n| `/home/ubuntu/jf_storage/firstraid5_storage` | `192.168.1.130:/mnt/firstraid5` | 71 GB (97% used) — was 100% full on 2026-09-29, do NOT use for new downloads | films, games, music, serials |\n| `/home/ubuntu/jf_storage/secraid5_storage` | `192.168.1.130:/mnt/secraid5/jellyfin_storage` | ~198 GB (91% used) | films, serials |\n| `/home/ubuntu/jf_storage/NetTera8` | `192.168.1.131:/mnt/NetTera8` | ~250 GB (97% used) | films, serials |\n\nDefault transmission `download-dir`: `/home/ubuntu/jf_storage/secraid5_storage`. Flood diskScanPaths also list `NetTera1` and `eserv_storage`, which are not currently mounted.\n\nSerials layout on NetTera8: `/home/ubuntu/jf_storage/NetTera8/serials/` — e.g. `The Gentlemen (Season 1) WEB-DL 1080p`, `The Gentlemen (Season 2) WEB-DL 1080p`.\n\n## Adding torrents via RPC (verified 2026-09-29)\n\n1. Get session id: `curl -s -i http://127.0.0.1:9091/transmission/rpc` → read `X-Transmission-Session-Id` from the 409 response.\n2. Add: `torrent-add` with `metainfo` (base64 of the .torrent file), `download-dir`, `paused: false`.\n3. Verify: `torrent-get` with fields `status, percentDone, rateDownload, downloadDir`.\n4. Move a torrent: `torrent-set-location` with `location` and `move: true`, then `torrent-start`.\n5. Rename a torrent's top folder: `torrent-rename-path` with `path` (current name) and `name` (new name) — used to give season folders clean names matching Jellyfin layout.\n\n### Gotcha: magnet-only adds can stall (2026-09-30)\n\nAdding a rutor.info **magnet** via `torrent-add` (filename=magnet:...) can stall forever: metadata never arrives, `peersConnected` stays 0 even though trackers report peers. Root cause observed: the swarm peers were unreachable from the VM (TCP connect to every peer timed out/refused — NAT deadlock, both sides behind NAT), and the magnet carried only 2 trackers. Fix that worked: download the **.torrent file directly on the VM** (`curl -o /tmp/x.torrent https://d.rutor.info/download/` — VM has working internet) and add it via `metainfo` (base64). Note: re-adding the same info_hash while the magnet torrent exists returns `torrent-duplicate` and does NOT refresh metadata — remove the stalled torrent first (`torrent-remove`, `delete-local-data: false`), then add the .torrent. Extra public trackers can be attached with `torrent-set` `trackerAdd`.\n\n## Helper script: add-torrent.py (2026-09-30)\n\nDeployed at `/home/ubuntu/bin/add-torrent.py` on the VM (master copy in Navi workspace, `workspace/add-torrent.py`). Wraps the whole manual cycle into one command; prefer it over hand-rolled RPC calls.\n\nUsage:\n\n```\nadd-torrent.py [--dir DIR] [--paused] [--no-trackers] [--dry-run] [--json]\nadd-torrent.py ls\nadd-torrent.py move \n```\n\nWhat it does:\n\n- rutor page URL (`rutor.info/torrent//...`) is auto-converted to the direct link `d.rutor.info/download/` and the .torrent is downloaded on the VM (avoids the magnet-stall gotcha above);\n- downloaded file is bencode-validated (rejects HTML error pages);\n- duplicates are detected by info_hash BEFORE adding (exit 3, prints existing id/name/dir);\n- free space is checked on the target mount (min 5 GB or size×1.1 when known);\n- target dir: explicit `--dir`, else films → `secraid5_storage/films`, season/serial in the name → `NetTera8/serials`;\n- adds via RPC `metainfo`, attaches 10 public trackers (`trackerAdd`), prints status (peers, speed, ETA);\n- RPC credentials are read from the Flood config `torrentClient` section; session id cached in `/tmp/.tr_rpc_session`.\n\nExit codes: 0 ok, 1 bad args/not found, 2 download/parse fail, 3 duplicate, 4 no space, 5 RPC failure.\n\nTested 2026-09-30: `ls`, dry-run (rutor URL → download → parse → dir choice), dedup via both .torrent and magnet, magnet btih parsing, `move` with bad id. Two bugs found and fixed during testing: multi-file size parsing (bencode decoder returns `(value, raw)` tuples), and `move` of a non-existent id silently succeeded (Transmission RPC ignores unknown ids) — now checked via `torrent-get` first.\n\n## Known incident (2026-09-29)\n\nTorrent `Twilight.2008.BDRip.1080p.Rus.mkv` (id 8) was added to `firstraid5_storage/films` and failed with `error=3 No space left on device` — firstraid5 was 100% full. Moved to `secraid5_storage/films` via `torrent-set-location` and restarted; download resumed normally (~4.3 MB/s, 9 peers). Rule: check `df` on the target mount before adding torrents.\n\n## Recent activity\n\n- 2026-09-30: torrent id 9 `The Gentlemen (Season 2) WEB-DL 1080p` (rutor.info 1107212, WEB-DL 1080p, dub Red Head Sound, 8 episodes, 24.69 GB) added to `/home/ubuntu/jf_storage/NetTera8/serials`, downloading normally (~0.5 MB/s at start, 52 seeds). Season 1 of the same show already lives on the same mount.\n- 2026-09-30: torrent id 12 `Кобра.Cobra.1986.UHD.BDRip-HEVC.1080p.mkv` (rutor.info 780564, UHD BDRip-HEVC 1080p from RIPS CLUB, Arrow Films remaster, D/P/P2/A/L1, 10.32 GB) added to `/home/ubuntu/jf_storage/secraid5_storage/films`, downloading (~1.2 MB/s, 3 peers). First attempt with rutor 1043082 (BDRip 1080p x264, 12.32 GB) stalled at 0 peers — magnet-only add + dead swarm (see gotcha above); removed.\n- 2026-09-30: helper script `add-torrent.py` deployed to `/home/ubuntu/bin/` on the VM and tested (see section above)." + }, + "status": "applied", + "created_at": "2026-09-30T20:54:51Z", + "updated_at": "2026-09-30T20:54:53Z", + "applied_at": "2026-09-30T20:54:53Z", + "validation": { + "status": "ok", + "issue_count": 0, + "issues": [] + } +}