Last active
April 30, 2018 12:43
-
-
Save BroVic/9e114d1db1046e2aa71c0348ebdf4801 to your computer and use it in GitHub Desktop.
Quick download for course videos (part 2)
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
# video-download.ps1 | |
# Takes an array of video URLs and downloads them into the working directory | |
# and renames them | |
function Get-EdxVideos { | |
param([string[]]$UrlArray, [string[]]$NewNames) | |
for ($i = 0; $i -lt $UrlArray.Length; $i++) { | |
# Prepare new filenames | |
$nuName = $NewNames[$i] | |
$nuName = $nuName.Trim() | |
$nuName = $nuName.ToLower() | |
$nuName = $nuName.Replace(' ', '-') | |
$nuName = $nuName.Replace('introduction', 'intro') | |
$nuName = $nuName + '.mp4' | |
# thought of abbreviating 'javascript' to 'js' but function | |
# is actually meant to be generic across all courses | |
$vid = $UrlArray[$i] | |
Start-BitsTransfer $vid | |
$tmp = Split-Path $vid -Leaf | |
Rename-Item $tmp -NewName $nuName | |
} | |
} | |
New-Alias -Name edxvids -Value Get-EdxVideos |
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
# wk2-downloads.ps1 | |
."..\..\video-download.ps1" # has definition of 'Get-EdxVideos' | |
$wk2_vids = "https://edx-video.net/PENPWJSX2017-V000900_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V001900_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V000800_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V000700_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V003700_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V002000_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V004000_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V003800_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V002100_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V002200_DTH.mp4", | |
"https://edx-video.net/PENPWJSX2017-V002500_DTH.mp4" | |
$vidNames = "Introduction to JavaScript", | |
"JavaScript variables", | |
"JavaScript arrays and objects", | |
"JavaScript control structures", | |
"JavaScript functions", | |
"JavaScript regular expressions", | |
"Introduction to the DOM", | |
"DOM events", | |
"Introduction to jQuery", | |
"jQuery event handling", | |
"jQuery event handling" | |
Get-EdxVideos -UrlArray $wk2_vids -NewNames $vidNames | |
if ($(Get-ChildItem).Name.Contains('videos') -ne 'True') { | |
New-Item -Name videos -ItemType d | |
} | |
Move-Item *.mp4 -Destination .\videos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment