Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions source/Generic/ExtraMetadataLoader/ExtraMetadataLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ExtraMetadataLoader.Helpers;
using ExtraMetadataLoader.Interfaces;
using ExtraMetadataLoader.LogoProviders;
using ExtraMetadataLoader.LogoProviders.LaunchBox;
using ExtraMetadataLoader.Models;
using ExtraMetadataLoader.Services;
using ExtraMetadataLoader.ViewModels;
Expand Down Expand Up @@ -53,6 +54,7 @@ public class ExtraMetadataLoader : GenericPlugin
private readonly VideosDownloader videosDownloader;
private readonly ExtraMetadataHelper extraMetadataHelper;
private readonly List<ILogoProvider> _logoProviders;
private readonly ILogoProvider _launchBoxLogoProvider;
private VideoPlayerControl detailsVideoControl;
private VideoPlayerControl gridVideoControl;
private VideoPlayerControl genericVideoControl;
Expand Down Expand Up @@ -140,6 +142,8 @@ public ExtraMetadataLoader(IPlayniteAPI api) : base(api)
PlayniteUtilities.AddTextIcoFontResource(iconResource.Key, iconResource.Value);
}

var launchBoxMetadataCache = new LaunchBoxMetadataCache(Path.Combine(GetPluginUserDataPath(), "LaunchBox"), logger);
_launchBoxLogoProvider = new LaunchBoxClearLogoProvider(PlayniteApi, logger, launchBoxMetadataCache);
_logoProviders = new List<ILogoProvider>
{
new SteamProvider(PlayniteApi, settings.Settings),
Expand Down Expand Up @@ -404,6 +408,38 @@ public override IEnumerable<GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs
}
},
new GameMenuItem
{
Description = ResourceProvider.GetString("LOCExtra_Metadata_Loader_MenuItemDescriptionDownloadLaunchBoxLogosSelectedGames"),
MenuSection = $"Extra Metadata|{logosSection}",
Icon = "emtDownloadIcon",
Action = _ => {
var overwrite = GetBoolFromYesNoDialog(ResourceProvider.GetString("LOCExtra_Metadata_Loader_DialogMessageOverwriteLogosChoice"));
var isBackgroundDownload = GetBoolFromYesNoDialog(ResourceProvider.GetString("LOCExtra_Metadata_Loader_DialogAskSelectLogosAutomatically"));
var progressTitle = ResourceProvider.GetString("LOCExtra_Metadata_Loader_DialogMessageDownloadingLogosLaunchBox");

var progressOptions = new GlobalProgressOptions(progressTitle, true);
progressOptions.IsIndeterminate = false;
PlayniteApi.Dialogs.ActivateGlobalProgress((a) =>
{
var games = args.Games.Distinct();
a.ProgressMaxValue = games.Count() + 1;
foreach (var game in games)
{
if (a.CancelToken.IsCancellationRequested)
{
break;
}

a.CurrentProgressValue++;
a.Text = $"{progressTitle}\n\n{a.CurrentProgressValue}/{games.Count()}\n{game.Name}";

GetGameLogo(_launchBoxLogoProvider, game, isBackgroundDownload, overwrite, a.CancelToken);
};
}, progressOptions);
PlayniteApi.Dialogs.ShowMessage(ResourceProvider.GetString("LOCExtra_Metadata_Loader_DialogMessageDone"), "Extra Metadata Loader");
}
},
new GameMenuItem
{
Description = ResourceProvider.GetString("LOCExtra_Metadata_Loader_MenuItemDescriptionDownloadGoogleLogoSelectedGame"),
MenuSection = $"Extra Metadata|{logosSection}",
Expand Down Expand Up @@ -970,14 +1006,20 @@ public override void OnLibraryUpdated(OnLibraryUpdatedEventArgs args)
break;
}

var logoDownloaded = false;
foreach (var logoProvider in _logoProviders)
{
var logoDownloaded = GetGameLogo(logoProvider, game, true, settings.Settings.LibUpdateSelectLogosAutomatically, a.CancelToken);
logoDownloaded = GetGameLogo(logoProvider, game, true, settings.Settings.LibUpdateSelectLogosAutomatically, a.CancelToken);
if (logoDownloaded)
{
break;
}
}

if (!logoDownloaded && settings.Settings.UseLaunchBoxForAutomaticLogoDownloads)
{
GetGameLogo(_launchBoxLogoProvider, game, true, settings.Settings.LibUpdateSelectLogosAutomatically, a.CancelToken);
}
};
}, progressOptions);
}
Expand Down Expand Up @@ -1121,4 +1163,4 @@ public override UserControl GetSettingsView(bool firstRunSettings)
return new ExtraMetadataLoaderSettingsView();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.6.0.0\lib\net461\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -251,6 +253,9 @@
<Compile Include="Helpers\ExtraMetadataHelper.cs" />
<Compile Include="Interfaces\ILogoProvider.cs" />
<Compile Include="LogoProviders\GoogleProvider.cs" />
<Compile Include="LogoProviders\LaunchBox\LaunchBoxClearLogoProvider.cs" />
<Compile Include="LogoProviders\LaunchBox\LaunchBoxMetadataCache.cs" />
<Compile Include="LogoProviders\LaunchBox\LaunchBoxModels.cs" />
<Compile Include="LogoProviders\SteamGridDBProvider.cs" />
<Compile Include="LogoProviders\SteamProvider.cs" />
<Compile Include="Models\FfprobeVideoInfoOutput.cs" />
Expand Down Expand Up @@ -334,4 +339,4 @@
<PostBuildEvent>xcopy "$(ProjectDir)Localization\*.xaml" "$(TargetDir)\Localization" /Y /I /E</PostBuildEvent>
</PropertyGroup>
<Import Project="..\..\packages\Magick.NET-Q8-x86.14.11.1\build\netstandard20\Magick.NET-Q8-x86.targets" Condition="Exists('..\..\packages\Magick.NET-Q8-x86.14.11.1\build\netstandard20\Magick.NET-Q8-x86.targets')" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,18 @@ public bool LibUpdateSelectLogosAutomatically
}
}

