CourseDown.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var fs = require('fs');
  2. var logHelper = require("./helper/LjLogHelper.js");
  3. var fileHelper = require("./helper/LjFileHelper");
  4. /**
  5. * The course down
  6. */
  7. class CourseDown
  8. {
  9. static downCourse(lessonJsonObj,callBack)
  10. {
  11. /*课件-Begin*/
  12. //课程集合
  13. var courseList = lessonJsonObj.data.list;
  14. //课程数
  15. var courseListSize = courseList.length;
  16. //遍历课件
  17. for (var i = 0; i < courseListSize; i++)
  18. {
  19. logHelper.debug(courseList[i].title);
  20. //资源集合
  21. var resourceList = courseList[i].list;
  22. //资源数
  23. var resourceSize = resourceList.length;
  24. for (var j = 0; j < resourceSize; j++)
  25. {
  26. logHelper.debug(resourceList[j].url);
  27. var url = resourceList[j].url;
  28. fileHelper.downloadFile(url)
  29. }
  30. }
  31. /*课件-End*/
  32. logHelper.info("Succeed to down lesson【"+lessonJsonObj.data.title+"】");
  33. callBack();
  34. }
  35. }
  36. module.exports = CourseDown;