-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfranceculture.go
46 lines (37 loc) · 1.02 KB
/
franceculture.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"bytes"
"fmt"
"regexp"
"github.com/gorilla/feeds"
"golang.org/x/net/html"
)
type FranceCultureCrawler struct {
RadioFranceCrawler
}
func (c *FranceCultureCrawler) Name() string {
return "franceculture"
}
func (c *FranceCultureCrawler) Fetch(name string, cachedRss *feeds.RssFeedXml) (*feeds.Feed, error) {
url := fmt.Sprintf("https://www.franceculture.fr/emissions/%s", name)
content, _, err := c.cache.Get(url)
if err != nil {
return nil, err
}
doc, err := html.Parse(bytes.NewBuffer(content))
if err != nil {
return nil, err
}
re := regexp.MustCompile("https?://radiofrance-podcast.net/podcast09/rss_[0-9]+.xml")
rssFeedLink := re.FindString(string(content))
return c.getFeed(url, doc, rssFeedLink, cachedRss)
}
func newFranceCultureCrawler(cache *HTTPCache) *FranceCultureCrawler {
return &FranceCultureCrawler{
RadioFranceCrawler: RadioFranceCrawler{
cache: cache,
buttonIsFigureSibling: true,
url: "https://www.franceculture.fr",
},
}
}