Last active
April 6, 2018 19:05
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, thank you! :)