Created
May 22, 2023 22:22
-
-
Save fwielstra/8d83dbbd4df1db3c16f9cfd01d9285ed to your computer and use it in GitHub Desktop.
Podcast download script (Powershell)
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
# 1. Get a list of podcast episode mp3 files, e.g. from an RSS feed from https://feeds.megaphone.fm | |
# (just google "<your podcast> rss feed") | |
# 2. Run the get-mp3s.js script in your browser console to assemble a list of MP3 files (the url attribute of the enclosure xml tags) | |
# It's probably possible to have powershell download and parse the xml file to get the same result, but I'm just penning down the hacky method of doing it now. | |
$Urls = @() | |
$Urls += "https://example.com/podcast-episode-1.mp3" | |
# paste the rest here | |
# update this path to your destination, make sure it ends with a backslash | |
$OutPath = "C:\Users\yourname\Desktop\Destination\" | |
# iterate over URLs | |
ForEach ( $item in $Urls) { | |
# takes the filename.mp3 part from the URL | |
$file = $OutPath + ($item).split('/')[-1].split("?")[0] | |
# write the URL and the destination file | |
Write-Output $item | |
Write-Output $file | |
# download | |
Invoke-WebRequest -Uri $item -Outfile $file | |
} |
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
// this prints out a list of powershell append operations to put in the ps1 script | |
xmlhttp=new XMLHttpRequest(); | |
xmlhttp.open("GET","https://feeds.megaphone.fm/QCD8163454930",false); | |
if (xmlhttp.overrideMimeType){ | |
xmlhttp.overrideMimeType('text/xml'); | |
} | |
xmlhttp.send(); | |
xmlDoc=xmlhttp.responseXML; | |
var tagObj=xmlDoc.getElementsByTagName("item"); | |
for (var i = 0; i < tagObj.length; i++) { | |
console.log(`$Urls += "${tagObj[i].getElementsByTagName("enclosure")[0].getAttribute("url")}"`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment