Skip to content

Commit

Permalink
refactor: promote auto merge version from the experimental section
Browse files Browse the repository at this point in the history
- Promote the auto-merge multiple versions setting from the experimental section to the library section. The name is kept in the xml settings for now so people won't have to manually re-enable it.

- Remove the split & merge options from the settings UI, since I forgot when I removed them from the code earlier.
  • Loading branch information
revam committed Sep 11, 2024
1 parent 1b37ccc commit cad46bb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 38 deletions.
13 changes: 7 additions & 6 deletions Shokofin/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ public virtual string PrettyUrl

#region Library

/// <summary>
/// Automagically merge alternate versions after a library scan.
/// </summary>
[XmlElement("EXPERIMENTAL_AutoMergeVersions")]
public bool AutoMergeVersions { get; set; }

/// <summary>
/// Use Shoko Groups to group Shoko Series together to create the show entries.
/// </summary>
Expand Down Expand Up @@ -438,11 +444,6 @@ public virtual string PrettyUrl

#region Experimental features

/// <summary>
/// Automagically merge alternate versions after a library scan.
/// </summary>
public bool EXPERIMENTAL_AutoMergeVersions { get; set; }

/// <summary>
/// Blur the boundaries between AniDB anime further by merging entries which could had just been a single anime entry based on name matching and a configurable merge window.
/// </summary>
Expand Down Expand Up @@ -536,6 +537,7 @@ public PluginConfiguration()
VFS_Threads = 4;
VFS_AddReleaseGroup = false;
VFS_AddResolution = false;
AutoMergeVersions = true;
UseGroupsForShows = false;
SeparateMovies = false;
FilterMovieLibraries = true;
Expand All @@ -560,7 +562,6 @@ public PluginConfiguration()
SignalR_RefreshEnabled = false;
SignalR_FileEvents = false;
UsageTracker_StalledTimeInSeconds = 10;
EXPERIMENTAL_AutoMergeVersions = true;
EXPERIMENTAL_MergeSeasons = false;
EXPERIMENTAL_MergeSeasonsTypes = new[] { SeriesType.OVA, SeriesType.TV, SeriesType.TVSpecial, SeriesType.Web, SeriesType.OVA };
EXPERIMENTAL_MergeSeasonsMergeWindowInDays = 185;
Expand Down
13 changes: 3 additions & 10 deletions Shokofin/Configuration/configController.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ async function defaultSubmit(form) {
config.AddTMDBId = form.querySelector("#AddTMDBId").checked;

// Library settings
config.AutoMergeVersions = form.querySelector("#AutoMergeVersions").checked;
config.UseGroupsForShows = form.querySelector("#UseGroupsForShows").checked;
config.SeasonOrdering = form.querySelector("#SeasonOrdering").value;
config.CollectionGrouping = form.querySelector("#CollectionGrouping").value;
Expand Down Expand Up @@ -360,9 +361,6 @@ async function defaultSubmit(form) {


// Experimental settings
config.EXPERIMENTAL_AutoMergeVersions = form.querySelector("#EXPERIMENTAL_AutoMergeVersions").checked;
config.EXPERIMENTAL_SplitThenMergeMovies = form.querySelector("#EXPERIMENTAL_SplitThenMergeMovies").checked;
config.EXPERIMENTAL_SplitThenMergeEpisodes = form.querySelector("#EXPERIMENTAL_SplitThenMergeEpisodes").checked;
config.EXPERIMENTAL_MergeSeasons = form.querySelector("#EXPERIMENTAL_MergeSeasons").checked;

// User settings
Expand Down Expand Up @@ -518,6 +516,7 @@ async function syncSettings(form) {
config.AddTMDBId = form.querySelector("#AddTMDBId").checked;

// Library settings
config.AutoMergeVersions = form.querySelector("#AutoMergeVersions").checked;
config.UseGroupsForShows = form.querySelector("#UseGroupsForShows").checked;
config.SeasonOrdering = form.querySelector("#SeasonOrdering").value;
config.SeparateMovies = form.querySelector("#SeparateMovies").checked;
Expand All @@ -532,9 +531,6 @@ async function syncSettings(form) {
config.AddMissingMetadata = form.querySelector("#AddMissingMetadata").checked;

// Experimental settings
config.EXPERIMENTAL_AutoMergeVersions = form.querySelector("#EXPERIMENTAL_AutoMergeVersions").checked;
config.EXPERIMENTAL_SplitThenMergeMovies = form.querySelector("#EXPERIMENTAL_SplitThenMergeMovies").checked;
config.EXPERIMENTAL_SplitThenMergeEpisodes = form.querySelector("#EXPERIMENTAL_SplitThenMergeEpisodes").checked;
config.EXPERIMENTAL_MergeSeasons = form.querySelector("#EXPERIMENTAL_MergeSeasons").checked;

const result = await ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config);
Expand Down Expand Up @@ -982,6 +978,7 @@ export default function (page) {
form.querySelector("#AddTMDBId").checked = config.AddTMDBId;

// Library settings
form.querySelector("#AutoMergeVersions").checked = config.AutoMergeVersions || false;
if (form.querySelector("#UseGroupsForShows").checked = config.UseGroupsForShows) {
form.querySelector("#SeasonOrderingContainer").removeAttribute("hidden");
form.querySelector("#SeasonOrdering").disabled = false;
Expand Down Expand Up @@ -1027,10 +1024,6 @@ export default function (page) {
userSelector.innerHTML += users.map((user) => `<option value="${user.Id}">${user.Name}</option>`).join("");

// Experimental settings
form.querySelector("#EXPERIMENTAL_AutoMergeVersions").checked = config.EXPERIMENTAL_AutoMergeVersions || false;
form.querySelector("#EXPERIMENTAL_SplitThenMergeMovies").checked = config.EXPERIMENTAL_SplitThenMergeMovies != null
? config.EXPERIMENTAL_SplitThenMergeMovies : true;
form.querySelector("#EXPERIMENTAL_SplitThenMergeEpisodes").checked = config.EXPERIMENTAL_SplitThenMergeEpisodes || false;
form.querySelector("#EXPERIMENTAL_MergeSeasons").checked = config.EXPERIMENTAL_MergeSeasons || false;

if (!config.ApiKey) {
Expand Down
28 changes: 7 additions & 21 deletions Shokofin/Configuration/configPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,13 @@ <h3>Library Settings</h3>
<div class="fieldDescription verticalSection-extrabottompadding">
Placeholder description.
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input is="emby-checkbox" type="checkbox" id="AutoMergeVersions" />
<span>Automatically merge multiple versions of videos</span>
</label>
<div class="fieldDescription checkboxFieldDescription"><div>Automatically merge multiple versions of the same video together after a library scan or refresh. Only applies to videos with Shoko IDs set.</div></div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input is="emby-checkbox" type="checkbox" id="UseGroupsForShows" />
Expand Down Expand Up @@ -1575,27 +1582,6 @@ <h3>User Settings</h3>
<h3>Experimental Settings</h3>
</legend>
<div class="fieldDescription verticalSection-extrabottompadding">Any features/settings in this section is still considered to be in an experimental state. <strong>You can enable them, but at the risk if them messing up your library.</strong></div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input is="emby-checkbox" type="checkbox" id="EXPERIMENTAL_AutoMergeVersions" />
<span>Automatically merge multiple versions</span>
</label>
<div class="fieldDescription checkboxFieldDescription"><div>Automatically merge multiple versions of the same item together after a library scan. Only applies to items with a Shoko ID set.</div></div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input is="emby-checkbox" type="checkbox" id="EXPERIMENTAL_SplitThenMergeMovies" />
<span>Always split existing versions of movies before merging multiple versions</span>
</label>
<div class="fieldDescription checkboxFieldDescription"><div>Always split existing merged items before starting the merge.</div><details style="margin-top: 0.5em"><summary style="margin-bottom: 0.25em">What is this setting for?</summary>Enabling this setting will make sure there will be no merge conflicts by splitting up all the existing merged versions. It will probably also make the plugin do a lot of unneeded work 99.5% of the time, but will help for the last 0.5% that actually need this to be done before every merge. An example is ensuring multiple parts of a movie series (e.g. "Part 1", "Part 2", etc.) are not merged in core Jellyfin because they contain the same Shoko Series Id.</details></div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input is="emby-checkbox" type="checkbox" id="EXPERIMENTAL_SplitThenMergeEpisodes" />
<span>Always split existing versions of episodes before merging multiple versions</span>
</label>
<div class="fieldDescription checkboxFieldDescription"><div>Always split existing merged items before starting the merge.</div><details style="margin-top: 0.5em"><summary style="margin-bottom: 0.25em">What is this setting for?</summary>Enabling this setting will make sure there will be no merge conflicts by splitting up all the existing merged versions. It will probably also make the plugin do a lot of unneeded work 99.5% of the time, but will help for the last 0.5% that actually need this to be done before every merge.</details></div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input is="emby-checkbox" type="checkbox" id="EXPERIMENTAL_MergeSeasons" />
Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Tasks/PostScanTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public PostScanTask(MergeVersionsManager versionsManager, CollectionManager coll
public async Task Run(IProgress<double> progress, CancellationToken token)
{
// Merge versions now if the setting is enabled.
if (Plugin.Instance.Configuration.EXPERIMENTAL_AutoMergeVersions) {
if (Plugin.Instance.Configuration.AutoMergeVersions) {
// Setup basic progress tracking
var baseProgress = 0d;
var simpleProgress = new Progress<double>(value => progress.Report(baseProgress + (value / 2d)));
Expand Down

0 comments on commit cad46bb

Please sign in to comment.