From 5deb41b6f1846c9684d653a34d1d4a14a73bdd6a Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Sun, 28 Feb 2016 16:30:55 +0100 Subject: [PATCH] Adding Regex to remove (Author) from LP names --- config/config.go | 1 + config/gronkh.json.example | 1 + gparser/lpparser.go | 1 + gparser/main.go | 2 ++ 4 files changed, 5 insertions(+) diff --git a/config/config.go b/config/config.go index 9b2426b..733afc9 100644 --- a/config/config.go +++ b/config/config.go @@ -9,6 +9,7 @@ type Config struct { DatabaseConnection string EpisodeRegex string RemoveRegex string + LPRenameRegex string YoutubeKey string GronkhUrl string ImageDirectory string diff --git a/config/gronkh.json.example b/config/gronkh.json.example index 7284cb4..0109d97 100644 --- a/config/gronkh.json.example +++ b/config/gronkh.json.example @@ -1,6 +1,7 @@ { "EpisodeRegex": "^(?:Folge |Folge |Special |Folge S01E|Folge ß|Folge ESIDENT EVIL REVELATIONS 2 \\[|Folge #|Folge 1 – Galaktischer Krie\\: |Folge 15; Zurück in der neuen Wel\\: |Folge 6½ \\[German\\] – Dr\\. Kleiners Vortra\\: |Folge ESIDENT EVIL REVELATIONS 2 \\[)([0-9]+)(?:½\\: |\\: | – |; |\\.5\\: |½ \\[German\\] – | Verwirrspiele & Hinterhalt\\: 18 |] |\\. KIPPLASTER RACING Schwadro\\: 95\\. |[,.][0-9a-zA-Z]+\\: | Titanenlord Ursego\\: 41 |[a-zA-Z]\\: )", "RemoveRegex": "^(?:Folge Special\\: |Folge special\\: | – Let’s Play [1080][PS4\\: SIDENT EVIL REVELATIONS 2 [23] Getrennt..! – Let’s Play [1080][PS4]|Folge pecial\\: )", + "LPRenameRegex": "^(?:\\(Gronkh|Sarazar|Amras|Trashtazmani|Honeyball|TrueMG|Rahmschnitzel|LookslikeLink|Suishomaru|HerrDekay|Hijuga|Zombey\\))", "YoutubeKey": "FOOOBAAAARRRRRRR", "DatabaseConnection": "host=localhost user=gronkhde dbname=gronkhde sslmode=disable", "GronkhUrl": "http://5.62.67.8", diff --git a/gparser/lpparser.go b/gparser/lpparser.go index 576f73c..bd3da6d 100644 --- a/gparser/lpparser.go +++ b/gparser/lpparser.go @@ -57,6 +57,7 @@ func ParseLPPage(gslug string, LP *database.LetsPlay) { } LP.Name.String = doc.Find("h1 > a > strong").First().Text() + LP.Name.String = lpRenameRegex.ReplaceAllString(LP.Name.String, "") pos, _ := doc.Find(".lightbox").Attr("href") LP.PosterS.String, LP.PosterB.String, err = image.ResizeCover(pos) diff --git a/gparser/main.go b/gparser/main.go index 1e3b23d..343e0ef 100644 --- a/gparser/main.go +++ b/gparser/main.go @@ -13,6 +13,7 @@ import ( var conf config.Config var episodeRegex *regexp.Regexp var removeRegex *regexp.Regexp +var lpRenameRegex *regexp.Regexp var wg sync.WaitGroup func main() { @@ -30,6 +31,7 @@ func main() { } episodeRegex = regexp.MustCompile(config.C.EpisodeRegex) removeRegex = regexp.MustCompile(config.C.RemoveRegex) + lpRenameRegex = regexp.MustCompile(config.C.LPRenameRegex) if err = os.MkdirAll(config.C.ImageDirectory, 0775); err != nil { log.Fatalf("FAT Could not create ImageDirectory, error: %+v", err)