|
|
|
|
@@ -22,7 +22,6 @@ type Client struct {
|
|
|
|
|
CourseID string
|
|
|
|
|
CourseName string
|
|
|
|
|
FilesOnly bool
|
|
|
|
|
downloadedFiles map[string]bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewClient(httpClient *http.Client, accessToken, courseID string, filesOnly bool) *Client {
|
|
|
|
|
@@ -31,7 +30,6 @@ func NewClient(httpClient *http.Client, accessToken, courseID string, filesOnly
|
|
|
|
|
AccessToken: accessToken,
|
|
|
|
|
CourseID: courseID,
|
|
|
|
|
FilesOnly: filesOnly,
|
|
|
|
|
downloadedFiles: make(map[string]bool),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -84,13 +82,6 @@ func (c *Client) DownloadCourseFiles(root string) {
|
|
|
|
|
fileCount := 0
|
|
|
|
|
for _, file := range files {
|
|
|
|
|
|
|
|
|
|
if c.FilesOnly {
|
|
|
|
|
if c.downloadedFiles[file.DisplayName] {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
c.downloadedFiles[file.DisplayName] = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rawFolderPath := folderMap[file.FolderID]
|
|
|
|
|
safeFolderPath := utils.SanitizePath(rawFolderPath)
|
|
|
|
|
|
|
|
|
|
@@ -232,18 +223,11 @@ func (c *Client) downloadModuleFile(item models.ModuleItem, dir string) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.FilesOnly {
|
|
|
|
|
if c.downloadedFiles[fileMeta.DisplayName] {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
c.downloadedFiles[fileMeta.DisplayName] = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ext := filepath.Ext(fileMeta.DisplayName)
|
|
|
|
|
origBase := strings.TrimSuffix(fileMeta.DisplayName, ext)
|
|
|
|
|
|
|
|
|
|
fileName := fileMeta.DisplayName
|
|
|
|
|
if !c.FilesOnly && !strings.EqualFold(origBase, item.Title) && item.Title != "" {
|
|
|
|
|
if !strings.EqualFold(origBase, item.Title) && item.Title != "" {
|
|
|
|
|
fileName = fmt.Sprintf("%s (%s)%s", origBase, item.Title, ext)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|