Last active
September 6, 2022 03:48
-
-
Save runo280/0602c00ae7d403b6078da72946de5a7a to your computer and use it in GitHub Desktop.
Simply download courses from git.ir
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
#!/bin/env bash | |
# Author: https://github.com/runo280 | |
# How to use: ./gitit_dl.sh https://git.ir/your_course_name/ | |
# Valid pattern for url: https://git.ir/your_course_name/ | |
# Needed packages: aria2, wget, sed, cut, grep, rev | |
echo | |
echo "............................" | |
echo ". git.ir course downloader ." | |
echo "............................" | |
echo | |
if [ -z "$1" ]; then | |
echo "Url is missing!" | |
fi | |
url=$1 | |
links_file=links.txt | |
folder=$(echo $url | rev | cut -d '/' -f 2 | rev) | |
function extract_links(){ | |
echo "Start extracting links..." | |
content=$(wget $url -q -O -) | |
echo $content | grep -o '<a href=['"'"'"][^"'"'"']*['"'"'"]' | sed -e 's/^<a href=["'"'"']//' -e 's/["'"'"']$//' | sed -e '/.mp4/!d' > $folder/$links_file | |
} | |
function download(){ | |
echo "Start downloading..." | |
cd $folder | |
aria2c --max-concurrent-downloads=1 --continue --max-connection-per-server=16 --min-split-size=1M --split=16 --download-result=full --enable-color=true --human-readable=true --check-certificate=false -i $links_file | |
#wget -i $links_file | |
echo "Download finished" | |
} | |
if [ ! -d "$folder" ]; then | |
mkdir $folder | |
fi | |
if [ -f "$folder/$links_file" ]; then | |
echo "links.txt exists" | |
download | |
else | |
extract_links | |
download | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use this code?