hl2guide

Download Videos 1.0A - PowerShell

Aug 31st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Downloads Online Videos using youtube-dl command line tool
  2. # Downloads videos in the best way for the best quality (video and audio)
  3. # Works for youtube.com and many other online video sites (see https://rg3.github.io/youtube-dl/supportedsites.html)
  4.  
  5. # Script Version: 1.0A
  6. # Tool Source: https://rg3.github.io/youtube-dl/
  7. # Reference: http://howto.blbosti.com/2010/03/download-youtube-videos-with-youtube-dl/
  8. # Documenation: https://github.com/rg3/youtube-dl/blob/master/README.md#readme
  9. # Supported Sites: https://rg3.github.io/youtube-dl/supportedsites.html
  10.  
  11. $argsCustom = ''
  12.  
  13. # Edit from here:
  14.  
  15. $destinationFolder = 'D:\Downloads'
  16. $cliToolLocation = 'C:\Users\Dean\Google Drive\Batch Scripts\Commands\youtube-dl.exe'
  17. $destinationFileName = '%(title)s.%(ext)s'
  18.  
  19. # Download List must be a text file with one download address per line
  20. $downloadListFile = 'C:\Users\Dean\Google Drive\Batch Scripts\PowerShell\YouTube Download Script\downloadlist.txt'
  21.  
  22. # Custom Settings ($true OR $false)
  23. $consoleShowProgressInTitle = $true # Should download progress be shown in the title of the window?
  24. $writeASubtitleFile = $true # Should a subtitle download be attempted (if site supports it)
  25. # Playlist Settings ($true OR $false)
  26. $downloadAsPlaylist = $true # Download in playlist mode?
  27. $playlistReverse = $true # Download a playlist in reverse order?
  28. $playlistRandomize = $false # Download a playlist in randomized order?
  29.  
  30. # Whether or not to update the YouTube-DL tool (set to false when running a download)
  31. $updateYoutubeDLTool = $false
  32.  
  33. # End edits here! ========================
  34.  
  35. if($downloadAsPlaylist -eq $true)
  36. {
  37.   $argsCustom = '--yes-playlist '
  38.  
  39.   if($playlistReverse -eq $true)
  40.   {
  41.     $argsCustom += '--playlist-reverse '
  42.   }
  43.   elseif($playlistRandomize -eq $true)
  44.   {
  45.     $argsCustom += '--playlist-random '
  46.   }
  47. }
  48. else
  49. {
  50.   $argsCustom += '--no-playlist '
  51. }
  52.  
  53. if($consoleShowProgressInTitle -eq $true)
  54. {
  55.   $argsCustom += '--console-title '
  56. }
  57.  
  58. if($writeASubtitleFile -eq $true)
  59. {
  60.   $argsCustom += '--write-sub '
  61. }
  62.  
  63. # Update Tool
  64. if($updateYoutubeDLTool -eq $true)
  65. {
  66.     Start-Process $cliToolLocation -ArgumentList '-U'
  67.     exit
  68. }
  69.  
  70. # Start Download
  71. Write-Host 'Downloading Video(s)' -ForegroundColor Yellow
  72.  
  73. # For each url in the downloadlist.txt file try to download it
  74. foreach ($url in get-content $downloadListFile)
  75. {
  76.     $args = $argsCustom+'-f ''bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\'' -o "' + $destinationFolder + '/' + $destinationFileName + '" '+$url
  77.     # Write-Host $args
  78.     # Wait for each process to end
  79.     $process = Start-Process $cliToolLocation -ArgumentList $args -PassThru
  80.     $process.WaitForExit()
  81.     # Set-Clipboard $args
  82. }
  83.  
  84. Write-Host 'Video(s) Downloaded to:'$destinationFolder -ForegroundColor Green
Add Comment
Please, Sign In to add comment