bitmagnet Documentation
repository·main·Indexed 26 days ago
https://github.com/bitmagnet-io/bitmagnetA self-hosted BitTorrent indexer and search engine featuring a DHT crawler, content classification, a web UI, and a GraphQL API. It includes native integration with the Servarr stack and a customizable classifier using Common Expression Language (CEL) and YAML-based workflows for content type determination and automated torrent management.
What's inside bitmagnet
- bitmagnet is a self-hosted BitTorrent indexer that combines several core functionalities: a DHT crawler, a content classifier, and a torrent search engine. It provides a web UI for interaction, a GraphQL API for programmatic access, and native integration with the Servarr stack.
Overview of bitmagnet API and Web endpoints
mainbitmagnet provides several endpoints for user interface access, data querying, and system integration:
/: Redirects to the web user interface./webui: The main web user interface./graphql: The GraphQL API, which includes the GraphiQL browser interface for interactive querying./torznab/*: Torznab API, used for integration with compatible applications (e.g., download clients or indexer aggregators)./import: The Import API used to add new content to the library. Refer to the importing guide for specific usage./metrics: Prometheus-formatted metrics for monitoring./debug/pprof/*: Go pprof profiling endpoints for performance analysis./status: A health check and status endpoint for monitoring system availability.
Understand the bitmagnet technology stack
mainbitmagnet is built using the following core technologies:
Storage
- Postgres: Serves as the primary data store, powering the search engine and the message queue. It utilizes specific Postgres features and extensions.
Backend (GoLang)
- Dependency Injection:
fx(Uber) - HTTP Server:
gin - Database Migrations:
goose - ORM:
gorm - GraphQL Server:
gqlgen - CLI:
urfave/cli - Logging:
zap(Uber) - Regex:
rex - BitTorrent Utilities:
anacrolix/torrent
Frontend (TypeScript/Angular)
- Framework: Angular with Angular Material components.
- Deployment: The web UI is embedded directly into the GoLang binary and served via the Gin web framework.
Configure the Classifier via config.yml or Environment Variables
mainThe classifier can be customized using a
classifier.ymlfile or via the main application configuration inconfig.ymland environment variables. Note that the application configuration only exposes a subset of the classifier's properties.Common configuration options include:
classifier.workflow: Specifies a custom workflow to use.classifier.keywords.<type>: Adds keywords to a specific category (e.g.,music).classifier.extensions.<type>: Adds file extensions to a specific category (e.g.,audiobook).classifier.flags.delete_content_types: A list of content types to automatically delete.
Environment variable mappings include:
CLASSIFIER_WORKFLOWforclassifier.workflow.CLASSIFIER_DELETE_XXXfor auto-deleting adult content.TMDB_ENABLEDfor disabling TMDB API integration.
classifier: # specify a custom workflow to be used: workflow: custom # add to the core list of music keywords: keywords: music: - my-custom-music-keyword # add a file extension to the list of audiobook-related extensions: extensions: audiobook: - abc # auto-delete all comics flags: delete_content_types: - comicsOr via environment variables
TMDB_ENABLED=false \ CLASSIFIER_WORKFLOW=custom \ CLASSIFIER_DELETE_XXX=true \ bitmagnet worker run --allImport data into bitmagnet using magnetico2bitmagnet
mainThe
magnetico2bitmagnettool, developed by @DyonR, is a collection of scripts designed to import data into bitmagnet from Magnetico and other external sources.https://github.com/DyonR/magnetico2bitmagnetStart bitmagnet worker processes
mainbitmagnet operates using multiple worker processes. You can start all workers at once or specify a subset using the
--keysflag.Start all workers:
bitmagnet worker run --allStart specific workers:
bitmagnet worker run --keys=http_server,queue_server,dht_crawlerUse Wildcard Suffixes
mainThe
*character can be used as a suffix to match terms starting with a specific prefix.Note: Wildcards can only be used as a suffix; they cannot be used as a prefix or in the middle (infix) of a term.
appl*Use the Negation operator
mainThe
!character is a negation operator. It excludes results that contain the term immediately following the!symbol.orange !appleUse Actions and Workflows in the Classifier
mainA workflow is a list of actions executed on torrents. By default, the
defaultworkflow runs, but you can specify a custom one using theclassifier.workflowconfiguration option.Common Actions:
set_content_type: <type>: Sets the torrent's content type.unmatched: Returns an error indicating no match was found.delete: Deletes the torrent being classified.if_else: Executes anif_actionif aconditionis met, otherwise executeselse_action.find_match: Acts like a try/catch block. It attempts to run a list of actions and catchesunmatchederrors to proceed to the next check in the list.
Example: Using
find_matchto chain content type checksfind_match: - if_else: condition: "torrent.baseName.matches(keywords.audiobook)" if_action: set_content_type: audiobook else_action: unmatched - if_else: condition: "torrent.files.map(f, f.extension in extensions.ebook ? f.size : - f.size).sum() > 0" if_action: set_content_type: ebook else_action: unmatchedDisable TMDB or all API integrations
mainYou can disable API integrations to save resources or prevent errors.
- Disable TMDB specifically: Use
flags.tmdb_enabled: falsein configuration, thetmdb.enabledconfig option, or theTMDB_ENABLED=falseenvironment variable. - Disable all APIs: Use
flags.apis_enabled: falsein configuration. - Disable during reprocess: When running the reprocess command, you can pass the
--apisDisabledflag to disable integrations for that specific run.
- Disable TMDB specifically: Use
Run multiple bitmagnet instances
mainYou can run multiple bitmagnet instances pointing to the same Postgres database. While this works, it increases database load and may decrease application performance.
An alternative approach is to run multiple instances with separate databases and periodically merge them using the database merge process.
Use the OR operator
mainThe
|character acts as an OR operator. A search will return results that contain either the term on the left or the term on the right of the operator.apple | orange