aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorEvgeny Kuznetsov <evgeny@kuznetsov.md>2019-06-17 01:03:55 +0300
committerEvgeny Kuznetsov <evgeny@kuznetsov.md>2019-06-17 01:03:55 +0300
commitdbf10b303bffc98c2f6090a7460c5f1e62384c5d (patch)
tree8d9296d76a04588df390db93b87d7c258ce3e86d /main.go
parente8e7ca67ac8d1ab5af63850a3c179e6e7489dcf5 (diff)
downloadradiorus-rss-dbf10b303bffc98c2f6090a7460c5f1e62384c5d.tar.gz
radiorus-rss-dbf10b303bffc98c2f6090a7460c5f1e62384c5d.zip
add feed description
Diffstat (limited to 'main.go')
-rw-r--r--main.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/main.go b/main.go
index 5c109bf..fb23dc4 100644
--- a/main.go
+++ b/main.go
@@ -23,6 +23,7 @@ var (
}
programNameRe = regexp.MustCompile(`<h2>(.+?)?</h2>`)
+ programAboutRe = regexp.MustCompile(`(?s)<div class="brand__content_text__anons">(.+?)?</div>`)
episodeRe = regexp.MustCompile(`(?s)<div class="brand__list\-\-wrap\-\-item">(.+?)?<div class="add\-to\-list">`)
episodeAudioRe = regexp.MustCompile(`data\-id="(.+?)?">`)
episodeDateRe = regexp.MustCompile(`brand\-time brand\-menu\-link">(.+?)?\.(.+?)?\.(.+?)? в (.+?)?:(.+?)?</a>`)
@@ -46,15 +47,16 @@ func main() {
programPage := getPage(programUrl)
- for _, sub := range substitutes {
- re := regexp.MustCompile(sub.from)
- programPage = re.ReplaceAll(programPage, []byte(sub.to))
- }
-
feed.Title = string(programNameRe.FindSubmatch(programPage)[1])
feed.Link = &feeds.Link{Href: programUrl}
episodes := episodeRe.FindAll(programPage, -1)
+ programAboutUrl := "http://www.radiorus.ru/brand/" + programNumber + "/about"
+ programAboutPage := getPage(programAboutUrl)
+ programAbout := programAboutRe.FindSubmatch(programAboutPage)[1]
+ re := regexp.MustCompile(`<(.+?)?>`)
+ feed.Description = string(re.ReplaceAll(programAbout, []byte(``)))
+
for _, episode := range episodes {
episodeUrl := "http://www.radiorus.ru/brand/" + string(episodeUrlRe.FindSubmatch(episode)[1])
episodeTitle := string(episodeTitleRe.FindSubmatch(episode)[1])
@@ -108,5 +110,9 @@ func getPage(pageUrl string) []byte {
if err != nil {
log.Fatal(err)
}
+ for _, sub := range substitutes {
+ re := regexp.MustCompile(sub.from)
+ page = re.ReplaceAll(page, []byte(sub.to))
+ }
return page
}