Advertisement
notuserfriendly

Get-YoutubeVideos

Nov 23rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param(
  2.     [string]$configLocation,
  3.     [switch]$bugger,
  4.     [switch]$readmotd,
  5.     [switch]$simulate,
  6.     [switch]$resetdate
  7. )
  8.  
  9. $terminate = $true                                  # Variable for exiting
  10. $rootdir = $PSScriptRoot                            # Finds the root directory
  11. if ($readmotd) {$motd = Get-Content "$rootdir\bin\motd.txt"}         # Reads the changelog/motd
  12.  
  13.  
  14. Do {
  15.     # Reads the motd
  16.     if ($readmotd) {Write-Host $motd}
  17.  
  18.     #Builds the Command
  19.     $exp = "$rootdir\Start-YtdlManager.ps1"
  20.     if ($configlocation -ne $null) { $exp += " -configlocation $configlocation" }
  21.     if ($bugger) { $exp += " -bugger" }
  22.     if ($simulate) { $exp += " -simulate" }
  23.     if ($resetdate) { $exp += " -resetdate" }
  24.  
  25.     if ($bugger) {Write-Host "Expression is:" $exp }
  26.  
  27.     # Launches the Script
  28.     Write-Host "Launching Randall's YouTube-DL Manager"
  29.     Invoke-Expression $exp
  30.  
  31.     # System/Menu for Restarting the Process
  32.     $prompt = 'Press R to restart, Q to quit, or D to reset the Download Date'
  33.     $option = ''
  34.     $validoptions = ('R','Q','D')
  35.     while ($option -eq '') {
  36.         $option = (Read-Host $prompt).ToUpper()
  37.         if ($option -notin $validoptions) {
  38.             Write-Host '    Invalid Selection'
  39.             $option = ''
  40.             pause
  41.         }
  42.     }
  43.     switch ($option) {
  44.         'R' {$terminate = $false; break}
  45.         'Q' {$terminate = $true; break}
  46.         'D' {$terminate = $false; $resetdate = $true; break}
  47.     }
  48. } Until ($terminate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement