added endpoints to refresh items by name
This commit is contained in:
parent
3b2b9c59b2
commit
6c3c8490c9
|
@ -22,6 +22,61 @@ namespace MediaBrowser.Api
|
|||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Artists/{Name}/Refresh", "POST")]
|
||||
[Api(Description = "Refreshes metadata for an artist")]
|
||||
public class RefreshArtist : IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "Forced", Description = "Indicates if a normal or forced refresh should occur.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
|
||||
public bool Forced { get; set; }
|
||||
|
||||
[ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Genres/{Name}/Refresh", "POST")]
|
||||
[Api(Description = "Refreshes metadata for a genre")]
|
||||
public class RefreshGenre : IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "Forced", Description = "Indicates if a normal or forced refresh should occur.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
|
||||
public bool Forced { get; set; }
|
||||
|
||||
[ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
[Route("/MusicGenres/{Name}/Refresh", "POST")]
|
||||
[Api(Description = "Refreshes metadata for a music genre")]
|
||||
public class RefreshMusicGenre : IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "Forced", Description = "Indicates if a normal or forced refresh should occur.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
|
||||
public bool Forced { get; set; }
|
||||
|
||||
[ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Persons/{Name}/Refresh", "POST")]
|
||||
[Api(Description = "Refreshes metadata for a person")]
|
||||
public class RefreshPerson : IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "Forced", Description = "Indicates if a normal or forced refresh should occur.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
|
||||
public bool Forced { get; set; }
|
||||
|
||||
[ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Studios/{Name}/Refresh", "POST")]
|
||||
[Api(Description = "Refreshes metadata for a studio")]
|
||||
public class RefreshStudio : IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "Forced", Description = "Indicates if a normal or forced refresh should occur.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
|
||||
public bool Forced { get; set; }
|
||||
|
||||
[ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class ItemRefreshService : BaseApiService
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
@ -33,6 +88,111 @@ namespace MediaBrowser.Api
|
|||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public void Post(RefreshArtist request)
|
||||
{
|
||||
var task = RefreshArtist(request);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
private async Task RefreshArtist(RefreshArtist request)
|
||||
{
|
||||
var item = await GetArtist(request.Name, _libraryManager).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
await item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error refreshing library", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void Post(RefreshGenre request)
|
||||
{
|
||||
var task = RefreshGenre(request);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
private async Task RefreshGenre(RefreshGenre request)
|
||||
{
|
||||
var item = await GetGenre(request.Name, _libraryManager).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
await item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error refreshing library", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void Post(RefreshMusicGenre request)
|
||||
{
|
||||
var task = RefreshMusicGenre(request);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
private async Task RefreshMusicGenre(RefreshMusicGenre request)
|
||||
{
|
||||
var item = await GetMusicGenre(request.Name, _libraryManager).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
await item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error refreshing library", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void Post(RefreshPerson request)
|
||||
{
|
||||
var task = RefreshPerson(request);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
private async Task RefreshPerson(RefreshPerson request)
|
||||
{
|
||||
var item = await GetPerson(request.Name, _libraryManager).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
await item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error refreshing library", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void Post(RefreshStudio request)
|
||||
{
|
||||
var task = RefreshStudio(request);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
private async Task RefreshStudio(RefreshStudio request)
|
||||
{
|
||||
var item = await GetStudio(request.Name, _libraryManager).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
await item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error refreshing library", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the specified request.
|
||||
/// </summary>
|
||||
|
@ -43,7 +203,7 @@ namespace MediaBrowser.Api
|
|||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the item.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user