Skip to content

Instantly share code, notes, and snippets.

@nikosdouvlis
Last active April 6, 2018 19:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikosdouvlis/e9c5e98a307193d790d8feb8eaccbf80 to your computer and use it in GitHub Desktop.
Save nikosdouvlis/e9c5e98a307193d790d8feb8eaccbf80 to your computer and use it in GitHub Desktop.
Quick and dirty node script to download every free video from destroyallsoftware.com. Don't forget to change the DIR_PATH var (download destination) before running. Run with node --experimental-modules destroyallsoftware.mjs
import fetch from 'node-fetch';
import jsdom from 'jsdom';
import download from 'download-file';
const {JSDOM} = jsdom;
const BASE_URL = 'https://www.destroyallsoftware.com';
const DIR_PATH = 'where/to/save';
fetch(BASE_URL + '/screencasts/catalog')
.then(response => response.text())
.then(html => (new JSDOM(html)).window.document)
.then(document => document.querySelectorAll('a[href^="/screencasts/catalog/"]'))
.then(nodes => Array.from(nodes).map(c => c.href))
.then(array => {
return Promise.all(array.map(url => {
return fetch(BASE_URL + url)
.then(response => response.text())
.then(html => html.match(/source\.src \= \"(.*)\";/)[1]);
}));
})
.then(async (videos) => {
for (let video of videos) {
console.log(video);
let options = {
directory: DIR_PATH,
filename: video.match(/amazonaws\.com\/(.*)\.mp4/)[1] + '.mp4'
};
await new Promise((resolve, reject) => {
download(video, options, resolve);
});
}
});
@ClocxHD
Copy link

ClocxHD commented Apr 6, 2018

Awesome, thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment