Skip to content

Commit

Permalink
New MovieOrganizer PlugIn
Browse files Browse the repository at this point in the history
  • Loading branch information
softworkz committed Jul 22, 2016
1 parent cbb5063 commit 07fbd20
Show file tree
Hide file tree
Showing 18 changed files with 1,802 additions and 0 deletions.
8 changes: 8 additions & 0 deletions MediaBrowser.Plugins.sln
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetadataViewer", "MetadataV
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Plugins.ADEProvider", "MediaBrowser.Plugins.ADEProvider\MediaBrowser.Plugins.ADEProvider.csproj", "{2F1E5734-05C5-495D-B11B-42C4762CF4CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MovieOrganizer", "MovieOrganizer\MovieOrganizer.csproj", "{0449243E-8FBD-47DF-8E79-8FBA6E735D36}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -200,6 +202,12 @@ Global
{2F1E5734-05C5-495D-B11B-42C4762CF4CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F1E5734-05C5-495D-B11B-42C4762CF4CF}.Release|Any CPU.Build.0 = Release|Any CPU
{2F1E5734-05C5-495D-B11B-42C4762CF4CF}.Release|x86.ActiveCfg = Release|Any CPU
{0449243E-8FBD-47DF-8E79-8FBA6E735D36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0449243E-8FBD-47DF-8E79-8FBA6E735D36}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0449243E-8FBD-47DF-8E79-8FBA6E735D36}.Debug|x86.ActiveCfg = Debug|Any CPU
{0449243E-8FBD-47DF-8E79-8FBA6E735D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0449243E-8FBD-47DF-8E79-8FBA6E735D36}.Release|Any CPU.Build.0 = Release|Any CPU
{0449243E-8FBD-47DF-8E79-8FBA6E735D36}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
54 changes: 54 additions & 0 deletions MovieOrganizer/Api/MovieOrganizerApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging;
using MovieOrganizer.Service;
using ServiceStack;
using System.Threading;

namespace MovieOrganizer.Api
{
[Route("/Library/FileOrganizations/{Id}/Movie/OrganizeExt", "POST", Summary = "Performs organization of a movie file")]
public class OrganizeMovie
{
[ApiMember(Name = "Id", Description = "Result Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
public string Id { get; set; }

[ApiMember(Name = "MovieName", Description = "Movie Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
public string MovieName { get; set; }

[ApiMember(Name = "MovieYear", Description = "Movie Year", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
public string MovieYear { get; set; }

[ApiMember(Name = "TargetFolder", Description = "Target Folder", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
public string TargetFolder { get; set; }
}

[Authenticated]
public class MovieOrganizerApi : IRestfulService
{
private readonly ILogger _logger;
private readonly MovieOrganizerService _service;
private readonly ILibraryManager _libraryManager;

public MovieOrganizerApi(ILogManager logManager, MovieOrganizerService service, ILibraryManager libraryManager)
{
_logger = logManager.GetLogger(GetType().Name);
_service = service;
_libraryManager = libraryManager;
}

public void Post(OrganizeMovie request)
{
var task = _service.PerformMovieOrganization(new MovieFileOrganizationRequest
{
ResultId = request.Id,
Name = request.MovieName,
Year = request.MovieYear,
TargetFolder = request.TargetFolder
});

// Wait 2s for exceptions that may occur and would be automatically forwarded to the client for immediate error display
task.Wait(2000);
}
}
}
12 changes: 12 additions & 0 deletions MovieOrganizer/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using MediaBrowser.Model.Plugins;
using System;

namespace MovieOrganizer.Configuration
{
public class PluginConfiguration : BasePluginConfiguration
{
public PluginConfiguration()
{
}
}
}
Loading

0 comments on commit 07fbd20

Please sign in to comment.