From b2a53df51ef1e3a042d093925a7ee0a2f9c276d3 Mon Sep 17 00:00:00 2001 From: Ludvig Lundgren Date: Sat, 26 Feb 2022 17:00:26 +0100 Subject: [PATCH 1/3] feat: move specific tags --- cmd/move.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/cmd/move.go b/cmd/move.go index 8cbbb7e..cf2f17a 100644 --- a/cmd/move.go +++ b/cmd/move.go @@ -18,6 +18,7 @@ func RunMove() *cobra.Command { dry bool fromCategories []string targetCategory string + includeTags []string minSeedTime int ) @@ -30,6 +31,7 @@ func RunMove() *cobra.Command { command.Flags().BoolVar(&dry, "dry-run", false, "Run without doing anything") command.Flags().StringSliceVar(&fromCategories, "from", []string{}, "Move from categories") command.Flags().StringVar(&targetCategory, "to", "", "Move to the specified category") + command.Flags().StringSliceVar(&includeTags, "include-tags", []string{}, "Move from tags") command.Flags().IntVar(&minSeedTime, "min-seed-time", 0, "Minimum seed time in MINUTES before moving.") command.MarkFlagRequired("from") command.MarkFlagRequired("to") @@ -65,6 +67,13 @@ func RunMove() *cobra.Command { continue } + if len(includeTags) > 0 { + validTag := validateTag(includeTags, torrent.Tags) + if !validTag { + continue + } + } + // check TimeActive (seconds), CompletionOn (epoch) SeenComplete if minSeedTime > 0 { completedTime := time.Unix(int64(torrent.CompletionOn), 0) @@ -82,7 +91,7 @@ func RunMove() *cobra.Command { } if len(hashes) == 0 { - fmt.Printf("Could not find any matching torrents to move from (%v) to (%v) with min-seed-time %d minutes \n", strings.Join(fromCategories, ","), targetCategory, minSeedTime) + fmt.Printf("Could not find any matching torrents to move from (%v) to (%v) with tags (%v) and min-seed-time %d minutes \n", strings.Join(fromCategories, ","), targetCategory, strings.Join(includeTags, ","), minSeedTime) os.Exit(0) } @@ -104,3 +113,18 @@ func RunMove() *cobra.Command { return command } + +func validateTag(includeTags []string, torrentTags string) bool { + tagList := strings.Split(torrentTags, ", ") + + for _, includeTag := range includeTags { + for _, tag := range tagList { + if tag == includeTag { + fmt.Printf("Tag match %v\n", tag) + return true + } + } + } + + return false +} From 8c9c0cfe07cde8789c2ad7c32d11c0161c6554c6 Mon Sep 17 00:00:00 2001 From: Ludvig Lundgren Date: Sat, 26 Feb 2022 17:00:48 +0100 Subject: [PATCH 2/3] docs: update move flags tags --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5a56c7e..a390aa5 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ By using ATM (Automatic Torrent Mode) and the default behavior of categories map Optional flags: * `--dry-run` - Run without doing anything * `--min-seed-time` - Only move torrents with a minimum active seedtime of X minutes +* `--include-tags` - Only move torrents with any of the tags in comma separate list (tag1,tag2) Usable with cron as well. Run every 15 min. From 1f10a78754f5770c4fd8d90fee7d402b3b923ba1 Mon Sep 17 00:00:00 2001 From: Ludvig Lundgren Date: Sat, 26 Feb 2022 17:07:40 +0100 Subject: [PATCH 3/3] refactor: remove log --- cmd/move.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/move.go b/cmd/move.go index cf2f17a..929aeb8 100644 --- a/cmd/move.go +++ b/cmd/move.go @@ -120,7 +120,6 @@ func validateTag(includeTags []string, torrentTags string) bool { for _, includeTag := range includeTags { for _, tag := range tagList { if tag == includeTag { - fmt.Printf("Tag match %v\n", tag) return true } }