Skip to content

Commit

Permalink
Restrict to Windows/Proton
Browse files Browse the repository at this point in the history
Restricted mod functionality to only work when used with the Windows version of Resonite (or under proton). Additional code cleanup for potential future features related to appending arguments.
  • Loading branch information
Raidriar796 committed Apr 22, 2024
1 parent bb7d9ac commit 76a0d95
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
72 changes: 41 additions & 31 deletions ytdlpUpdater/ytdlpUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ResoniteModLoader;
using FrooxEngine;
using ResoniteModLoader;
using System.Diagnostics;

namespace ytdlpUpdater;
Expand All @@ -7,7 +8,7 @@ public class ytdlpUpdater : ResoniteMod
{
public override string Name => "yt-dlp Updater";
public override string Author => "Raidriar796";
public override string Version => "1.1.0";
public override string Version => "1.2.0";
public override string Link => "https://github.com/Raidriar796/yt-dlp-Updater";

public static ModConfiguration Config;
Expand All @@ -23,13 +24,22 @@ public override void OnEngineInit()
Config = GetConfiguration();
Config.Save(true);

//Runs update on startup
Update(Config.GetValue(UpdateBranch));
if (Engine.Current.Platform == Platform.Windows)
{
//Runs update on startup
Update(Config.GetValue(UpdateBranch));

//Runs update on config change
UpdateBranch.OnChanged += (value) => { Update(Config.GetValue(UpdateBranch)); };
//Runs update on config change
UpdateBranch.OnChanged += (value) => { Update(Config.GetValue(UpdateBranch)); };
}
else
{
Msg("This mod is only supported on Windows/Proton");
}
}

private static String branchArgs = "";

public enum Branch
{
Stable,
Expand All @@ -39,35 +49,35 @@ public enum Branch

private static void Update(Branch SelectedBranch)
{
switch (SelectedBranch)
if (File.Exists("RuntimeData/yt-dlp.exe"))
{
case Branch.Stable:
Process process1 = new Process();
process1.StartInfo.FileName = "RuntimeData/yt-dlp.exe";
process1.StartInfo.Arguments = "--update-to stable@latest";
process1.Start();
break;
switch (SelectedBranch)
{
case Branch.Stable:
branchArgs = "--update-to stable@latest";
break;

case Branch.Nightly:
branchArgs = "--update-to nightly@latest";
break;

case Branch.Nightly:
Process process2 = new Process();
process2.StartInfo.FileName = "RuntimeData/yt-dlp.exe";
process2.StartInfo.Arguments = "--update-to nightly@latest";
process2.Start();
break;
case Branch.Master:
branchArgs = "--update-to master@latest";
break;

case Branch.Master:
Process process3 = new Process();
process3.StartInfo.FileName = "RuntimeData/yt-dlp.exe";
process3.StartInfo.Arguments = "--update-to master@latest";
process3.Start();
break;
default:
branchArgs = "--update-to stable@latest";
break;
}

default:
Process process4 = new Process();
process4.StartInfo.FileName = "RuntimeData/yt-dlp.exe";
process4.StartInfo.Arguments = "--update-to stable@latest";
process4.Start();
break;
Process updateProcess = new Process();
updateProcess.StartInfo.FileName = "RuntimeData/yt-dlp.exe";
updateProcess.StartInfo.Arguments = branchArgs;
updateProcess.Start();
}
else
{
Msg("yt-dlp.exe not found in RuntimeData folder, you may want to validate files or manually redownload yt-dlp");
}
}
}
7 changes: 4 additions & 3 deletions ytdlpUpdater/ytdlpUpdater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<AssemblyTitle>ytdlpUpdater</AssemblyTitle>
<Authors>Raidriar796</Authors>
<Copyright>Copyright © 2023 Raidriar796</Copyright>
<Version>1.1.0</Version>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<Version>1.2.0</Version>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<FileVersion>1.2.0.0</FileVersion>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<TargetFramework>net472</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -19,6 +19,7 @@

<PropertyGroup Condition="'$(ResonitePath)'==''">
<ResonitePath Condition="Exists('C:\Program Files (x86)\Steam\steamapps\common\Resonite\')">C:\Program Files (x86)\Steam\steamapps\common\Resonite\</ResonitePath>
<ResonitePath Condition="Exists('$(HOME)/.steam/steam/steamapps/common/Resonite/')">$(HOME)/.steam/steam/steamapps/common/Resonite/</ResonitePath>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 76a0d95

Please sign in to comment.