From dbf10b303bffc98c2f6090a7460c5f1e62384c5d Mon Sep 17 00:00:00 2001 From: Evgeny Kuznetsov Date: Mon, 17 Jun 2019 01:03:55 +0300 Subject: add feed description --- main.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'main.go') 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(`

(.+?)?

`) + programAboutRe = regexp.MustCompile(`(?s)
(.+?)?
`) episodeRe = regexp.MustCompile(`(?s)
(.+?)?
`) episodeAudioRe = regexp.MustCompile(`data\-id="(.+?)?">`) episodeDateRe = regexp.MustCompile(`brand\-time brand\-menu\-link">(.+?)?\.(.+?)?\.(.+?)? в (.+?)?:(.+?)?`) @@ -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 } -- cgit v1.2.3