Skip to content

Instantly share code, notes, and snippets.

@jherran
Last active August 4, 2023 23:48
Show Gist options
  • Select an option

  • Save jherran/d45792c55b66293c45b5 to your computer and use it in GitHub Desktop.

Select an option

Save jherran/d45792c55b66293c45b5 to your computer and use it in GitHub Desktop.
Download and label all WWDC 2015 videos
#!/usr/local/bin/bash
curl -s https://developer.apple.com/videos/wwdc/2015/ -o source.html
grep "?id=" source.html | grep -v "video center" | sed -E 's/(.*)(\?id=[0-9]+).*/\2/g' | sort | uniq > video_links.txt
rm source.html
cat video_links.txt | while read line
do
url="https://developer.apple.com/videos/wwdc/2015/$line"
curl -s $url -o video.html
title=$(grep "<h3>" video.html | sed -E 's/<h3>|<\/h3>//g' | sed -e 's/^[ \t]*//')
description=$(grep "<p>" video.html | head -1 | sed -E 's/<p>|<\/p>//g' | sed -e 's/^[ \t]*//')
url=$(grep -E -o "href.*HD" video.html | sed -e 's/^.*|//' | sed -e 's/HD.*//' | sed -e 's/.*href="//' | sed -e 's/">.*//')
number=$(grep "HD" video.html | sed -e 's/^.*|//' | sed -e 's/HD.*//' | sed -e 's/.*href="//' | sed 's/">//' | sed -r 's/.*\/([0-9]+)_.*/\1/g')
echo $url
echo $title
echo $description
echo $number
curl -s $url -o "$number-$title-orig.mp4" || printf '%s\n' $?
ffmpeg -i "$number-$title-orig.mp4" -c copy -metadata title="$title" -metadata artist=WWDC -metadata album_artist=WWDC -metadata album="WWDC, Season 2015" -metadata genre="Special Interest" -metadata show=WWDC -metadata media_type=10 -metadata hd_video=1 -metadata season_number=223 -metadata year=2015 -metadata description="$description" -metadata episode_id="S2015E$number" "$number-$title.mp4" -nostdin
if [[ $? = 0 ]];
then
rm "$number-$title-orig.mp4"
fi
done
rm video_links.txt
rm video.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment