03-22-2022, 12:02 PM
I am a PowerShell novice, but have successfully managed to update the Library Exporter script to add columns and such (and I was so proud of myself!)
I have attempted to mirror the elements of that script extension to create a new one to programmatically update a single game entry, to test the process so I can create some batch updates.
1. I have a folder in my Extensions directory - Apply_Updates
2. The folder contains the files - extension.yaml, ApplyUpdates.psm1
3. extension.yaml contains the following entries:
Id: Apply_Updates
Name: Apply Updates
Author: Playnite
Version: 1.0
Module: ApplyUpdates.psm1
Type: Script
4. ApplyUpdates.psm1 contains the following:
function global:ApplyUpdates()
{
$game = $PlayniteApi.Database.Games["<game id>"]
$game.Notes = "<note text>"
$PlayniteApi.Database.Games.Update($game)
}
function global:GetMainMenuItems()
{
param(
$menuArgs
)
$menuItem = New-Object Playnite.SDK.Plugins.ScriptMainMenuItem
$menuItem.Description = "Apply Updates"
$menuItem.FunctionName = "ApplyUpdates"
$menuItem.MenuSection = "@"
return $menuItem
}
5. I previously received alerts on starting Playnite that the script was not loaded due to an unspecified error, and managed to eliminate that by correcting some syntax errors.
6. The script now loads without complaint, and appears as installed and enabled in the Add-Ons/Generic dialog.
7. "Apply Updates" does not appear in the "Extensions" menu.
I have checked other scripts and experimented with replacing '$menuArgs' with '$getMainMenuItemsArgs' but I get the same result.
Can you tell me what I am doing wrong? Should I be looking for any tab characters and replace them with spaces, for instance?
I have attempted to mirror the elements of that script extension to create a new one to programmatically update a single game entry, to test the process so I can create some batch updates.
1. I have a folder in my Extensions directory - Apply_Updates
2. The folder contains the files - extension.yaml, ApplyUpdates.psm1
3. extension.yaml contains the following entries:
Id: Apply_Updates
Name: Apply Updates
Author: Playnite
Version: 1.0
Module: ApplyUpdates.psm1
Type: Script
4. ApplyUpdates.psm1 contains the following:
function global:ApplyUpdates()
{
$game = $PlayniteApi.Database.Games["<game id>"]
$game.Notes = "<note text>"
$PlayniteApi.Database.Games.Update($game)
}
function global:GetMainMenuItems()
{
param(
$menuArgs
)
$menuItem = New-Object Playnite.SDK.Plugins.ScriptMainMenuItem
$menuItem.Description = "Apply Updates"
$menuItem.FunctionName = "ApplyUpdates"
$menuItem.MenuSection = "@"
return $menuItem
}
5. I previously received alerts on starting Playnite that the script was not loaded due to an unspecified error, and managed to eliminate that by correcting some syntax errors.
6. The script now loads without complaint, and appears as installed and enabled in the Add-Ons/Generic dialog.
7. "Apply Updates" does not appear in the "Extensions" menu.
I have checked other scripts and experimented with replacing '$menuArgs' with '$getMainMenuItemsArgs' but I get the same result.
Can you tell me what I am doing wrong? Should I be looking for any tab characters and replace them with spaces, for instance?