Last active
June 24, 2021 00:21
-
-
Save keb/b686170958866a7c40bf613f421d93ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$rawGames = $PlayniteApi.Database.Games | |
$count = $PlayniteApi.Database.Games.Count | |
[System.Collections.ArrayList]$games = @() | |
foreach ($game in $rawGames) { | |
if ($game.Source.Name) { | |
$gameObj = @{ | |
"name" = $game.Name # adding the game name to the JSON breaks things | |
"store" = $game.Source.Name | |
} | |
$games.Add($gameObj) | |
} | |
} | |
$payload = @{ | |
"count" = $count | |
"games" = $games | |
} | |
$json = $payload | ConvertTo-Json -Compress | |
$headers = @{ | |
"Accept" = "application/vnd.github.v3+json" | |
"Content-Type" = "application/json" | |
"Authorization" = "token $token" | |
"Charset" = "UTF-8" | |
} | |
$body = @{ | |
"description" = "PlayniteGistLib" | |
"public" = $True | |
"files" = @{ | |
"library.json" = @{ | |
"filename" = "library.json" | |
"content" = $json | |
} | |
} | |
} | ConvertTo-Json -Compress | |
$response = Invoke-WebRequest -Method "POST" -Headers $headers -Body $body -Uri "https://api.github.com/gists" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment