Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
candrapersada opened this issue Jan 4, 2024 · 5 comments
Assignees
Labels

Comments

@candrapersada
Copy link

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

What does update-mpv-and-libmpv.ps1 mean and how do I use it?

@Sneakpeakcss
Copy link
Collaborator

This script updates mpv and libmpv using github.com/zhongfly/mpv-winbuild
Two positoninal 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.
Requires 7zip being installed at 'C:\Program Files\7-Zip\7z.exe'

@candrapersada
Copy link
Author

@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
Copy link
Collaborator

stax76 commented Jan 4, 2024

@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
Copy link
Author

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
Copy link
Collaborator

stax76 commented Jan 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants