forked from haofree/opendmm-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
45 lines (39 loc) · 850 Bytes
/
utils.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
package opendmm
import (
"net/url"
"strings"
"github.com/PuerkitoBio/goquery"
"github.com/golang/glog"
"github.com/junzh0u/httpx"
)
func newDocument(url string, getcontent httpx.GetContentFunc) (*goquery.Document, error) {
content, err := getcontent(url)
if err != nil {
return nil, err
}
glog.V(3).Infof("=======\nPage:%s\nContent:%s\n=======\n", url, content)
return goquery.NewDocumentFromReader(strings.NewReader(content))
}
func normalizeURL(in string) string {
if in == "" {
return ""
}
u, _ := url.Parse(in)
if u.Scheme == "" {
u.Scheme = "http"
}
return u.String()
}
func normalizeURLs(in []string) []string {
var out []string
for _, s := range in {
out = append(out, normalizeURL(s))
}
return out
}
func unblockingSend(meta MovieMeta, metach chan MovieMeta) {
select {
case metach <- meta:
default:
}
}