Skip to content

Commit

Permalink
Added branch changing
Browse files Browse the repository at this point in the history
Added config option to change the update branch.
Changed startup function to call the update branch method instead to apply manual config changes.
  • Loading branch information
Raidriar796 committed Dec 25, 2023
1 parent 7a2e620 commit f34564c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# yt-dlp Updater

A [ResoniteModLoader](https://github.com/resonite-modding-group/ResoniteModLoader) mod for [Resonite](https://resonite.com/) that runs the built in update function for yt-dlp on startup.
A [ResoniteModLoader](https://github.com/resonite-modding-group/ResoniteModLoader) mod for [Resonite](https://resonite.com/) that runs the built in update function for yt-dlp on startup, includes option to change the update branch.


## Requirements
- [ResoniteModLoader](https://github.com/resonite-modding-group/ResoniteModLoader)
- [Python 3.8+](https://www.python.org/downloads/)

## Installation
1. Install [ResoniteModLoader](https://github.com/resonite-modding-group/ResoniteModLoader).
Expand Down
65 changes: 59 additions & 6 deletions ytdlpUpdater/ytdlpUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,69 @@ namespace ytdlpUpdater;

public class ytdlpUpdater : ResoniteMod
{
public override string Name => "yt-dlp-Updater";
public override string Name => "yt-dlp Updater";
public override string Author => "Raidriar796";
public override string Version => "1.0.0";
public override string Version => "1.1.0";
public override string Link => "https://github.com/Raidriar796/yt-dlp-Updater";

public static ModConfiguration Config;

[AutoRegisterConfigKey] public static readonly ModConfigurationKey<Branch> UpdateBranch =
new ModConfigurationKey<Branch>(
"UpdateBranch",
"Update branch.",
() => Branch.Stable);

public override void OnEngineInit()
{
Process process = new Process();
process.StartInfo.FileName = "RuntimeData/yt-dlp.exe";
process.StartInfo.Arguments = "-U";
process.Start();
Config = GetConfiguration();
Config.Save(true);

//Runs update on startup
Update(Config.GetValue(UpdateBranch));

//Runs update on config change
UpdateBranch.OnChanged += (value) => { Update(Config.GetValue(UpdateBranch)); };
}

public enum Branch
{
Stable,
Nightly,
Master
}

private static void Update(Branch SelectedBranch)
{
switch (SelectedBranch)
{
case Branch.Stable:
Process process1 = new Process();
process1.StartInfo.FileName = "RuntimeData/yt-dlp.exe";
process1.StartInfo.Arguments = "--update-to stable@latest";
process1.Start();
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:
Process process3 = new Process();
process3.StartInfo.FileName = "RuntimeData/yt-dlp.exe";
process3.StartInfo.Arguments = "--update-to master@latest";
process3.Start();
break;

default:
Process process4 = new Process();
process4.StartInfo.FileName = "RuntimeData/yt-dlp.exe";
process4.StartInfo.Arguments = "--update-to stable@latest";
process4.Start();
break;
}
}
}
6 changes: 3 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.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Version>1.1.0</Version>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<TargetFramework>net472</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down

0 comments on commit f34564c

Please sign in to comment.