A Go application that provides both JSON and Torznab APIs for local torrent files containing web seed URLs. This application acts as a local Torznab indexer similar to Jackett, but specifically designed for torrent files with web seeds.
- List torrents: Scans and parses
.torrentfiles from a local directory - JSON API: RESTful API for torrent information in JSON format
- Torznab API: Compatible with Torznab specification for integration with media servers
- Web seed support: Extracts and exposes web seed URLs from torrent files
- Proper info hash calculation: Uses SHA-1 hash of the info dictionary
- File download: Direct download of torrent files via HTTP
- Search functionality: Search torrents by name
- Real-time refresh: Ability to reload torrent list without restart
- Go 1.21 or higher
- Git
git clone <repository-url>
cd webseed2torznab
go mod tidy
go build -o webseed2torznab main.go# Run with default settings (./torrents directory, port 8080)
./webseed2torznab
# Specify custom torrents directory
./webseed2torznab /path/to/torrents
# Set custom port via environment variable
PORT=9090 ./webseed2torznab
# Set custom base URL
BASE_URL=http://example.com:8080 ./webseed2torznabPORT: Server port (default: 8080)BASE_URL: Base URL for the server (default: http://localhost:PORT)
GET /api/torrents
GET /api/torrents?q=search_term
GET /api/refresh
GET /api/torznab?t=caps
GET /api/torznab?t=search&q=search_term
GET /torrent/{filename}
GET /health
# Get all torrents
curl http://localhost:8080/api/torrents
# Search for torrents containing "avengers"
curl "http://localhost:8080/api/torrents?q=avengers"
# Refresh torrent list
curl -X POST http://localhost:8080/api/refresh# Get Torznab capabilities
curl "http://localhost:8080/api/torznab?t=caps"
# Search via Torznab
curl "http://localhost:8080/api/torznab?t=search&q=cube"
# Download a torrent file
curl -O "http://localhost:8080/torrent/Movie.2023.720p.WEBRip.x264.torrent"{
"status": "success",
"count": 5,
"torrents": [
{
"name": "Movie Title",
"info_hash": "72bdf5bd3ed8309db13e72983cc4a3acd4868d91",
"size": 2530433842,
"files": [
{
"path": ["Movie", "Movie.mkv"],
"length": 2530433842
}
],
"web_seeds": [
"http://example.com/path/to/file.mkv"
],
"created_by": "mktorrent 1.1",
"created_date": "2025-06-08T00:38:35+02:00",
"comment": "Sample torrent",
"file_path": "torrents/Movie.torrent"
}
]
}<rss version="2.0">
<channel>
<title>WebSeed2Torznab</title>
<description>Local torrent files with web seeds</description>
<link>http://localhost:8080</link>
<item>
<title>Movie Title</title>
<description>Sample torrent</description>
<link>http://localhost:8080/torrent/Movie.torrent</link>
<guid>72bdf5bd3ed8309db13e72983cc4a3acd4868d91</guid>
<pubDate>Sun, 08 Jun 2025 00:38:35 +0200</pubDate>
<size>2530433842</size>
<enclosure url="http://localhost:8080/torrent/Movie.torrent" length="2530433842" type="application/x-bittorrent"/>
<torznab:attr name="category" value="7000"/>
<torznab:attr name="size" value="2530433842"/>
<torznab:attr name="magneturl" value="magnet:?xt=urn:btih:72bdf5bd3ed8309db13e72983cc4a3acd4868d91&dn=Movie%20Title&ws=http%3A%2F%2Fexample.com%2Fpath%2Fto%2Ffile.mkv"/>
</item>
</channel>
</rss>- Add a new Torznab indexer in your media server
- Set the URL to:
http://your-server:8080/api/torznab - No API key required
- Test the connection
- 2000: Movies
- 5000: TV Shows
- 7000: Other
webseed2torznab/
├── main.go # Main application
├── go.mod # Go module dependencies
├── go.sum # Go module checksums
├── torrents/ # Directory containing .torrent files
│ ├── Movie1.torrent
│ ├── Movie2.torrent
│ └── ...
└── README.md # This file
The application automatically:
- Parses
.torrentfiles using bencode - Calculates proper SHA-1 info hashes
- Extracts file information (name, size, file list)
- Identifies web seed URLs from
url-listfield - Handles both single-file and multi-file torrents
The application specifically looks for and extracts web seed URLs from the url-list field in torrent files. These URLs are:
- Included in JSON responses as
web_seedsarray - Added to magnet links in Torznab responses as
wsparameters - Used to enable HTTP/HTTPS downloading alongside BitTorrent
- Graceful handling of corrupted torrent files
- Detailed logging of parsing errors
- Continues operation even if some torrents fail to parse
- Returns appropriate HTTP status codes
- No torrents loaded: Ensure
.torrentfiles exist in the torrents directory - Parsing errors: Check that torrent files are valid and not corrupted
- Port conflicts: Change the PORT environment variable if 8080 is in use
- Permission errors: Ensure the application has read access to the torrents directory
The application logs important events including:
- Number of torrents loaded on startup
- Parsing errors for individual torrent files
- Server startup information with endpoints
This project is provided as-is for educational and personal use.
Feel free to submit issues and enhancement requests.