jnfilter @ f0c2bbf9a990b963a225d244974062ee727103d1

feat: Add more series
diff --git a/Makefile b/Makefile
index e498b3570b613b0e1ce10d4b35440036bc63e39d..0bb3b319a53bdae889583b3a6dc8c64c70c8cb5c 100644
--- a/Makefile
+++ b/Makefile
@@ -23,3 +23,6 @@ 	upx --best --ultra-brute $(OUT)
 
 run:
 	$(GO_RUN) .
+
+series:
+	$(GO_RUN) . series
diff --git a/main.go b/main.go
index b9bed96fefc2d2eb2286a5c0c529520ede26575b..22d1489b26af1ccd0d907ddec6974bc518acc0aa 100644
--- a/main.go
+++ b/main.go
@@ -7,6 +7,7 @@ 	"flag"
 	"fmt"
 	"io"
 	"net/http"
+	"os"
 	"regexp"
 	"strconv"
 	"strings"
@@ -18,22 +19,34 @@ 	"github.com/prometheus/client_golang/prometheus/promauto"
 	"github.com/prometheus/client_golang/prometheus/promhttp"
 )
 
-type ErrorRequestHandler func(w http.ResponseWriter, r *http.Request) error
-
 const (
 	FeedUrl = "https://api.jovemnerd.com.br/feed-nerdcast/"
 )
 
+type (
+	ErrorRequestHandler func(w http.ResponseWriter, r *http.Request) error
+)
+
 var (
-	RegexCollection = map[string]string{
-		"nerdcast":     "NerdCast [0-9]+[a-c]* -",
-		"empreendedor": "Empreendedor [0-9]+ -",
-		"mamicas":      "Caneca de Mamicas [0-9]+ -",
-		"english":      "Speak English [0-9]+ -",
-		"nerdcash":     "NerdCash [0-9]+ -",
-		"bunker":       "Lá do Bunker [0-9]+ -",
-		"tech":         "NerdTech [0-9]+ -",
-		"genera":       "Generacast [0-9]+ -",
+	SerieRegex = regexp.MustCompile(`(?P<serie>.+) (?P<number>[0-9abc]+) \- (?P<title>.+)`)
+)
+
+var (
+	regexCollection = map[string]string{
+		"nerdcast":     "NerdCast [0-9]+[a-c]*",
+		"empreendedor": "Empreendedor [0-9]+",
+		"mamicas":      "Caneca de Mamicas [0-9]+",
+		"english":      "Speak English [0-9]+",
+		"nerdcash":     "NerdCash [0-9]+",
+		"bunker":       "Lá do Bunker( LDB especial Oscar|) [0-9]+",
+		"tech":         "NerdTech [0-9]+",
+		"genera":       "Generacast [0-9]+",
+		"rpg":          "NerdCast RPG [0-9]+[a-c]*",
+		"catar":        "Vai te Catar [0-9]+",
+		"cloud":        "Nerd na Cloud [0-9]+",
+		"contar":       "Vou (T|t)e Contar [0-9]+",
+		"parceiro":     "Papo de Parceiro [0-9]+",
+		"cash":         "NerdCash [0-9]+",
 	}
 
 	feedRequest = promauto.NewHistogramVec(prometheus.HistogramOpts{
@@ -60,7 +73,7 @@
 	var series []string
 
 	for _, q := range strings.Split(query, ",") {
-		if _, ok := RegexCollection[q]; ok {
+		if _, ok := regexCollection[q]; ok {
 			series = append(series, q)
 		}
 	}
@@ -74,7 +87,7 @@ }
 
 func match(title string, series []string) bool {
 	for _, s := range series {
-		if ok, err := regexp.MatchString(RegexCollection[s], title); err == nil && ok {
+		if ok, err := regexp.MatchString(regexCollection[s], title); err == nil && ok {
 			return true
 		}
 	}
@@ -224,7 +237,44 @@
 	return nil
 }
 
+func genSeries() error {
+	xml, err := fetchXML(context.Background())
+	if err != nil {
+		return err
+	}
+
+	doc := etree.NewDocument()
+	err = doc.ReadFromBytes(xml)
+	if err != nil {
+		return err
+	}
+
+	unique := make(map[string]any)
+	els := doc.FindElements("//channel/item")
+	for _, e := range els {
+		txt := e.FindElement("title").Text()
+		res := SerieRegex.FindStringSubmatch(txt)
+		if len(res) > 1 {
+			unique[res[1]] = nil
+		}
+	}
+
+	for k := range unique {
+		fmt.Println(k)
+	}
+
+	return nil
+}
+
 func main() {
+	if len(os.Args) > 1 && os.Args[1] == "series" {
+		err := genSeries()
+		if err != nil {
+			panic(err.Error())
+		}
+		return
+	}
+
 	var (
 		addr = flag.String("addr", ":8080", "Server address")
 	)