diff options
author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-02-04 17:35:56 +0300 |
---|---|---|
committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-02-04 17:35:56 +0300 |
commit | f25632cbc7c4871f295c5e63dbf0eb14cdcc6907 (patch) | |
tree | 62916411189c73f19acdd486349b290e26678305 /main.go | |
parent | 8f44886d0114de8a4a432e28de930eae0928f709 (diff) | |
download | radiorus-rss-f25632cbc7c4871f295c5e63dbf0eb14cdcc6907.tar.gz radiorus-rss-f25632cbc7c4871f295c5e63dbf0eb14cdcc6907.zip |
cleaner processing of pages containing video episodes
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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", } |