fix(lists): improve parsing and exclude unwanted characters (#1918)

* fix(lists): improve parsing and ignore invalid titles

* chore: add missing license headers

* fix(lists): add missing tests from omegabrr
This commit is contained in:
ze0s 2025-01-03 12:45:58 +01:00 committed by GitHub
parent 433c1248f4
commit 40c5462df9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 385 additions and 0 deletions

View file

@ -1,3 +1,6 @@
// Copyright (c) 2021 - 2024, Ludvig Lundgren and the autobrr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later
package list
import (
@ -16,6 +19,7 @@ var (
parenthesesEndRegexp = regexp.MustCompile(`\)$`)
)
// yearRegexp = regexp.MustCompile(`\(\d{4}\)$`)
func processTitle(title string, matchRelease bool) []string {
// Checking if the title is empty.
if strings.TrimSpace(title) == "" {
@ -83,6 +87,10 @@ func NewTitleSlice() *Titles {
}
func (ts *Titles) Add(title string, matchRelease bool) {
if title == "" || title == "*" {
return
}
if matchRelease {
title = strings.Trim(title, "?")
title = fmt.Sprintf("*%v*", title)