diff options
author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2019-06-17 01:03:55 +0300 |
---|---|---|
committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2019-06-17 01:03:55 +0300 |
commit | dbf10b303bffc98c2f6090a7460c5f1e62384c5d (patch) | |
tree | 8d9296d76a04588df390db93b87d7c258ce3e86d /main.go | |
parent | e8e7ca67ac8d1ab5af63850a3c179e6e7489dcf5 (diff) | |
download | radiorus-rss-dbf10b303bffc98c2f6090a7460c5f1e62384c5d.tar.gz radiorus-rss-dbf10b303bffc98c2f6090a7460c5f1e62384c5d.zip |
add feed description
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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 } |