From f25632cbc7c4871f295c5e63dbf0eb14cdcc6907 Mon Sep 17 00:00:00 2001 From: Evgeny Kuznetsov Date: Tue, 4 Feb 2020 17:35:56 +0300 Subject: cleaner processing of pages containing video episodes --- main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'main.go') 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", } -- cgit v1.2.3