Add support to download all the users courses

This commit is contained in:
joren
2026-03-11 19:36:54 +01:00
parent 11d9867155
commit 8591ae283e
3 changed files with 38 additions and 2 deletions

View File

@@ -51,6 +51,20 @@ func (c *Client) GetCourseInfo() error {
return nil
}
func (c *Client) GetEnrolledCourses() ([]models.Course, error) {
req, _ := http.NewRequest("GET", fmt.Sprintf("%s/api/v1/courses?enrollment_state=active&per_page=100", config.BaseURL), nil)
req.Header.Set("Authorization", "Bearer "+c.AccessToken)
resp, err := c.HTTPClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var courses []models.Course
json.NewDecoder(resp.Body).Decode(&courses)
return courses, nil
}
func (c *Client) DownloadCourseFiles(root string) {
fmt.Println("\n[*] Fetching regular course files...")