Skip to content

Instantly share code, notes, and snippets.

@ebraminio
Last active April 5, 2021 07:53
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebraminio/621958b33777d9ce0897 to your computer and use it in GitHub Desktop.
Save ebraminio/621958b33777d9ce0897 to your computer and use it in GitHub Desktop.
maktabkhooneh
// https://maktabkhooneh.org/course/%D9%85%D8%A8%D8%A7%D9%86%DB%8C-%D8%A7%D9%82%D8%AA%D8%B5%D8%A7%D8%AF-mk170/
[...document.querySelectorAll('a.chapter__unit')]
.map(x => () => fetch(x.href)
.then(x => x.text())
.then(x => new DOMParser().parseFromString(x, 'text/html').querySelector('meta[property="og:video"]').content)
.then(y => console.log(y, x.children[1].innerText.trim().replace(/\s/g, '_') + '.mp4'))
)
.reduce((promise, next) => promise.then(next), Promise.resolve())
.then(() => console.log('Finished!'));
# Broken, WIP
#!/bin/bash
for x in $(curl $1 -s | grep lesson-links | sed 's/.*href="\([^"]*\)".*/\1/g')
do
curl http://maktabkhooneh.org${x} -s | grep 'class="video-dl"' | sed 's/.*href="\([^"]*\)".*/\1/g'
done
# or a one-liner
URL=https://maktabkhooneh.org/course/170/; for x in $(curl -L $URL -s | grep lesson-links | sed 's/.*href="\([^"]*\)".*/\1/g'); do curl http://maktabkhooneh.org${x} -s | grep 'class="video-dl"' | sed 's/.*href="\([^"]*\)".*/\1/g'; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment