Internet radio browser GUI for music/video streams from various directory services.

โŒˆโŒ‹ โŽ‡ branch:  streamtuner2


Diff

Differences From Artifact [e1ab50fb3b]:

To Artifact [d1faae1ee5]:


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  [string]$TEMP = $env:TEMP,
  [string]$PYTHON = "C:\Python27",
  [string]$StartMenu = "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs",
 #[string]$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$",""),
  [string]$ProgramFiles = "%ProgramFiles(x86)%",
  [string]$AboutLink = "http://freshcode.club/projects/streamtuner2",
  [string]$VERSION = "2.2.0"
)            

#-- paths
$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$","")
$UninstallPath = "$UsrFolder\share\streamtuner2\dev\uninstall.cmd"
$ResetPrefsPath = $UninstallPath -replace ("uninstall", "resetprefs")
$ModifyPath = $MyInvocation.MyCommand.Path -replace ("[.]ps1$", ".bat")
$IconPath = "$UsrFolder\share\pixmaps\streamtuner2.ico"







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  [string]$TEMP = $env:TEMP,
  [string]$PYTHON = "C:\Python27",
  [string]$StartMenu = "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs",
 #[string]$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$",""),
  [string]$ProgramFiles = "%ProgramFiles(x86)%",
  [string]$AboutLink = "http://freshcode.club/projects/streamtuner2",
  [string]$VERSION = "2.2.0"
)

#-- paths
$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$","")
$UninstallPath = "$UsrFolder\share\streamtuner2\dev\uninstall.cmd"
$ResetPrefsPath = $UninstallPath -replace ("uninstall", "resetprefs")
$ModifyPath = $MyInvocation.MyCommand.Path -replace ("[.]ps1$", ".bat")
$IconPath = "$UsrFolder\share\pixmaps\streamtuner2.ico"
189
190
191
192
193
194
195

196
197
198
199
200
201
202
        $MyWindow = $Host.UI.RawUI.WindowSize
        $MyWindow.Height = ($MaxHeight)
        $MyWindow.Width = (80)
        $MyBuffer.Height = (9999)
        #$MyBuffer.Width = (80)
        $host.UI.RawUI.set_bufferSize($MyBuffer)
        $host.UI.RawUI.set_windowSize($MyWindow)

    }
}

#-- create Desktop/Startmenu shortcuts
function Make-Shortcut {
    param($dir, $name, $target, $arg=$false, $parm=$false, [parameter(ValueFromRemainingArguments=$true)]$kwargs=0)
    if (!(Test-Path -Path $dir)) {







>







189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
        $MyWindow = $Host.UI.RawUI.WindowSize
        $MyWindow.Height = ($MaxHeight)
        $MyWindow.Width = (80)
        $MyBuffer.Height = (9999)
        #$MyBuffer.Width = (80)
        $host.UI.RawUI.set_bufferSize($MyBuffer)
        $host.UI.RawUI.set_windowSize($MyWindow)
        $host.ui.RawUI.BackgroundColor = ($bckgrnd = 'Black')
    }
}

