Skip to content

Instantly share code, notes, and snippets.

@bburky bburky/IsThereAnyDeal.ps1

Last active Jul 24, 2020
Embed
What would you like to do?

Is There Any Deal Collection Sync Playnite Extension

Installation

See Installing Scripts and Plugins.

Usage

  1. Select games to add to your Is There Any Deal collection.
  2. Click Extensions" → "Add Selected Games to Is There Any Deal Collection" in the menu.
  3. Log into Is There Any Deal if it prompts you to. Close the window and rerun the extension after logging in.
  4. Review the list of games and scroll to the bottom. Check "Remove from Waitlist" if desired. Click "Import (safe option)".
  5. Close the window after importing.

Games are only imported to Is There Any Deal by name, it is possible it could guess the wrong game.

Note, while playtime and completion status can be imported to Is There Any Deal, it does not always seem to update. You can try using "Replace" while importing or deleting games from your collection to force it to update.

This extension does not support importing your list of games from Is There Any Deal into Playnite.

Name: Is There Any Deal
Author: Blake Burkhart
Version: 1.2
Module: IsThereAnyDeal.ps1
Type: Script
Functions:
- Description: Add Selected Games to Is There Any Deal Collection
FunctionName: IsThereAnyDeal
function ConvertGamesToITAD ($allGames) {
foreach ($group in $allGames | Group-Object -Property Name) {
$games = $group.Group
$playtime = ($games.Playtime | Sort-Object)[-1]
$status = ($games.CompletionStatus | Sort-Object)[-1]
@{
title = $games[0].Name
status = ([string]$status).ToLower()
playtime = $playtime / 60
copies = @(foreach ($game in $games) {
@{
type = switch ($game.Source) {
"Battle.net" { "battlenet" }
"itch.io" { "itchio" }
{ !$_ } { "playnite" }
Default { $_.Name.ToLower() }
}
owned = 1
}
})
}
}
}
function ImportGamesInITAD ($games) {
$data = @{
version = "02"
data = @(ConvertGamesToITAD $games)
} | ConvertTo-Json -Depth 5
$b64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($data))
$html = "<!DOCTYPE html>
<body onload='form.submit()'>
<form id='form' action='https://isthereanydeal.com/collection/import/' method='post'>
<input type='hidden' name='file' value='$b64'>
<input type='hidden' name='upload' value='Import ITAD Collection'>
</form>
</body>"
$webView = $PlayniteApi.WebViews.CreateView(1000, 800)
$webView.Navigate("data:text/html," + $html)
$webView.OpenDialog()
}
function IsThereAnyDeal {
ImportGamesInITAD $PlayniteApi.MainView.SelectedGames
}
@bburky

This comment has been minimized.

Copy link
Owner Author

bburky commented Feb 26, 2019

Update 1.1

Correctly map all Playnite "source" values to ITAD store IDs. Added mapping for itch.io. Twitch Prime currently does not exist as a default store on ITAD. An empty "source" is mapped to "playnite".

Custom values for "source" are also allowed or any ID from ITAD's list of stores: https://api.isthereanydeal.com/v01/web/stores/all/

@gazpachoking

This comment has been minimized.

Copy link

gazpachoking commented Jul 29, 2019

I was getting the error:
Method invocation failed because [Playnite.SDK.Models.GameSource] does not contain a method named 'ToLower'.
I believe line 16 needs to be changed to: Default { $_.Name.ToLower() }

@mldickens

This comment has been minimized.

Copy link

mldickens commented Nov 3, 2019

I tried making that change to line 16 but it looks like ITAD can't figure out the format - it says "no game has been found." It would be great if this could be updated!

@Thoneon

This comment has been minimized.

Copy link

Thoneon commented Feb 22, 2020

making that change to line 16 but it looks like ITAD can't figure out the format - it says "no game has been found." It would be great if this could be updated!

I did it the first time got the error seen that we could import a file I exported them then redid the processes ( thinking to upload the file ) and it had them all listed, bet it was a cache thing

@bburky

This comment has been minimized.

Copy link
Owner Author

bburky commented Mar 21, 2020

Update 1.2

  • Applied fix for ToLower() bug.

@gazpachoking Thanks, I applied your fix. It was probably a change between new Playnite verisons. Sorry for not making the change sooner, I had been ignoring most of my Playnite extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.