-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (35 loc) · 954 Bytes
/
main.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
package main
import (
"flag"
"fmt"
"github.com/ericzhao007/m3u8-downloader/spiders"
)
var m3u8Url = flag.String("m3u8", "", "m3u8下载链接")
var useMemory = flag.Bool("mem", false, "是否内存加速,会占用大量内存")
var workerNum = flag.Int("m", 0, "并发数")
var filePath = flag.String("f", "movie.mp4", "保存的文件地址")
func main() {
flag.Parse()
if *m3u8Url == "" {
fmt.Println("请填写m3u8地址")
return
}
// appLog, err := os.Create("app.log")
// if err != nil {
// fmt.Println(err)
// return
// }
// defer appLog.Close()
// log.Default().SetOutput(appLog)
var withs []spiders.WithFunc
if *useMemory {
withs = append(withs, spiders.WithMemoryStoreEngine())
} else {
withs = append(withs, spiders.WithDiskStoreEngine())
}
withs = append(withs, spiders.WithWorkerNum(*workerNum))
s := spiders.NewSpiders(*m3u8Url, withs...)
if err := s.Run(*filePath); err != nil {
fmt.Println(err)
}
}