From b5e78e7b69d7d56931b00fbda06b94bf534105e6 Mon Sep 17 00:00:00 2001 From: Fletcher Aksel Date: Tue, 25 Nov 2025 15:02:53 -0800 Subject: [PATCH 1/5] add --start-priority option qbitorrent imports these lists with priority reflecting the order in the input list. --start-priority 10 will output 10 blank lines to set the tracker prioritys starting at 10 use this to avoid merging newly added tracker priorities with existing ones Signed-off-by: Fletcher Aksel --- cmd/groups.go | 22 ++++++++++++++++++ cmd/prompts:02-start-priority.md | 40 ++++++++++++++++++++++++++++++++ cmd/root.go | 1 + 3 files changed, 63 insertions(+) create mode 100644 cmd/prompts:02-start-priority.md diff --git a/cmd/groups.go b/cmd/groups.go index 018ba83..f34ba84 100644 --- a/cmd/groups.go +++ b/cmd/groups.go @@ -20,11 +20,19 @@ var groupsCmd = &cobra.Command{ RunE: runGroups, } +var startPriority int + func init() { rootCmd.AddCommand(groupsCmd) + groupsCmd.Flags().IntVarP(&startPriority, "start-priority", "p", 0, "Output N blank lines before tracker groups (default: 0)") } func runGroups(cmd *cobra.Command, args []string) error { + // Validate start-priority flag + if startPriority < 0 { + return fmt.Errorf("start-priority must be a non-negative integer, got: %d", startPriority) + } + // Load config cfg, err := config.Load() if err != nil { @@ -81,10 +89,24 @@ func runGroups(cmd *cobra.Command, args []string) error { } }() + // Output blank lines for start-priority + if err := outputStartPriority(writer, startPriority); err != nil { + return err + } + // Output groups return outputGroups(writer, groups) } +func outputStartPriority(writer io.Writer, count int) error { + for i := 0; i < count; i++ { + if _, err := fmt.Fprintln(writer); err != nil { + return err + } + } + return nil +} + func outputGroups(writer io.Writer, groups []group.Group) error { for i, g := range groups { if i > 0 { diff --git a/cmd/prompts:02-start-priority.md b/cmd/prompts:02-start-priority.md new file mode 100644 index 0000000..ae19601 --- /dev/null +++ b/cmd/prompts:02-start-priority.md @@ -0,0 +1,40 @@ +## Feature Addition: Start Priority Flag + +Add a new flag to the `groups` command that outputs N blank lines before the grouped tracker URLs. + +### Flag Specification +- `--start-priority ` or `-p ` +- Takes an integer argument (number of blank lines to output) +- Only applies to the `groups` command (default command) +- Works with both stdout and file output (`-o` flag) + +### Behavior +- Output N blank lines at the very beginning, before any tracker groups +- Then output the normal grouped tracker URLs as usual +- Example: `gettrackers groups --start-priority 10` outputs 10 blank lines, then the tracker groups + +### Use Case +This creates N "empty groups" that offset the priority of added trackers in clients like qBittorrent, effectively lowering the priority of the new trackers. + +### Implementation Notes +- Validate that the number is non-negative (0 or positive integer) +- If invalid number provided, show clear error message +- Default value should be 0 (no blank lines) if flag not specified +- The blank lines should come before any other output, including the first tracker group + +### Example Output +``` +gettrackers groups -p 3 +``` + +Would output: +``` +[blank line] +[blank line] +[blank line] +http://tracker1.example.com:8080/announce +http://tracker1.example.com:9090/announce + +http://api.other.com/tracker +... +``` \ No newline at end of file diff --git a/cmd/root.go b/cmd/root.go index 3ed1162..ebf3d88 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,6 +18,7 @@ var outputFile string func init() { rootCmd.PersistentFlags().StringVarP(&outputFile, "output", "o", "", "Write output to file instead of stdout") + rootCmd.Flags().IntVarP(&startPriority, "start-priority", "p", 0, "Output N blank lines before tracker groups (default: 0)") } // Execute runs the root command From 7c44aea0b12b0957b55a33be94c6bb245d9e9e1f Mon Sep 17 00:00:00 2001 From: Fletcher Aksel Date: Tue, 25 Nov 2025 16:09:07 -0800 Subject: [PATCH 2/5] add README Signed-off-by: Fletcher Aksel --- README.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..5372005 --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +# gettrackers + +## Purpose + +Fetches, filters, and structures public torrent tracker lists, +grouping them into **priority tiers** optimized for use in qBittorrent and +other compatible clients. + +such as [ngosang's trackerslist](jhttps://github.com/ngosang/trackerslist) + +## Usage + +``` +> gettrackers --help +gettrackers is a CLI tool that downloads tracker URLs from configurable sources, filters them using a blocklist, and outputs them grouped by domain. + +Usage: + gettrackers [flags] + gettrackers [command] + +Available Commands: + block Add a pattern to the blocklist + completion Generate the autocompletion script for the specified shell + config Manage configuration + fetch Force download/update the cached sources file + groups Output grouped tracker URLs (default command) + help Help about any command + show Show cached sources or blocklist + +Flags: + -h, --help help for gettrackers + -o, --output string Write output to file instead of stdout + -p, --start-priority int Output N blank lines before tracker groups (default: 0) + +Use "gettrackers [command] --help" for more information about a command. +``` + +note the source download file is cached for 24h. + +## Backstory + +found myself reviving a bunch of very old torrents, most of which no +longer had working trackers listed in them. Some trackers were +rejecting the client contacting too quickly, and realized this was because sometimes the all lists have http, https, and udp variants of the same tracker + +so this program groups those into the same tier + +## Tracker Tiering (Based on libtorrent) + +in th underlying **libtorrent** library, which powers qBittorrent. Trackers are +organized into **priority tiers** + +### Tracker Tiers Redundancy and Announcement Logic + +libtorrent use of tracker tiers are controlled by [two +settings](https://www.libtorrent.org/reference-Settings.html#announce_to_all_trackers). + +> `announce_to_all_trackers` controls how multi tracker torrents are treated. +If this is set to true, all trackers in the same tier are announced to in +parallel. If all trackers in tier 0 fails, all trackers in tier 1 are +announced as well. If it's set to false, the behavior is as defined by the +multi tracker specification. + +> `announce_to_all_tiers` also controls how multi tracker torrents are +treated. When this is set to true, one tracker from each tier is announced +to. This is the uTorrent behavior. To be compliant with the Multi-tracker +specification, set it to false. + +this tool groups trackers with the same hostname, into the same priority +tier, with the assumption that qBittorrent's default configuration is +`announce_to_all_trackers` false, and `announce_to_all_tiers` true. + +so `udp://` `http://` `https://` or different port numbers, with the same hostname all get grouped into the same tier. + +### Defining Tiers in Tracker Lists + +When a multi-line list of trackers is added to a torrent, qBittorrent +interprets the structure as follows: + +* **Same Tier (Group):** All consecutive trackers (each on a new line) areassigned to the **same priority tier**. + +* **Next Tier (Priority Fallback):** A single **empty line** separates the + current group, assigning the subsequent block of trackers to the **next + priority level** (e.g., Tier 0, then Tier 1, etc.). + From 5424efe2de3711e14fc245bb29a4efaf4f70d42d Mon Sep 17 00:00:00 2001 From: Fletcher Aksel Date: Tue, 25 Nov 2025 16:32:45 -0800 Subject: [PATCH 3/5] make go install able. Signed-off-by: Fletcher Aksel --- README.md | 6 ++++++ cmd/block.go | 2 +- cmd/config.go | 2 +- cmd/fetch.go | 4 ++-- cmd/groups.go | 8 ++++---- cmd/show.go | 4 ++-- go.mod | 2 +- internal/config/config.go | 2 +- internal/fetch/fetch.go | 2 +- internal/filter/filter.go | 2 +- main.go | 2 +- 11 files changed, 21 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 5372005..73409b9 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ other compatible clients. such as [ngosang's trackerslist](jhttps://github.com/ngosang/trackerslist) +## install + +``` +go install github.com/flueflacks/gettrackers +``` + ## Usage ``` diff --git a/cmd/block.go b/cmd/block.go index b169179..76d71b2 100644 --- a/cmd/block.go +++ b/cmd/block.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "gettrackers/internal/filter" + "github.com/flueflacks/gettrackers/internal/filter" "github.com/spf13/cobra" ) diff --git a/cmd/config.go b/cmd/config.go index a00791f..f590b9f 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -5,7 +5,7 @@ import ( "os" "strings" - "gettrackers/internal/config" + "github.com/flueflacks/gettrackers/internal/config" "github.com/spf13/cobra" ) diff --git a/cmd/fetch.go b/cmd/fetch.go index 934f59c..7dcfe2e 100644 --- a/cmd/fetch.go +++ b/cmd/fetch.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - "gettrackers/internal/config" - "gettrackers/internal/fetch" + "github.com/flueflacks/gettrackers/internal/config" + "github.com/flueflacks/gettrackers/internal/fetch" "github.com/spf13/cobra" ) diff --git a/cmd/groups.go b/cmd/groups.go index f34ba84..6402fe6 100644 --- a/cmd/groups.go +++ b/cmd/groups.go @@ -5,10 +5,10 @@ import ( "io" "os" - "gettrackers/internal/config" - "gettrackers/internal/fetch" - "gettrackers/internal/filter" - "gettrackers/internal/group" + "github.com/flueflacks/gettrackers/internal/config" + "github.com/flueflacks/gettrackers/internal/fetch" + "github.com/flueflacks/gettrackers/internal/filter" + "github.com/flueflacks/gettrackers/internal/group" "github.com/spf13/cobra" ) diff --git a/cmd/show.go b/cmd/show.go index 98f0157..dca0eee 100644 --- a/cmd/show.go +++ b/cmd/show.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - "gettrackers/internal/filter" - "gettrackers/internal/paths" + "github.com/flueflacks/gettrackers/internal/filter" + "github.com/flueflacks/gettrackers/internal/paths" "github.com/spf13/cobra" ) diff --git a/go.mod b/go.mod index c484223..c88e89f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module gettrackers +module github.com/flueflacks/gettrackers go 1.21 diff --git a/internal/config/config.go b/internal/config/config.go index 179f2bb..7c61809 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "gettrackers/internal/paths" + "github.com/flueflacks/gettrackers/internal/paths" "gopkg.in/yaml.v3" ) diff --git a/internal/fetch/fetch.go b/internal/fetch/fetch.go index 1a174f6..7eba11b 100644 --- a/internal/fetch/fetch.go +++ b/internal/fetch/fetch.go @@ -8,7 +8,7 @@ import ( "os" "time" - "gettrackers/internal/paths" + "github.com/flueflacks/gettrackers/internal/paths" ) const cacheMaxAge = 24 * time.Hour diff --git a/internal/filter/filter.go b/internal/filter/filter.go index 5c83d8a..4bd4035 100644 --- a/internal/filter/filter.go +++ b/internal/filter/filter.go @@ -4,7 +4,7 @@ import ( "os" "strings" - "gettrackers/internal/paths" + "github.com/flueflacks/gettrackers/internal/paths" ) // LoadBlocklist loads blocklist patterns from file diff --git a/main.go b/main.go index d27dbb2..16fd6d9 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "os" - "gettrackers/cmd" + "github.com/flueflacks/gettrackers/cmd" ) func main() { From 0b23ea543040c01bd453610766e1fb20d1890c95 Mon Sep 17 00:00:00 2001 From: Fletcher Aksel Date: Tue, 25 Nov 2025 16:57:25 -0800 Subject: [PATCH 4/5] update readme usage Signed-off-by: Fletcher Aksel --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 73409b9..a8ed216 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ go install github.com/flueflacks/gettrackers ## Usage +``` +> gettrackers | pbcopy # macos +> gettrackers | xclip -selection clipboard # linux +... +``` + + ``` > gettrackers --help gettrackers is a CLI tool that downloads tracker URLs from configurable sources, filters them using a blocklist, and outputs them grouped by domain. From 49f9b879b32dde0fac6b9de26f6fdc55cb829205 Mon Sep 17 00:00:00 2001 From: Fletcher Aksel Date: Tue, 25 Nov 2025 17:00:09 -0800 Subject: [PATCH 5/5] oops. fix broken url in README. Signed-off-by: Fletcher Aksel --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a8ed216..7c0cfc1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Fetches, filters, and structures public torrent tracker lists, grouping them into **priority tiers** optimized for use in qBittorrent and other compatible clients. -such as [ngosang's trackerslist](jhttps://github.com/ngosang/trackerslist) +such as [ngosang's trackerslist](https://github.com/ngosang/trackerslist) ## install