mpvnet-player / mpv.net

🎞 mpv.net is a media player for Windows with a modern GUI.
GNU General Public License v2.0
3.41k stars 161 forks source link

New PowerShell script etc/update-mpv-and-libmpv.ps1 to update mpv and libmpv. #635

Open candrapersada opened 8 months ago

candrapersada commented 8 months ago

https://github.com/mpvnet-player/mpv.net/blob/304fe58f278e172c6195f11c3e240628b9e35ac8/docs/changelog.md?plain=1#L6 What does update-mpv-and-libmpv.ps1 mean and how do I use it?

Sneakpeakcss commented 8 months ago

https://github.com/mpvnet-player/mpv.net/blob/304fe58f278e172c6195f11c3e240628b9e35ac8/etc/update-mpv-and-libmpv.ps1#L4-L13

candrapersada commented 8 months ago

@Sneakpeakcss

7-Zip 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20

Scanning the drive for archives:
1 file, 25179534 bytes (25 MiB)

Extracting archive: C:\Users\UserName\AppData\Local\Temp\mpv-dev-x86_64-20240104-git-448cb4d.7z
--
Path = C:\Users\UserName\AppData\Local\Temp\mpv-dev-x86_64-20240104-git-448cb4d.7z
Type = 7z
Physical Size = 25179534
Headers Size = 353
Method = LZMA2:26 LZMA:20 BCJ2
Solid = +
Blocks = 2

Everything is Ok

Folders: 2
Files: 6
Size:       102590856
Compressed: 25179534
Test-Path : Cannot bind argument to parameter 'Path' because it is null.
At D:\mpv.net\script etc\update-mpv-and-libmpv.ps1:25 char:25
+     if (-not (Test-Path $path)) {
+                         ~~~~~
    + CategoryInfo          : InvalidData: (:) [Test-Path], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCom
   mand
stax76 commented 8 months ago

@candrapersada

Which command line did you use to run the scripts?

I use another script to run it, using this code:

$arg1 = 'D:\folder-that-contains-libmpv-to-be-updated'
$arg2 = 'D:\folder-that-contains-mpv-to-be-updated'
$path = 'D:\foobar-scripts\update-mpv-and-libmpv.ps1'

& $path $arg1 $arg2

Then I execute the script in the terminal with this command line.

D:\foobar-scripts\update-mpv-and-libmpv.ps1

That is hard to type and remember, I highly recommend using a fzf based history, in your PS profile:

# Install-Module -Name PSFzf
# Set PsFzf's history and file finder keyboard shortcuts.
$env:_PSFZF_FZF_DEFAULT_OPTS = '--exact --no-sort --layout=reverse'
Set-PsFzfOption -PSReadlineChordReverseHistory 'Ctrl+r' -PSReadlineChordProvider 'Ctrl+p'

With that, I invoke the fzf history with Ctrl+r and get what I need by typing.

upd mpv

I hope it's clear now. Bash, PowerShell or Nushell are not easy to learn, but it's worth it.

candrapersada commented 8 months ago

Which command line did you use to run the scripts? file.bat

@ECHO OFF
:: This batch file exists to run update-mpv-and-libmpv.ps1 without hassle
pushd %~dp0
set updater_script="%~dp0\update-mpv-and-libmpv.ps1"
:: Check if pwsh is in the system's PATH
where pwsh >nul 2>nul
if %errorlevel% equ 0 (
    :: pwsh is in PATH, so run the script using Windows Powershell
    pwsh -NoProfile -NoLogo -ExecutionPolicy Bypass -File %updater_script%
) else (
    :: pwsh is not in PATH, run the script using PowerShell Core
    powershell -NoProfile -NoLogo -ExecutionPolicy Bypass -File %updater_script%
)
timeout 5
stax76 commented 8 months ago

You missed passing required arguments into the script.

Two positional command line arguments need to be passed into the script:

  1. The directory containing libmpv to be updated.
  2. The directory containing mpv to be updated.

    To skip one of both pass 'no' instead of the path.

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1#-file----filepath-args