Last active
June 7, 2022 18:29
-
-
Save radianttap/8c8bc9a92aa9bda75adc5771f18e8431 to your computer and use it in GitHub Desktop.
Download WWDC 22 HD videos and PDFs
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/bash | |
#Setup the environment | |
mkdir tmp_download | |
cd tmp_download | |
#Extract IDs | |
echo "Downloading the index" | |
wget -q https://developer.apple.com/videos/wwdc2022/ -O index.html | |
cat index.html | sed -n '/data-released=\"true\"/,/class=\"video-image-link\"/p' | grep videos/play/wwdc2022 | sed -e 's/.*wwdc2022\///' -e 's/\/\"\ .*//' | sed '$!N; /^\(.*\)\n\1$/!P; D' > ../downloadData | |
rm index.html | |
#Iterate through the talk IDs | |
while read -r line | |
do | |
echo "Trying $line" | |
#Download the page with the real download URL and the talk name | |
wget -q "https://developer.apple.com/videos/play/wwdc2022/$line/" -O webpage | |
#We grab the title of the page then clean it up | |
talkName=$(cat webpage | grep "<title" | sed -e "s/.*\<title\>//" -e "s/ \- WWDC22.*//") | |
#We grep "_hd" which bring up the download URL, then some cleanup | |
#If we were to want SD video, all we would have to do is replace _hd_ by _sd_ | |
dlURL=$(cat webpage | grep _hd | sed -e "s/.*href\=//" -e "s/\>.*//" -e "s/\"//g") | |
pdfURL=$(cat webpage | grep .pdf | grep devstreaming | sed -e "s/.*href\=//" -e "s/\>.*//" -e "s/\"//g" -e "s/ .*$//g") | |
rm webpage | |
#Is there a video URL? | |
if [ -z "$dlURL" ]; then | |
echo | |
else | |
if [[ $talkName == *"(ASL)"* ]]; then | |
echo "Skipping $line ($talkName)" | |
continue | |
fi | |
echo "Video $line ($talkName)" | |
echo " url: $dlURL" | |
#Great, we download the file | |
wget -c "$dlURL" -O "../$line - $talkName.mp4" | |
fi | |
#Is there a PDF URL? | |
if [ -z "$pdfURL" ]; then | |
echo | |
else | |
echo "PDF $line ($talkName)" | |
echo " url: $pdfURL" | |
#Great, we download the file | |
wget -c "$pdfURL" -O "../$line - $talkName.pdf" | |
fi | |
done < "../downloadData" | |
#cleanup | |
cd .. | |
rm -rf tmp_download | |
rm downloadData |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment