aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-02-05 19:02:44 +0300
committerEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-02-05 19:02:44 +0300
commit37a1c96b0be5edc140fea87812854f63c8854542 (patch)
treec4f74714f4ff46d767a8aa48d62d16ce71af4caa
parent2c054e0e4dbc94ecff95d62fd8a06b98405ff4d4 (diff)
downloadradiorus-rss-37a1c96b0be5edc140fea87812854f63c8854542.tar.gz
radiorus-rss-37a1c96b0be5edc140fea87812854f63c8854542.zip
refactor
-rw-r--r--main.go16
1 files changed, 8 insertions, 8 deletions
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 {