aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-02-04 17:35:56 +0300
committerEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-02-04 17:35:56 +0300
commitf25632cbc7c4871f295c5e63dbf0eb14cdcc6907 (patch)
tree62916411189c73f19acdd486349b290e26678305 /main.go
parent8f44886d0114de8a4a432e28de930eae0928f709 (diff)
downloadradiorus-rss-f25632cbc7c4871f295c5e63dbf0eb14cdcc6907.tar.gz
radiorus-rss-f25632cbc7c4871f295c5e63dbf0eb14cdcc6907.zip
cleaner processing of pages containing video episodes
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/main.go b/main.go
index a105576..d284b20 100644
--- a/main.go
+++ b/main.go
@@ -165,10 +165,17 @@ func populateFeed(feed *feeds.Feed, page []byte) (err error) {
}
func findEnclosure(ep []byte) *feeds.Enclosure {
- episodeAudioRe := regexp.MustCompile(`data\-id="(.+?)?">`)
- episodeAudioUrl := "https://audio.vgtrk.com/download?id=" + string(episodeAudioRe.FindSubmatch(ep)[1])
+ re := regexp.MustCompile(`data\-type="audio"\s+data\-id="(.+?)?">`)
+
+ matches := re.FindSubmatch(ep)
+ if len(matches) < 2 {
+ return &feeds.Enclosure{}
+ }
+
+ url := "https://audio.vgtrk.com/download?id=" + string(matches[1])
+
return &feeds.Enclosure{
- Url: episodeAudioUrl,
+ Url: url,
Length: "1024",
Type: "audio/mpeg",
}