Skip to content

Instantly share code, notes, and snippets.

@ebraminio ebraminio/maktabkhooneh.js

Last active Apr 14, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.