diff options
author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 15:04:03 +0300 |
---|---|---|
committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 15:04:03 +0300 |
commit | f1c749597bcf5588618eccbd2fbb7797b42eb713 (patch) | |
tree | d489ff5f1a589fab5060e5e661ffb8f31fea967d /main.go | |
parent | 95a896ff9738b28b54d0d77d460ec03ff07c36bd (diff) | |
download | radiorus-rss-f1c749597bcf5588618eccbd2fbb7797b42eb713.tar.gz radiorus-rss-f1c749597bcf5588618eccbd2fbb7797b42eb713.zip |
fix episode addressing for tests
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -133,12 +133,13 @@ func populateFeed(feed *feeds.Feed, page []byte) (err error) { } episodes := episodeRe.FindAll(page, -1) + urlPrefix := episodeURLPrefix(feed.Link.Href) for _, episode := range episodes { if len(episodeUrlRe.FindAllSubmatch(episode, -1)) > 1 { return errBadEpisode } - episodeUrl := "http://www.radiorus.ru/brand/" + string(episodeUrlRe.FindSubmatch(episode)[1]) + episodeUrl := urlPrefix + string(episodeUrlRe.FindSubmatch(episode)[1]) episodeTitle := string(episodeTitleRe.FindSubmatch(episode)[1]) episodeAudioUrl := "https://audio.vgtrk.com/download?id=" + string(episodeAudioRe.FindSubmatch(episode)[1]) dateBytes := episodeDateRe.FindSubmatch(episode) @@ -224,3 +225,8 @@ func cleanText(b []byte) []byte { } return b } + +// episodeURLPrefix derives common episode URL prefix from programme page URL +func episodeURLPrefix(url string) string { + return strings.Split(url, "/brand/")[0] + "/brand/" +} |