PlayniteExtensionsCollection
PlayniteExtensionsCollection copied to clipboard
[Extra Metadata Loader] Add menu item to download video(s) from games created by itch.io library
Extension name
Extra Metadata Loader
Feature Description
should work for most store page on itch.io the approach with:
- get itch.io game page url from links section of the game (itch.io library normally adds these)
- download the html from that page
- get position of
<div class="right_col column">in html (+ get child<div class="video_embed">) (added by CanRanBan not sure) - get youtube video ID with regex match
(?:youtu(?:\.be|be\.com)\/embed\/)((?:[a-zA-Z\d]|-|_){11})
- make sure found match position in html is greater than position found in point 3
- use the youtube id to pass it your youtube download function to download the video from youtube for game
notes from CanRanBan
But I think you should add to only look inside the <div class="video_embed">. If my looking at 3 different store pages is sufficient enough you always have one
here is another variation of the script (i'm now) using
it tries to take the 1st youtube video it finds after the text class="right_col column" using this way it had found some extra video's
function Get-ItchIoYoutubeLink
{
param(
$scriptGameMenuItemActionArgs
)
Set-MandatorySettings
$gameDatabase = $PlayniteApi.MainView.SelectedGames
$videoSetCount = 0
foreach ($game in $gameDatabase)
{
if($game.Links)
{
foreach ($link in $game.Links)
{
if ($link.Url -like "*itch.io*")
{
$matches = $null
try
{
$webContent = Get-DownloadString $link.Url
}
catch
{
$webContent = ""
}
$webContentLower = $webContent.ToLower()
$index = $webContentLower.LastIndexOf('class="right_col column"')
if ($index -gt 0)
{
$m = Select-String -InputObject $webContent -Pattern '(?:youtu(?:\.be|be\.com)\/embed\/)((?:[a-zA-Z\d]|-|_){11})' -AllMatches
foreach ($match in $m.Matches)
{
if($match.Index -gt $index)
{
Set-YouTubeVideoManual $Match.Groups[1] $false $game
break
}
}
}
}
}
}
}
$PlayniteApi.Dialogs.ShowMessage("Finished", "Extra Metadata tools")
}
