/
punkrockvids.com.go
64 lines (56 loc) · 1.34 KB
/
punkrockvids.com.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package sites
import (
"os"
"strconv"
"strings"
"github.com/nektro/SiteRippers/pkg/idata"
"github.com/nektro/SiteRippers/pkg/iutil"
"github.com/PuerkitoBio/goquery"
"github.com/nektro/go-util/mbpp"
)
// punkrockvids.com
// https://punkrockvids.com
// https://punkrockvids.com/?mod=videos&subid=official&vidid=&page=400
func init() {
idata.Handlers["punkrockvids.com"] = func(site, doneDir string) {
//
grabCategory := func(cat string) {
mbpp.CreateJob(site+": "+cat, func(bar *mbpp.BarProxy) {
dir := doneDir + "/" + cat
os.MkdirAll(dir, os.ModePerm)
fv := ""
for i := 1; true; i++ {
stop := false
iutil.FetchDocAs("https://punkrockvids.com/?mod=videos&subid="+cat+"&page="+strconv.Itoa(i), nil, "body table table td:nth-child(3) a:nth-of-type(2)", func(a, b int, c string, el *goquery.Selection) {
if stop {
return
}
if b == 0 {
if fv == c {
stop = true
return
}
fv = c
}
if !strings.HasPrefix(c, "videos/") {
return
}
bar.AddToTotal(1)
go func() {
iutil.DownloadTo("https://"+site+"/"+c, dir, bar)
}()
})
if stop {
break
}
}
})
}
//
grabCategory("official")
grabCategory("live")
grabCategory("ivideos")
// grabCategory("archive")
// grabCategory("interviews")
}
}