[DontSerialize]
private bool useLaunchBoxForAutomaticLogoDownloads = false;
public bool UseLaunchBoxForAutomaticLogoDownloads
{
get => useLaunchBoxForAutomaticLogoDownloads;
set
{
useLaunchBoxForAutomaticLogoDownloads = value;
OnPropertyChanged();
}
}

public DateTime LastAutoLibUpdateAssetsDownload = DateTime.MinValue;

[DontSerialize]
Expand Down Expand Up @@ -887,4 +899,4 @@ public void LoginToYoutube()
webView.Dispose();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
<StackPanel Margin="20,0,0,10" IsEnabled="{Binding ElementName=CbDownloadLogosOnLibUpdate, Path=IsChecked}" >
<CheckBox Margin="0,0,0,10" IsChecked="{Binding Settings.LibUpdateSelectLogosAutomatically}"
Content="{DynamicResource LOCExtra_Metadata_Loader_SettingsDownloadLogosOnLibUpdateSelectLogosAutomaticallyLabel}" />
<CheckBox Margin="0,0,0,10" IsChecked="{Binding Settings.UseLaunchBoxForAutomaticLogoDownloads}"
Content="{DynamicResource LOCExtra_Metadata_Loader_SettingsUseLaunchBoxForAutomaticLogoDownloadsLabel}" />
</StackPanel>
<CheckBox Margin="0,0,0,10" Name="CbProcessLogosOnDownload"
IsChecked="{Binding Settings.ProcessLogosOnDownload}"
Expand Down Expand Up @@ -320,4 +322,4 @@
</TabControl>
</ScrollViewer>
</DockPanel>
</UserControl>
</UserControl>
5 changes: 4 additions & 1 deletion source/Generic/ExtraMetadataLoader/Localization/en_US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<sys:String x:Key="LOCExtra_Metadata_Loader_SettingsDownloadVideosMicroOnLibUpdateLabel">Download Micro videos of newly added games on library update</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_SettingsDownloadLogosOnLibUpdateLabel">Download logos of newly added games on library update</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_SettingsDownloadLogosOnLibUpdateSelectLogosAutomaticallyLabel">Select logos to download automatically</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_SettingsUseLaunchBoxForAutomaticLogoDownloadsLabel">Use LaunchBox for automatic logo downloads</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_VideoLabel">Video</sys:String>

<sys:String x:Key="LOCExtra_Metadata_Loader_Browser_OptionHorizontalAlignmentLeft">Left</sys:String>
Expand All @@ -66,6 +67,7 @@
<sys:String x:Key="LOCExtra_Metadata_Loader_DialogMessageDownloadingVideosSteam">Downloading videos from Steam...</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_DialogMessageDownloadingVideosMicroSteam">Downloading Micro videos from Steam...</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_DialogMessageDownloadingLogosSteam">Downloading logos from Steam...</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_DialogMessageDownloadingLogosLaunchBox">Downloading logos from LaunchBox...</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_DialogMessageDownloadingLogosSgdb">Downloading logos from SteamGridDB...</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_DialogMessageDownloadingVideoYoutube">Downloading video from YouTube...</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_DialogMessageDownloadingVideoYoutubeErrorMessage" xml:space="preserve">Failed to download video from YouTube.
Expand All @@ -87,6 +89,7 @@ Please verify that your yt-dlp installation is up to date.</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_MenuItemDescriptionDownloadSteamVideosSelectedGames">Download videos from Steam for selected games</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_MenuItemDescriptionDownloadSteamVideosMicroSelectedGames">Download Micro videos from Steam for selected games</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_MenuItemDescriptionDownloadSteamLogosSelectedGames">Download logos from Steam for selected games</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_MenuItemDescriptionDownloadLaunchBoxLogosSelectedGames">Download logos from LaunchBox for selected games</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_MenuItemDescriptionDownloadSgdbLogosSelectedGames">Download logos from SteamGridDB for selected games</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_MenuItemDescriptionOpenExtraMetadataDirectory">Open Extra Metadata directory</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_MenuItemDescriptionDeleteLogosSelectedGames">Delete logos of selected games</sys:String>
Expand Down Expand Up @@ -161,4 +164,4 @@ Failed to get video information: {0}, {1}, {2}.</sys:String>
Failed to process video in ffmpeg: {0}, {1}, {2}</sys:String>
<sys:String x:Key="LOCExtra_Metadata_Loader_NotificationErrorYtdlpDownloadFail" xml:space="preserve">Extra Metadata Loader
Error during download of video from YouTube: {0}, {1}, {2}</sys:String>
</ResourceDictionary>
</ResourceDictionary>
Loading