feat: add -a/--all flag to include concluded courses
This commit is contained in:
@@ -16,6 +16,7 @@ func main() {
|
||||
filesOnly := flag.Bool("fo", false, "Files only mode - download all files to a single directory without module structure")
|
||||
videosOnly := flag.Bool("vo", false, "Videos only mode - download only Panopto videos to a single directory")
|
||||
me := flag.Bool("me", false, "Download all enrolled courses")
|
||||
all := flag.Bool("a", false, "Include concluded (old) courses when used with -me")
|
||||
moduleNumbers := flag.Bool("n", false, "Prefix modules with order numbers [1], [2], etc.")
|
||||
flag.Parse()
|
||||
|
||||
@@ -29,7 +30,7 @@ func main() {
|
||||
}
|
||||
|
||||
if *me {
|
||||
canvasClient := canvas.NewClient(httpClient, accessToken, "", *filesOnly, *videosOnly, *moduleNumbers)
|
||||
canvasClient := canvas.NewClient(httpClient, accessToken, "", *filesOnly, *videosOnly, *moduleNumbers, *all)
|
||||
courses, err := canvasClient.GetEnrolledCourses()
|
||||
if err != nil {
|
||||
fmt.Printf("Error fetching courses: %v\n", err)
|
||||
@@ -39,7 +40,7 @@ func main() {
|
||||
fmt.Printf("[+] Found %d enrolled courses\n", len(courses))
|
||||
for _, course := range courses {
|
||||
fmt.Printf(" -> Downloading: %s (ID: %d)\n", course.Name, course.ID)
|
||||
downloadCourse(httpClient, accessToken, fmt.Sprintf("%d", course.ID), *filesOnly, *videosOnly, *moduleNumbers)
|
||||
downloadCourse(httpClient, accessToken, fmt.Sprintf("%d", course.ID), *filesOnly, *videosOnly, *moduleNumbers, *all)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -48,11 +49,11 @@ func main() {
|
||||
fmt.Print("Enter Course ID: ")
|
||||
fmt.Scanln(&courseID)
|
||||
|
||||
downloadCourse(httpClient, accessToken, courseID, *filesOnly, *videosOnly, *moduleNumbers)
|
||||
downloadCourse(httpClient, accessToken, courseID, *filesOnly, *videosOnly, *moduleNumbers, *all)
|
||||
}
|
||||
|
||||
func downloadCourse(httpClient *http.Client, accessToken, courseID string, filesOnly, videosOnly, moduleNumbers bool) {
|
||||
canvasClient := canvas.NewClient(httpClient, accessToken, courseID, filesOnly, videosOnly, moduleNumbers)
|
||||
func downloadCourse(httpClient *http.Client, accessToken, courseID string, filesOnly, videosOnly, moduleNumbers, all bool) {
|
||||
canvasClient := canvas.NewClient(httpClient, accessToken, courseID, filesOnly, videosOnly, moduleNumbers, all)
|
||||
|
||||
if err := canvasClient.GetCourseInfo(); err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
|
||||
Reference in New Issue
Block a user