-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (26 loc) · 876 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
package main
import (
"flag"
"fmt"
"github.com/nishanthvijayan/nptel-dl/nptel"
)
func main() {
var courseID string
flag.StringVar(&courseID, "courseID", "", "Course Id or Subject ID (Eg: 106106198)")
var outputDirectory string
flag.StringVar(&outputDirectory, "dir", ".", "Output directory")
var start int
flag.IntVar(&start, "start", 1, "Video to start at")
var format string
flag.StringVar(&format, "format", "mp4", "Options: mp4, 3gp, flv")
flag.Parse()
if courseID == "" {
fmt.Println("No courseID was provided. Exiting..")
return
}
courseIndexPage := nptel.GetCourseIndexPage(courseID)
defer courseIndexPage.Close()
courseVideoURLs := nptel.ExtractLectureDownloadUrls(courseIndexPage, format)
fmt.Printf("Found %d lectures available for download\n", len(courseVideoURLs))
nptel.DownloadVideos(courseVideoURLs, start, outputDirectory)
}