diff options
author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-02-05 19:02:44 +0300 |
---|---|---|
committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-02-05 19:02:44 +0300 |
commit | 37a1c96b0be5edc140fea87812854f63c8854542 (patch) | |
tree | c4f74714f4ff46d767a8aa48d62d16ce71af4caa | |
parent | 2c054e0e4dbc94ecff95d62fd8a06b98405ff4d4 (diff) | |
download | radiorus-rss-37a1c96b0be5edc140fea87812854f63c8854542.tar.gz radiorus-rss-37a1c96b0be5edc140fea87812854f63c8854542.zip |
refactor
-rw-r--r-- | main.go | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -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 { |