Skip to content

Commit

Permalink
Fix splitting not taking into account excluded libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
danieladov committed Apr 20, 2023
1 parent 45ba528 commit b8d2cf5
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Jellyfin.Plugin.MergeVersions.Api
/// The Merge Versions api controller.
/// </summary>
[ApiController]
[Authorize(Policy = "DefaultAuthorization")]
[Authorize]
[Route("MergeVersions")]
[Produces(MediaTypeNames.Application.Json)]
public class MergeVersionsController : ControllerBase
Expand Down
129 changes: 65 additions & 64 deletions Jellyfin.Plugin.MergeVersions/Configuration/configurationpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ <h3 class="checkboxListLabel">Select paths to exclude from merging:</h3>
</div>
</div>

<button is="emby-button" type="button" class="raised button-submit block emby-button" id="refresh-library"
onclick=save()><span>Save</span></button>

<button is="emby-button" type="button" class="raised button-submit block emby-button"
id="refresh-library" onclick=save()><span>Save</span></button>

<button is="emby-button" type="button" class="raised block" id="refresh-library"
onclick=mergeMovies()><span>Merge All Movies</span></button>
Expand All @@ -52,7 +52,7 @@ <h3 class="checkboxListLabel">Select paths to exclude from merging:</h3>

var pluginId = "f21bbed8-3a97-4d8b-88b2-48aaa65427cb";


function mergeMovies() {
var request = {
url: ApiClient.getUrl('MergeVersions/MergeMovies'),
Expand Down Expand Up @@ -114,93 +114,94 @@ <h3 class="checkboxListLabel">Select paths to exclude from merging:</h3>
var config = undefined;

ApiClient.getPluginConfiguration(pluginId).then(function (savedConfig) {
config = savedConfig;
config = savedConfig;

if (!config) {
config.LocationsExcluded = [];
}

ApiClient.getVirtualFolders().then(function (virtualFolders) {
loadVirtualFolders(config, virtualFolders);
});


});

if (!config) {
config.LocationsExcluded =[];
}

ApiClient.getVirtualFolders().then(function (virtualFolders) {
loadVirtualFolders(config, virtualFolders);
});


});








function loadVirtualFolders(config, virtualFolders){

function loadVirtualFolders(config, virtualFolders) {
var page = $.mobile.activePage;
var html = "";
html += '<div data-role="controlgroup">';
for (var i = 0, length = virtualFolders.length; i < length; i++) {
var virtualFolder = virtualFolders[i];
html += getFolderHtml(config, virtualFolder, i);
}
html += '</div>';
$('#divTraktLocations', page).html(html).trigger('create');
html += '<div data-role="controlgroup">';
for (var i = 0, length = virtualFolders.length; i < length; i++) {
var virtualFolder = virtualFolders[i];
html += getFolderHtml(config, virtualFolder, i);
}
html += '</div>';
$('#divTraktLocations', page).html(html).trigger('create');

}

function getFolderHtml(currentUserConfig, virtualFolder, index) {
var html = "";
for (var i = 0, length = virtualFolder.Locations.length; i < length; i++) {
var id = "chkFolder" + index + "_" + i;
var location = virtualFolder.Locations[i];
var isChecked = currentUserConfig.LocationsExcluded.filter(function (current) {
return current.toLowerCase() == location.toLowerCase();
}).length;
var checkedAttribute = isChecked ? 'checked="checked"' : "";
html += '<label><input is="emby-checkbox" class="chkLibrary" type="checkbox" data-mini="true" id="' + id + '" name="' + id + '" data-location="' + location + '" ' + checkedAttribute + ' /><span>' + location + " - " + virtualFolder.Name + '</span></label>';
}
return html;
}

function getFolderHtml (currentUserConfig, virtualFolder, index) {
var html = "";
for (var i = 0, length = virtualFolder.Locations.length; i < length; i++) {
var id = "chkFolder" + index + "_" + i;
var location = virtualFolder.Locations[i];
var isChecked = currentUserConfig.LocationsExcluded.filter(function (current) {
return current.toLowerCase() == location.toLowerCase();
}).length;
var checkedAttribute = isChecked ? 'checked="checked"' : "";
html += '<label><input is="emby-checkbox" class="chkLibrary" type="checkbox" data-mini="true" id="' + id + '" name="' + id + '" data-location="' + location + '" ' + checkedAttribute + ' /><span>' + location + " - " + virtualFolder.Name + '</span></label>';
}
return html;
}


function save(){
var folders = $('.chkLibrary:checked').map(function () {
return this.getAttribute('data-location');
}).get();



ApiClient.getPluginConfiguration(pluginId).then(function (config){
config.LocationsExcluded = folders;
ApiClient.updatePluginConfiguration(pluginId,config).then(function (res){
Dashboard.processPluginConfigurationUpdateResult(res);});

function save() {
var folders = $('.chkLibrary:checked').map(function () {
return this.getAttribute('data-location');
}).get();



ApiClient.getPluginConfiguration(pluginId).then(function (config) {
config.LocationsExcluded = folders;
ApiClient.updatePluginConfiguration(pluginId, config).then(function (res) {
Dashboard.processPluginConfigurationUpdateResult(res);
});


}
});


}

$('.traktConfigurationPage').on('pageinit', function () {
var page = this;
$('#traktConfigurationForm', page).on('submit', function(){
$('#traktConfigurationForm', page).on('submit', function () {
save();
return false;
});
});

























</script>
</div>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.8.0-alpha5" />
<PackageReference Include="Jellyfin.Controller" Version="10.8.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.0" />
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.1.0" />
Expand All @@ -22,13 +22,13 @@
</ItemGroup>

<ItemGroup>
<Reference Include="Jellyfin.Api">
<HintPath>..\..\jellyfin\Jellyfin.Api\bin\Debug\net6.0\Jellyfin.Api.dll</HintPath>
</Reference>
<Folder Include="ReferencedAssemblies\" />
</ItemGroup>

<ItemGroup>
<Folder Include="ReferencedAssemblies\" />
<Reference Include="Jellyfin.Api">
<HintPath>..\..\jellyfin\Jellyfin.Api\bin\Debug\net6.0\Jellyfin.Api.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions Jellyfin.Plugin.MergeVersions/MergeVersionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void MergeMovies(IProgress<double> progress)
public void SplitMovies(IProgress<double> progress)
{
var movies = GetMoviesFromLibrary().ToArray();
movies = movies.Where(isElegible).ToArray();
var total = movies.Count();
var current = 0;
//foreach grouping, merge
Expand Down
10 changes: 10 additions & 0 deletions Jellyfin.Plugin.MergeVersions/ScheduledTasks/RefreshLibraryTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
};
}

public Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
{
return Execute(cancellationToken, progress);
}

public string Name => "Merge All Movies";
public string Key => "MergeMoviesTask";
public string Description => "Scans all libraries to merge repeated movies";
Expand Down Expand Up @@ -124,6 +129,11 @@ public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
};
}

public Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
{
return Execute(cancellationToken, progress);
}

public string Name => "Merge All Episodes";
public string Key => "MergeEpisodesTask";
public string Description => "Merges all repeated episodes";
Expand Down

0 comments on commit b8d2cf5

Please sign in to comment.