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

⌈⌋ ⎇ branch:  streamtuner2


Diff

Differences From Artifact [b3f784399d]:

To Artifact [0748f98fbb]:


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  ),
  @(
    "Python requests",
    "requests", # no download url, pip handles this
    "easy_install",
    "",
    "",
    "{PYTHON}\Lib\site-packages\requests-2.12.1-py2.7.egg",
    "",
    ''
  ),
  @(
    "LXML 2.3",
    "https://pypi.python.org/packages/d4/fa/e4e0c7a8fe971b10e275cdc20efd16f553a225e700c400c11da25276e4f4/lxml-2.3-py2.7-win32.egg",
    "easy_install",







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  ),
  @(
    "Python requests",
    "requests", # no download url, pip handles this
    "easy_install",
    "",
    "",
    "{PYTHON}\Lib\site-packages\requests-2*py2.7.egg",
    "",
    ''
  ),
  @(
    "LXML 2.3",
    "https://pypi.python.org/packages/d4/fa/e4e0c7a8fe971b10e275cdc20efd16f553a225e700c400c11da25276e4f4/lxml-2.3-py2.7-win32.egg",
    "easy_install",
179
180
181
182
183
184
185
186
187
188
189
190

191
192
193
194
195
196
197
|                                                                             |
|    Installer for Python 2.7.12 & Gtk 2.24.2                                 |
 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 
"@
}
function Ask-First {
    Write-Host ""
    if ((Ask "Do you want to install Python and Gtk now? [Y/n] ") -notmatch "^[yY]|^$") {
        $tasks = $tasks[7..($tasks.length-1)]
        return
    }
    $reuseCachedFiles = (Ask "Reuse any cached setup files? [r]euse/[I]gnore) ") -match "^[Rr]"

    $optionalInstall =  (Ask "Install optional components? [y/N] ") -match "^[Yy]"
    Write-Host ""
    return $reuseCachedFiles, $optionalInstall
}