#-- create Desktop/Startmenu shortcuts
function Make-Shortcut {
    param($dir, $name, $target, $arg=$false, $parm=$false, [parameter(ValueFromRemainingArguments=$true)]$kwargs=0)
    if (!(Test-Path -Path $dir)) {
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
    ForEach ($t in $tasks) {
        $t.found = 0
        $t.testpth = $t.testpth -replace "{PYTHON}","$PYTHON"
        if (!$t.regkey -and !$t.testpth) {
            continue
        }
        if ($t.prescn) {  # expression for e.g. registry โ†’ path lookup
            Invoke-Expression $t.prescn  # should set $.found + global $PLACEHOLDER variable
        }
        elseif ($t.testpth) {
            if (Test-Path $t.testpth) {
                $t.found = $t.testpth
            }
            elseif ($t.regkey -and (Test-Path $t.regkey)) {
                $t.found = "installer/registry"







|







324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
    ForEach ($t in $tasks) {
        $t.found = 0
        $t.testpth = $t.testpth -replace "{PYTHON}","$PYTHON"
        if (!$t.regkey -and !$t.testpth) {
            continue
        }
        if ($t.prescn) {  # expression for e.g. registry โ†’ path lookup
            Invoke-Expression $t.prescn  # should set $t.found + global $PLACEHOLDER variable
        }
        elseif ($t.testpth) {
            if (Test-Path $t.testpth) {
                $t.found = $t.testpth
            }
            elseif ($t.regkey -and (Test-Path $t.regkey)) {
                $t.found = "installer/registry"
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
}

#-- Operates on parameters of each hash from `$tasks`
#
#  ยท $title   โ†’ print current step
#  ยท $url     โ†’ download from given link, keep as local `$file`
#  ยท $cmd     โ†’ instead of running file, run a custom command
#  ยท $iargs    โ†’ used for MSI installation
#  ยท $testpth โ†’ check for exisiting dir/file
#  ยท $regkey  โ†’ set registry key if successful
#  ยท $is_opt  โ†’ run as expression
#  ยท $prescn  โ†’ used in check-prereq()
#
filter Run-Task {
    # extract flags/vars from $tasks pipe
    $title=""; $cmd=""; $url=""; $iargs=""; $testpth=""; $regkey=""; $is_opt=""; $prescn=""; $_found=""
    ($task = $_).GetEnumerator() | % { Set-Variable -Scope Local -Name $_.key -Value ([regex]::Replace($_.value, "[#{](\w+)[}#]", { param($m) Invoke-Expression ("$"+$m.Groups[1].Value) })) }

    # skip optionals
    if ($is_opt -AND !(Invoke-Expression $is_opt)) { return }

    # print step
    if ($title -match "\d+\.\d+") { $title = "Installing $title" }







|







|







362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
}

#-- Operates on parameters of each hash from `$tasks`
#
#  ยท $title   โ†’ print current step
#  ยท $url     โ†’ download from given link, keep as local `$file`
#  ยท $cmd     โ†’ instead of running file, run a custom command
#  ยท $iargs   โ†’ used for MSI installation
#  ยท $testpth โ†’ check for exisiting dir/file
#  ยท $regkey  โ†’ set registry key if successful
#  ยท $is_opt  โ†’ run as expression
#  ยท $prescn  โ†’ used in check-prereq()
#
filter Run-Task {
    # extract flags/vars from $tasks pipe
    $title=""; $cmd=""; $url=""; $iargs=""; $testpth=""; $regkey=""; $is_opt=""; $prescn=""; $found=""
    ($task = $_).GetEnumerator() | % { Set-Variable -Scope Local -Name $_.key -Value ([regex]::Replace($_.value, "[#{](\w+)[}#]", { param($m) Invoke-Expression ("$"+$m.Groups[1].Value) })) }

    # skip optionals
    if ($is_opt -AND !(Invoke-Expression $is_opt)) { return }

    # print step
    if ($title -match "\d+\.\d+") { $title = "Installing $title" }
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
        Start-Process -Wait msiexec -ArgumentList /i,"$TEMP\$file", $iargs
        if ($regkey) {
            Set-ItemProperty -Path "$regkey" -Name "WindowsInstaller"  -Value "0"
        }
    }
    # exe
    elseif ($file -match ".+.exe$") {
        write-host -f DarkGray " โ†’ $file $iargs"
        if ($iargs) {
            Start-Process -Wait "$TEMP\$file" -ArgumentList $iargs
        }
        else {
            Start-Process -Wait "$TEMP\$file"
        }
    }
    # other files
    elseif ($file) {
        echo " โ†’ $file"
        & "$TEMP\$file"
    }
}



#-- run through tasks
Clear-Host
$host.ui.RawUI.BackgroundColor = ($bckgrnd = 'Black')
Console-MaxHeight
Display-Logo
Check-Package
$PYTHON = Check-PythonInstall
$reuseCachedFiles, $optionalInstall = Ask-First
Check-Prerequisites
$tasks | Run-Task  # <-- main loop: process all commands
Any-Key Green








|


















<









430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455

456
457
458
459
460
461
462
463
464
        Start-Process -Wait msiexec -ArgumentList /i,"$TEMP\$file", $iargs
        if ($regkey) {
            Set-ItemProperty -Path "$regkey" -Name "WindowsInstaller"  -Value "0"
        }
    }
    # exe
    elseif ($file -match ".+.exe$") {
        Write-Host -f DarkGray " โ†’ $file $iargs"
        if ($iargs) {
            Start-Process -Wait "$TEMP\$file" -ArgumentList $iargs
        }
        else {
            Start-Process -Wait "$TEMP\$file"
        }
    }
    # other files
    elseif ($file) {
        echo " โ†’ $file"
        & "$TEMP\$file"
    }
}



#-- run through tasks
Clear-Host

Console-MaxHeight
Display-Logo
Check-Package
$PYTHON = Check-PythonInstall
$reuseCachedFiles, $optionalInstall = Ask-First
Check-Prerequisites
$tasks | Run-Task  # <-- main loop: process all commands
Any-Key Green