From 37a1c96b0be5edc140fea87812854f63c8854542 Mon Sep 17 00:00:00 2001 From: Evgeny Kuznetsov Date: Wed, 5 Feb 2020 19:02:44 +0300 Subject: refactor --- main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 16463b1..2304b4b 100644 --- a/main.go +++ b/main.go @@ -226,12 +226,12 @@ func describeFeed(feed *feeds.Feed, wg *sync.WaitGroup) { } func processFeedDesc(page []byte) (string, error) { - matches := programAboutRe.FindSubmatch(page) - if len(matches) < 2 { - return "", errCantParse + res, err := parseSingle(page, programAboutRe) + if err != nil { + return "", err } re := regexp.MustCompile(`<(.+?)?>`) - return string(re.ReplaceAll(matches[1], []byte(``))), nil + return string(re.ReplaceAll(res, []byte(``))), err } func describeEpisodes(feed *feeds.Feed) { @@ -254,11 +254,11 @@ func describeEpisode(item *feeds.Item, wg *sync.WaitGroup) { } func processEpisodeDesc(page []byte) (string, error) { - matches := episodeDescRe.FindSubmatch(page) - if len(matches) < 2 { - return "", errCantParse + res, err := parseSingle(page, episodeDescRe) + if err != nil { + return "", err } - return string(matches[1]), nil + return string(res), err } func getPage(pageUrl string) []byte { -- cgit v1.2.3