aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-01-28 15:04:03 +0300
committerEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-01-28 15:04:03 +0300
commitf1c749597bcf5588618eccbd2fbb7797b42eb713 (patch)
treed489ff5f1a589fab5060e5e661ffb8f31fea967d /main.go
parent95a896ff9738b28b54d0d77d460ec03ff07c36bd (diff)
downloadradiorus-rss-f1c749597bcf5588618eccbd2fbb7797b42eb713.tar.gz
radiorus-rss-f1c749597bcf5588618eccbd2fbb7797b42eb713.zip
fix episode addressing for tests
Diffstat (limited to 'main.go')
-rw-r--r--main.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.go b/main.go
index f29fae3..749ba1a 100644
--- a/main.go
+++ b/main.go
@@ -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/"
+}