Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use class to locate frame #225

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions internal/pkg/canvas/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ func (c *CanvasClient) extractVideoAudioUrlFromFolder(page playwright.Page, fold
}

func (c *CanvasClient) extractCurrentVideoFolder(page playwright.Page, folderPath string, increment func(isFile bool)) *CourseVideoFolder {
frameLoc := page.FrameLocator("#tool_content")
frameLoc := page.FrameLocator(".tool_launch")
currentVideos := []*CourseVideoFile{}
currentFolders := []*CourseVideoFolder{}

Expand All @@ -639,9 +639,9 @@ func (c *CanvasClient) extractCurrentVideoFolder(page playwright.Page, folderPat
if err != nil {
pterm.Error.Printfln("error finding videos in %s", folderPath)
}
if len(videoLocs) == 0 {
pterm.Info.Printfln("found 0 videos in %s", folderPath)
}
// if len(videoLocs) == 0 {
// pterm.Info.Printfln("found 0 videos in %s", folderPath)
// }
if len(videoLocs) > 0 {
for _, videoLoc := range videoLocs {
videoUrlLoc := videoLoc.GetByRole("link").First()
Expand Down Expand Up @@ -682,7 +682,7 @@ func (c *CanvasClient) extractCurrentVideoFolder(page playwright.Page, folderPat
folderListLoc.WaitFor()
folderLocs, err := folderListLoc.Locator(".subfolder-item").All()
if err != nil {
pterm.Error.Printfln("err getting .subfolder-item")
pterm.Error.Printfln("err getting .subfolder-item: %s", err)
} else {
// fmt.Printf("\nfound %d folder locs", len(folderLocs))
if len(folderLocs) > 0 {
Expand Down Expand Up @@ -755,6 +755,7 @@ func (c *CanvasClient) GetCourseVideos(page playwright.Page, dataDir string, cou

courseVideosPath := filepath.Join(dataDir, course.CourseCode, "videos")
courseFolder := c.extractCurrentVideoFolder(page, courseVideosPath, increment)
fmt.Printf("\ncourse folders: %v", courseFolder.Folders)
for _, fold := range courseFolder.Folders {
c.extractVideoAudioUrlFromFolder(page, fold, increment)
}
Expand Down