Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. // open all sections
  2. $$('section.module:not(.open) header').forEach((h) => h.click());
  3.  
  4. // get all list course videos in each section
  5. let listItems = $$('section.module li');
  6.  
  7. // download them
  8. for (let i = 0; i < listItems.length; i++) {
  9. let listItem = listItems[i];
  10. let title = listItem.querySelector('h3').textContent;
  11. let number = `000${i}`.slice(-3);
  12. let videoName = `${number}-${title}.mp4`;
  13. listItem.click();
  14. await new Promise((resolve) => setTimeout(resolve, 3000));
  15. let video = document.querySelector('video');
  16. let url = video.src;
  17. const response = await fetch(url);
  18. const blob = await response.blob();
  19. let a = document.createElement('a');
  20. a.href = window.URL.createObjectURL(blob);
  21. a.download = videoName;
  22. document.body.appendChild(a);
  23. a.click();
  24. a.remove();
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement