Skip to content

Instantly share code, notes, and snippets.

@codeimpossible
Created February 7, 2015 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeimpossible/bdd8871231b989202126 to your computer and use it in GitHub Desktop.
Save codeimpossible/bdd8871231b989202126 to your computer and use it in GitHub Desktop.
Script to automate our podcast publishing
Param (
[Parameter(Mandatory=$True)]
[string]$url
)
# this assumes you have youtube-dl installed
# choco install youtube-dl
# this also assumes you have ffmpeg installed
# choco install ffmpeg
# this also, also assumes you have Tag installed in the same dir
# http://synthetic-soul.co.uk/tag/
# store the local file name for conversion and cleanup
$local = youtube-dl --get-filename -o "%(title)s.%(ext)s" $url
$local_name_only = [System.IO.Path]::GetFileNameWithoutExtension($local)
$local_name_only = $local_name_only.ToLower()
$local_name_only = $local_name_only -replace '\s','-' # replace spaces with -
# populate some basic episode metadata
$local_title = youtube-dl --get-title $url
$local_description = youtube-dl --get-description $url
# download the file from youtube
youtube-dl -o "%(title)s.%(ext)s" $url
# convert to mp3
ffmpeg -i "./$local" -vn -b:a 192k -c:a libmp3lame "$local_name_only.convert.mp3"
# insert our intro music
ffmpeg -i "concat:f:\FragCast\final\fragcast-intro-music.mp3|$local_name_only.convert.mp3" -acodec copy "$local_name_only.mp3"
# tag the file
./Tag "$local_name_only.mp3" --artist "Frag Castle Games, Inc." --title "$local_title" --comment "$local_description" --year "2015" --album "FragCast Volume 2"
# copy the final file out
cp ".\$local_name_only.mp3" "f:\FragCast\final\$local_name_only.mp3"
cp ".\$local_name_only.mp3" "~\Dropbox\FragCast\$local_name_only.mp3"
# cleanup
if($LastExitCode -eq 0) {
rm "./$local"
rm "./$local_name_only.mp3"
rm ".\$local_name_only.convert.mp3"
Write-Host "All done! the episode is published and here: f:\FragCast\final\$local_name_only.mp3"
} else {
Write-Host "something went fubar. not cleaning up."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment