johnpaulada
1/23/2017 - 7:57 AM

Generates a curl command to download all episodes in a course on Sitepoint.

Generates a curl command to download all episodes in a course on Sitepoint.

function zip(a, b) { return a.length ? [[a[0], b[0]]].concat(zip(a.slice(1), b.slice(1))) : []}
(function() {
  const getVideo = (whole, part) => {if (part[0] !== "Quiz") return `${whole} -o "${part[0]}.mp4" ${part[1]} `; else return whole;}
  const zipped = zip (
    [...document.querySelectorAll('span.Contents_title')]
      .map(el => el.innerText)
      .filter(text => text != 'Quiz'),
    [...document.querySelectorAll('span.Contents_actions a:nth-child(2)')]
      .map(el => el.href))
      .reduce(getVideo, '');
  
  return "curl -# " + zipped;
})();