From 180d96648637431cdb93d34c0762f7e5a043d575 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Sat, 27 Feb 2016 13:14:53 +0100 Subject: [PATCH] Removing SUC messages and chainging WAR to ERR if operation is aborted --- gparser/authorparser.go | 4 ---- gparser/episodeparser.go | 12 ++++-------- gparser/feedparser.go | 8 +++----- gparser/lpparser.go | 4 ---- gparser/ltparser.go | 6 +----- 5 files changed, 8 insertions(+), 26 deletions(-) diff --git a/gparser/authorparser.go b/gparser/authorparser.go index 1461c6a..56a3ef2 100644 --- a/gparser/authorparser.go +++ b/gparser/authorparser.go @@ -80,8 +80,6 @@ func ParseAuthor(i int, s *goquery.Selection) { } if err := database.Db.Create(&AT).Error; err != nil { log.Printf("ERR AT %s: Could not be added to databse (%+v)", slug, err) - } else { - log.Printf("SUC AT %s: Added to database", slug) } } @@ -114,7 +112,5 @@ func UpdateAuthor(AT database.Author) { } if err := database.Db.Save(&AT).Error; err != nil { log.Printf("ERR AT %s: Could not be updated in database (%+v)", AT.Slug.String, err) - } else { - log.Printf("SUC AT %s: Updated in database", AT.Slug.String) } } diff --git a/gparser/episodeparser.go b/gparser/episodeparser.go index b205024..323bcfe 100644 --- a/gparser/episodeparser.go +++ b/gparser/episodeparser.go @@ -88,12 +88,12 @@ func ParseEpisode(i int, s *goquery.Selection) { if match := episodeRegex.FindStringSubmatch(EP.Name.String); len(match) > 0 { num, err := strconv.Atoi(match[1]) if err != nil { - log.Printf("SUC EP %s: Integer conversion not possible", slug) + log.Printf("WAR EP %s: Integer conversion not possible", slug) EP.Episode.Int64 = 0 } EP.Episode.Int64 = int64(num) } else { - log.Printf("SUC EP %s: Name does not match RegEx", slug) + log.Printf("WAR EP %s: Name does not match RegEx", slug) EP.Episode.Int64 = 0 } doc.Find(".article > p").Each(func(i int, s *goquery.Selection) { @@ -112,7 +112,7 @@ func ParseEpisode(i int, s *goquery.Selection) { } ytres, err := youtube.GetVideos([]string {"snippet", "statistics", "status", "contentDetails"}, []string {EP.Youtube.String}, config.C.YoutubeKey) if err != nil || len(ytres.Items) == 0 || ytres.Items[0].Status.UploadStatus != "processed" { - log.Printf("WAR EP %s: Video %s is private (%+v)", slug, EP.Youtube.String, err) + log.Printf("ERR EP %s: Video %s is private (%+v)", slug, EP.Youtube.String, err) return } if EP.Descr.String == "" { @@ -135,7 +135,7 @@ func ParseEpisode(i int, s *goquery.Selection) { if err == nil { EP.Duration.Int64 = int64(dur.ToDuration().Seconds()) } else { - log.Printf("SUC EP %s: Could not parse duration", slug) + log.Printf("WAR EP %s: Could not parse duration", slug) EP.Duration.Int64 = 0 } EP.Rating.Float64, EP.Votes.Int64 = youtube.GetRatingAndVotesWithRes(ytres) @@ -146,8 +146,6 @@ func ParseEpisode(i int, s *goquery.Selection) { if err := database.Db.Create(&EP).Error; err != nil { log.Printf("ERR EP %s: Could not be added to databse (%+v)", slug, err) - } else { - log.Printf("SUC EP %s: Added to database", slug) } } @@ -183,7 +181,5 @@ func UpdateEpisode(EP database.Episode) { if err := database.Db.Save(&EP).Error; err != nil { log.Printf("ERR EP %s: Could not be updated in databse (%+v)", EP.Slug.String, err) - } else { - log.Printf("SUC EP %s: Updated in database", EP.Slug.String) } } diff --git a/gparser/feedparser.go b/gparser/feedparser.go index 6ac146f..b3191b3 100644 --- a/gparser/feedparser.go +++ b/gparser/feedparser.go @@ -103,7 +103,7 @@ func ParseFeedEpisode(u string) { num, _ := strconv.Atoi(match[1]) EP.Episode.Int64 = int64(num) } else { - log.Printf("SUC RSS %s: Name does not match RegEx", slug) + log.Printf("WAR RSS %s: Name does not match RegEx", slug) EP.Episode.Int64 = 0 } doc.Find(".article > p").Each(func(i int, s *goquery.Selection) { @@ -122,7 +122,7 @@ func ParseFeedEpisode(u string) { } ytres, err := youtube.GetVideos([]string {"snippet", "statistics", "status", "contentDetails"}, []string {EP.Youtube.String}, config.C.YoutubeKey) if err != nil || len(ytres.Items) == 0 || ytres.Items[0].Status.UploadStatus != "processed" { - log.Printf("WAR RS %s: Video %s is private (%s)", slug, EP.Youtube.String, err) + log.Printf("ERR RS %s: Video %s is private (%s)", slug, EP.Youtube.String, err) return } if EP.Descr.String == "" { @@ -145,14 +145,12 @@ func ParseFeedEpisode(u string) { if err == nil { EP.Duration.Int64 = int64(dur.ToDuration().Seconds()) } else { - log.Printf("SUC RSS %s: Could not parse duration", slug) + log.Printf("WAR RSS %s: Could not parse duration", slug) EP.Duration.Int64 = 0 } EP.Rating.Float64, EP.Votes.Int64 = youtube.GetRatingAndVotesWithRes(ytres) if err := database.Db.Create(&EP).Error; err != nil { log.Printf("ERR RS %s: Could not be added to databse (%+v)", slug, err) - } else { - log.Printf("SUC RSS %s: Added to database", slug) } } diff --git a/gparser/lpparser.go b/gparser/lpparser.go index 3b51f73..7411669 100644 --- a/gparser/lpparser.go +++ b/gparser/lpparser.go @@ -79,8 +79,6 @@ func ParseLPPage(gslug string, LP *database.LetsPlay) { if err := database.Db.Create(&LP).Error; err != nil { log.Printf("ERR LP %s: Could not be added to database (%+v)", gslug, err) return - } else { - log.Printf("SUC LP %s: Added to database", gslug) } } @@ -119,8 +117,6 @@ func UpdateLP(LP database.LetsPlay) { if err := database.Db.Save(&LP).Error; err != nil { log.Printf("ERR LP %s: Could not be updated in database (%+v)", LP.Slug.String, err) return - } else { - log.Printf("SUC LP %s: Updated in database", LP.Slug.String) } } } diff --git a/gparser/ltparser.go b/gparser/ltparser.go index b33e15e..f7d502f 100644 --- a/gparser/ltparser.go +++ b/gparser/ltparser.go @@ -77,7 +77,7 @@ func ParseLT(i int, s *goquery.Selection) { } ytres, err := youtube.GetVideos([]string {"snippet", "statistics", "status", "contentDetails"}, []string {LT.Youtube.String}, config.C.YoutubeKey) if err != nil || len(ytres.Items) == 0 || ytres.Items[0].Status.UploadStatus != "processed" { - log.Printf("WAR LT %s: Video %s is private (%+v)", slug, LT.Youtube.String, err) + log.Printf("ERR LT %s: Video %s is private (%+v)", slug, LT.Youtube.String, err) return } if LT.Descr.String == "" { @@ -106,8 +106,6 @@ func ParseLT(i int, s *goquery.Selection) { LT.Rating.Float64, LT.Votes.Int64 = youtube.GetRatingAndVotesWithRes(ytres) if err := database.Db.Create(<).Error; err != nil { log.Printf("ERR LT %s: Could not be added to databse (%+v)", slug, err) - } else { - log.Printf("SUC LT %s: Added to database", slug) } } @@ -174,7 +172,5 @@ func UpdateLT(LT database.LetsTest) { } if err := database.Db.Save(<).Error; err != nil { log.Printf("ERR LT %s: Could not be updated in databse (%+v)", LT.Slug.String, err) - } else { - log.Printf("SUC LT %s: Updated in database", LT.Slug.String) } }