function Console-MaxHeight {
    if ($Host.Name -match "console") {







|

|

|
>







179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|                                                                             |
|    Installer for Python 2.7.12 & Gtk 2.24.2                                 |
 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 
"@
}
function Ask-First {
    Write-Host ""
    if ((Ask "Do you want install Streamtuner2 and its Python dependencies now? [Y/n] ") -notmatch "^[yY]|^$") {
        $tasks = $tasks[7..($tasks.length-1)]
        exit
    }
#   $reuseCachedFiles = (Ask "Reuse any cached setup files? [r]euse/[I]gnore) ") -match "^[Rr]"
    $reuseCachedFiles = (Ask "Reuse any cached setup files or ignore them? [r/I] ") -match "^[Rr]"
    $optionalInstall =  (Ask "Install optional components? [y/N] ") -match "^[Yy]"
    Write-Host ""
    return $reuseCachedFiles, $optionalInstall
}

function Console-MaxHeight {
    if ($Host.Name -match "console") {
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
}

#-- create Desktop/Startmenu shortcuts
function Make-Shortcut {
    [CmdletBinding()]
    param($dir, $name, $target, $arg=$false)
    if (!(Test-Path -Path $dir)) {
        New-Item -Path $dir -ItemType directory 2> $null
    }
    $wsh = New-Object -ComObject WScript.Shell
    if (!$wsh) { return }
    $lnk = $wsh.CreateShortcut("$dir\$name")
    $lnk.TargetPath = $target
    if ($arg) {
        $lnk.Arguments = '"'+$arg+'"'
        $lnk.IconLocation = "$IconPath"
        $lnk.WorkingDirectory = "$UsrFolder\bin"
    }
    $lnk.Save()
}

#-- create uninstall script and registry key
function Create-Uninstallscript {
    [CmdletBinding()]
    param()
    #Write-Host " → Creating uninstall script"
    $UninstallScriptPath = "$UsrFolder\share\streamtuner2\dev\uninstall.cmd"
    $installFolder = $usrFolder.substring(0,$usrFolder.LastIndexOf('\'))
    $UninstallScript = Get-Content -Path $UninstallScriptPath

    Out-File -FilePath $UninstallScriptPath -Encoding ascii -InputObject "@set installFolder=$installFolder"
    Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject "@set usrFolder=$usrFolder"
    Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject "@set Python=$PYTHON"
    Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject "@set StreamripperFolder=$STREAMRIPPER"
    Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject "@echo off"
    for ($i=4; $i -lt $UninstallScript.Length ; $i++) {
        Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject $UninstallScript[$i]
    }
    #Out-File -FilePath "$UsrFolder\share\streamtuner2\dev\Y" -Encoding ascii -InputObject "Y"
    #if (Test-IsElevated) {
    #Write-Host "   Writing to registry"
    Remove-Item -Path $regPathCU\Streamtuner2 2> $null        
    New-Item $regPathCU -Name "Streamtuner2" > $null
    Set-Location -Path $regPathCU\Streamtuner2
    New-ItemProperty -Path . -Name DisplayName -PropertyType String -Value "Streamtuner2" > $null
    New-ItemProperty -Path . -Name DisplayVersion -PropertyType String -Value "2.2.0" > $null
    New-ItemProperty -Path . -Name DisplayIcon -PropertyType String -Value "$IconPath" > $null
    New-ItemProperty -Path . -Name UninstallString -PropertyType String -Value "$UninstallPath" > $null







|


















<

|
>
|
|
|
|
|

|

<
<
<







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235

236
237
238
239
240
241
242
243
244
245
246



247
248
249
250
251
252
253
}

#-- create Desktop/Startmenu shortcuts
function Make-Shortcut {
    [CmdletBinding()]
    param($dir, $name, $target, $arg=$false)
    if (!(Test-Path -Path $dir)) {
        New-Item -Path $dir -ItemType directory > $null
    }
    $wsh = New-Object -ComObject WScript.Shell
    if (!$wsh) { return }
    $lnk = $wsh.CreateShortcut("$dir\$name")
    $lnk.TargetPath = $target
    if ($arg) {
        $lnk.Arguments = '"'+$arg+'"'
        $lnk.IconLocation = "$IconPath"
        $lnk.WorkingDirectory = "$UsrFolder\bin"
    }
    $lnk.Save()
}

#-- create uninstall script and registry key
function Create-Uninstallscript {
    [CmdletBinding()]
    param()
    #Write-Host " → Creating uninstall script"

    $installFolder = $usrFolder.substring(0,$usrFolder.LastIndexOf('\'))
    $UninstallScript = Get-Content -Path $UninstallPath
    Out-File -FilePath $UninstallPath -Encoding ascii -InputObject @"
@set installFolder=$installFolder
@set usrFolder=$usrFolder
@set Python=$PYTHON
@set StreamripperFolder=$STREAMRIPPER
"@
    for ($i=4; $i -lt $UninstallScript.Length ; $i++) {
        Out-File -FilePath $UninstallPath -Encoding ascii -Append -InputObject $UninstallScript[$i]
    }



    Remove-Item -Path $regPathCU\Streamtuner2 2> $null        
    New-Item $regPathCU -Name "Streamtuner2" > $null
    Set-Location -Path $regPathCU\Streamtuner2
    New-ItemProperty -Path . -Name DisplayName -PropertyType String -Value "Streamtuner2" > $null
    New-ItemProperty -Path . -Name DisplayVersion -PropertyType String -Value "2.2.0" > $null
    New-ItemProperty -Path . -Name DisplayIcon -PropertyType String -Value "$IconPath" > $null
    New-ItemProperty -Path . -Name UninstallString -PropertyType String -Value "$UninstallPath" > $null
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
}

#-- colorized Read-Host
function Ask($str) {
    if ($str -cmatch "^(.+?)(\[[a-z/]*)([A-Z]+)([\w/]*\])(.*)$") {
        Write-Host -n -f Yellow     $matches[1] # Want to install
        Write-Host -n -f Gray       $matches[2] # [n/
        Write-Host -n -f DarkCyan   $matches[3] # Y
        Write-Host -n -f Gray       $matches[4] # /a]
        Write-Host -n -f Yellow     $matches[5] # ?
    }
    else {
        Write-Host -n -f Yellow $str
    }
    Read-Host ; Write-Host ""







|







267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
}

#-- colorized Read-Host
function Ask($str) {
    if ($str -cmatch "^(.+?)(\[[a-z/]*)([A-Z]+)([\w/]*\])(.*)$") {
        Write-Host -n -f Yellow     $matches[1] # Want to install
        Write-Host -n -f Gray       $matches[2] # [n/
        Write-Host -n -f Green      $matches[3] # Y
        Write-Host -n -f Gray       $matches[4] # /a]
        Write-Host -n -f Yellow     $matches[5] # ?
    }
    else {
        Write-Host -n -f Yellow $str
    }
    Read-Host ; Write-Host ""
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
    ForEach ($task in $tasks) {
        $title, $url, $cmd, $args, $regkey, $checkpath, $is_optional, $presearch, $_found = $task;
        $checkpath = $checkpath -replace "{PYTHON}","$PYTHON"
        if (($is_optional -and !$optionalInstall) -or (!$regkey -and !$checkpath)) {
            continue
        }
        if ($presearch) {  # expression for e.g. registry → path lookup
            Invoke-Expression $presearch # should set $_found + global $PLACEHOLDER variable
        }
        elseif ($checkpath) {
            if (Test-Path $checkpath) {
                $_found = $checkpath
            }
        }
        elseif ($regkey -and (Test-Path $regkey)) {
            $_found = $regkey -replace ".+\\", ""
        }
        if (!$_found) {
            Write-Host "   - $title not found"
            $result = 0;
        }
        else {
            Write-Host -n "   + $title found "  # and display shortened path:







|







|







335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
    ForEach ($task in $tasks) {
        $title, $url, $cmd, $args, $regkey, $checkpath, $is_optional, $presearch, $_found = $task;
        $checkpath = $checkpath -replace "{PYTHON}","$PYTHON"
        if (($is_optional -and !$optionalInstall) -or (!$regkey -and !$checkpath)) {
            continue
        }
        if ($presearch) {  # expression for e.g. registry → path lookup
            Invoke-Expression $presearch > $null # should set $_found + global $PLACEHOLDER variable
        }
        elseif ($checkpath) {
            if (Test-Path $checkpath) {
                $_found = $checkpath
            }
        }
        elseif ($regkey -and (Test-Path $regkey)) {
            $_found = "installer/registry"
        }
        if (!$_found) {
            Write-Host "   - $title not found"
            $result = 0;
        }
        else {
            Write-Host -n "   + $title found "  # and display shortened path:
375
376
377
378
379
380
381

382
383
384
385
386
387
388
}




#-- ask before running
Clear-Host

Console-MaxHeight
Display-Logo
Check-Package
$PYTHON = Check-PythonInstall
$reuseCachedFiles, $optionalInstall = Ask-First
Check-Prerequisites








>







373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
}




#-- ask before running
Clear-Host
$host.ui.RawUI.BackgroundColor = ($bckgrnd = 'Black')
Console-MaxHeight
Display-Logo
Check-Package
$PYTHON = Check-PythonInstall
$reuseCachedFiles, $optionalInstall = Ask-First
Check-Prerequisites

400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
    # print step
    if ($title -match "\d+\.\d+") { $title = "Installing $title" }
    Write-Host -b DarkBlue "`n $title `n"
    chdir($TEMP);

    # test if element (file path or registry key) already exists:
    if ($testpath -AND ($reinstall -ne "all") -AND (Test-Path -Path $testpath)) {
        Write-Host -f Green -NoNewline " → Is already present."
        if ($reinstall -eq "none") { continue tasks }
        Switch -regex ( Ask "   Reinstall [y/N/all/none]? " ) {
            "^all|always|re|^A" { $reinstall = "all"; break }
            "never|none|skip|^S" { $reinstall = "none"; continue tasks }
            "^y|yes|1|go|^R" { break } # YES
            ".*" { continue tasks } # everything else counts as NO
        }







|







399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
    # print step
    if ($title -match "\d+\.\d+") { $title = "Installing $title" }
    Write-Host -b DarkBlue "`n $title `n"
    chdir($TEMP);

    # test if element (file path or registry key) already exists:
    if ($testpath -AND ($reinstall -ne "all") -AND (Test-Path -Path $testpath)) {
        Write-Host -f DarkGreen -NoNewline " → Is already present."
        if ($reinstall -eq "none") { continue tasks }
        Switch -regex ( Ask "   Reinstall [y/N/all/none]? " ) {
            "^all|always|re|^A" { $reinstall = "all"; break }
            "never|none|skip|^S" { $reinstall = "none"; continue tasks }
            "^y|yes|1|go|^R" { break } # YES
            ".*" { continue tasks } # everything else counts as NO
        }
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
            if (!($file)) {
                $cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $url" #"
            }
            else {
                $cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $TEMP\$file" #"
            }
        }
        Write-Host -f DarkYellow   " → $cmd"
        Invoke-Expression "$cmd"
    }
    # msi
    elseif ($file -match ".+.msi$") {
        Write-Host -f DarkYellow (" → msiexec /i " + "$file " + $args)
        Start-Process -Wait msiexec -ArgumentList /i,"$TEMP\$file", $args
        if ($regkey) {
            Set-ItemProperty -Path "$regkey" -Name "WindowsInstaller"  -Value "0"
        }
    }
    # exe
    elseif ($file -match ".+.exe$") {
        write-host -f DarkYellow " → $file $args"
        if ($args) {
            Start-Process -Wait "$TEMP\$file" -ArgumentList $args
        }
        else {
            Start-Process -Wait "$TEMP\$file"
        }
    }







|




|







|







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
            if (!($file)) {
                $cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $url" #"
            }
            else {
                $cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $TEMP\$file" #"
            }
        }
        Write-Host -f DarkGray   " → $cmd"
        Invoke-Expression "$cmd"
    }
    # msi
    elseif ($file -match ".+.msi$") {
        Write-Host -f DarkGray (" → msiexec /i " + "$file " + $args)
        Start-Process -Wait msiexec -ArgumentList /i,"$TEMP\$file", $args
        if ($regkey) {
            Set-ItemProperty -Path "$regkey" -Name "WindowsInstaller"  -Value "0"
        }
    }
    # exe
    elseif ($file -match ".+.exe$") {
        write-host -f DarkGray " → $file $args"
        if ($args) {
            Start-Process -Wait "$TEMP\$file" -ArgumentList $args
        }
        else {
            Start-Process -Wait "$TEMP\$file"
        }
    }