Skip to content

Commit

Permalink
Added button to clean library of past intros
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianCArnold committed May 22, 2023
1 parent 3ff45cc commit 3550726
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
20 changes: 20 additions & 0 deletions Jellyfin.Plugin.LocalIntros/API/LocalIntrosController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ public IActionResult LoadIntros()
PopulateIntroLibrary();
return Ok();
}

[HttpPost("ClearIntros")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public IActionResult ClearIntros()
{
logger.LogInformation("Clearing Intros");
LocalIntrosPlugin.LibraryManager.GetItemsResult(new InternalItemsQuery
{
HasAnyProviderId = new Dictionary<string, string>
{
{"prerolls.video", ""}
}
}).Items.ToList().ForEach(x =>
{
logger.LogInformation($"Removing {x.Path} from library.");
LocalIntrosPlugin.LibraryManager.DeleteItem(x, new DeleteOptions());
});
return Ok();
}


private static string introsPath => LocalIntrosPlugin.Instance.Configuration.Local;
Expand Down
18 changes: 17 additions & 1 deletion Jellyfin.Plugin.LocalIntros/Configuration/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<span>Load Videos</span>
</button>

<button id="clearVideosBtn" is="emby-button" type="button" class="raised button-submit block emby-button">
<span>Clean Intros (if you used old plugin)</span>
</button>

</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="ruleSelection">Rule Type</label>
Expand Down Expand Up @@ -215,6 +219,12 @@
ApiClient.ajax({ type: 'POST', url, data, contentType: 'application/json' }).then(() => {loadPage()}).catch(ev => alert(ev));
}

var clearIntros = () => {
let url = ApiClient.getUrl('LocalIntros/ClearIntros');
let data = {};
ApiClient.ajax({ type: 'POST', url, data, contentType: 'application/json' }).then(() => {loadPage()}).catch(ev => alert(ev));
}

var addTagIntroRule = (introId, precedence, prevalence) =>
{
var tagRule = {
Expand Down Expand Up @@ -392,7 +402,13 @@

$('#loadVideosBtn').click(ev => {
saveChanges().then(() => loadVideos());
})
});

$('#clearVideosBtn').click(async ev => {
await saveChanges();
await clearIntros();
await loadVideos();
});

$('#local').change(ev => {
localIntroConfig.Local = $('#local').val();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.LocalIntros</RootNamespace>
<AssemblyVersion>2.2.0.99</AssemblyVersion>
<FileVersion>2.2.0.99</FileVersion>
<AssemblyVersion>2.2.0.100</AssemblyVersion>
<FileVersion>2.2.0.100</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 3550726

Please sign in to comment.