Automatically post videos to YouTube
Yes, its possible and it works pretty well! I like doing youtube videos but i don’t like sitting for hours waiting for it to upload (this is ireland afterall 35k/sec upload!) so after some thought and research i didnt really find anything Windows Based that i could stick in a scheduled task on my file server and leave run overnight, lots of stuff for cURL but Windows nada (i could of possibly gone cURL for windows, but where’s the fun in that ).
Download my scripts here and extract to your desired location (important to include the folders), then go and download googlecl from here extract into a folder called googlecl where you extracted the first lot of scripts and folders.
Open a command line and navigate to Googlecl directory and run:
google.exe youtube list
You should be taken to a webpage in order to provide your details. After this open the youtube.ps1 file in notepad and edit the following lines to point to the correct directories:
$dir = "F:\youtube\" $wrkdir = "F:\youtube\Processing\" $FinDir = "F:\youtube\Finished\" $logs = "F:\youtube\Logs\" $gcl = "F:\youtube\googlecl\google.exe"
By default the script uploads all videos to “Games” (gaming category) have a look at the catalogue for youtube categories here and see what “term” you can use for the following line and replace Games with your desired term:
invoke-expression "$gcl youtube post --category Games $wrkdir$vid" | out-null
Finally modify the run.bat located in the scripts folder to point to your paths and give it a go, to automate simply create a scheduled task. I have this set on my server and a network drive shared out, so i simply drag a wmv file to the network drive and at 2:30am every day the server uploads to youtube.
The script isn’t perfect but it works.
Code for youtube.ps1 script:
$date = get-date -uformat "%d%m%Y-%H%M" $file = "$date.txt" $dir = "F:\youtube\" $wrkdir = "F:\youtube\Processing\" $FinDir = "F:\youtube\Finished\" $logs = "F:\youtube\Logs\" $gcl = "F:\youtube\googlecl\google.exe" get-childitem $dir -name -filter "*.wmv" > $dir$file $vid = Get-Content $dir$file -totalcount 1 $vid move-Item $dir$vid $wrkdir $timer = get-date "Starting at $timer" | out-file $logs$file invoke-expression "$gcl youtube post --category Games $wrkdir$vid" | out-null $timer = get-date "Finished at $timer" | out-file $logs$file -append move-Item $wrkdir$vid $Findir Remove-Item $dir$file