mirror of https://github.com/lidarr/Lidarr
Merge branch 'develop' of https://github.com/lidarr/Lidarr into develop
This commit is contained in:
commit
8bd9119954
|
@ -32,6 +32,11 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
{
|
||||
_mediaBrowserService.Notify(Settings, ALBUM_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
}
|
||||
|
||||
if (Settings.UpdateLibrary)
|
||||
{
|
||||
_mediaBrowserService.Update(Settings, message.Artist);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDownload(TrackDownloadMessage message)
|
||||
|
@ -40,11 +45,6 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
{
|
||||
_mediaBrowserService.Notify(Settings, TRACK_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
}
|
||||
|
||||
if (Settings.UpdateLibrary)
|
||||
{
|
||||
_mediaBrowserService.Update(Settings, message.Artist);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnRename(Artist artist)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Notifications.MediaBrowser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Emby
|
||||
{
|
||||
|
@ -20,22 +23,52 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
var path = "/Notifications/Admin";
|
||||
var request = BuildRequest(path, settings);
|
||||
request.Headers.ContentType = "application/json";
|
||||
request.Method = HttpMethod.POST;
|
||||
|
||||
request.SetContent(new
|
||||
{
|
||||
Name = title,
|
||||
Description = message,
|
||||
ImageUrl = "https://raw.github.com/lidarr/Lidarr/develop/Logo/64.png"
|
||||
}.ToJson());
|
||||
{
|
||||
Name = title,
|
||||
Description = message,
|
||||
ImageUrl = "https://raw.github.com/lidarr/Lidarr/develop/Logo/64.png"
|
||||
}.ToJson());
|
||||
|
||||
ProcessRequest(request, settings);
|
||||
}
|
||||
|
||||
public void Update(MediaBrowserSettings settings, string mbId)
|
||||
public void Update(MediaBrowserSettings settings, List<string> musicCollectionPaths)
|
||||
{
|
||||
var path = string.Format("/Library/Artist/Updated?tvdbid={0}", mbId); //TODO: Get Emby to add a new Library Route
|
||||
var request = BuildRequest(path, settings);
|
||||
request.Headers.Add("Content-Length", "0");
|
||||
string path;
|
||||
HttpRequest request;
|
||||
|
||||
if (musicCollectionPaths.Any())
|
||||
{
|
||||
path = "/Library/Media/Updated";
|
||||
request = BuildRequest(path, settings);
|
||||
request.Headers.ContentType = "application/json";
|
||||
|
||||
var updateInfo = new List<EmbyMediaUpdateInfo>();
|
||||
|
||||
foreach (var colPath in musicCollectionPaths)
|
||||
{
|
||||
updateInfo.Add(new EmbyMediaUpdateInfo
|
||||
{
|
||||
Path = colPath,
|
||||
UpdateType = "Created"
|
||||
});
|
||||
}
|
||||
|
||||
request.SetContent(new
|
||||
{
|
||||
Updates = updateInfo
|
||||
}.ToJson());
|
||||
}
|
||||
else
|
||||
{
|
||||
path = "/Library/Refresh";
|
||||
request = BuildRequest(path, settings);
|
||||
}
|
||||
|
||||
request.Method = HttpMethod.POST;
|
||||
|
||||
ProcessRequest(request, settings);
|
||||
}
|
||||
|
@ -44,7 +77,8 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
{
|
||||
request.Headers.Add("X-MediaBrowser-Token", settings.ApiKey);
|
||||
|
||||
var response = _httpClient.Post(request);
|
||||
var response = _httpClient.Execute(request);
|
||||
|
||||
_logger.Trace("Response: {0}", response.Content);
|
||||
|
||||
CheckForError(response);
|
||||
|
@ -55,7 +89,7 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
private HttpRequest BuildRequest(string path, MediaBrowserSettings settings)
|
||||
{
|
||||
var url = string.Format(@"http://{0}/mediabrowser", settings.Address);
|
||||
|
||||
|
||||
return new HttpRequestBuilder(url).Resource(path).Build();
|
||||
}
|
||||
|
||||
|
@ -65,5 +99,16 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
|
||||
//TODO: actually check for the error
|
||||
}
|
||||
|
||||
public List<EmbyMediaFolder> GetArtist(MediaBrowserSettings settings)
|
||||
{
|
||||
var path = "/Library/MediaFolders";
|
||||
var request = BuildRequest(path, settings);
|
||||
request.Method = HttpMethod.GET;
|
||||
|
||||
var response = ProcessRequest(request, settings);
|
||||
|
||||
return Json.Deserialize<EmbyMediaFoldersResponse>(response).Items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
|
@ -32,7 +33,11 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
|
||||
public void Update(MediaBrowserSettings settings, Artist artist)
|
||||
{
|
||||
_proxy.Update(settings, artist.ForeignArtistId);
|
||||
var folders = _proxy.GetArtist(settings);
|
||||
|
||||
var musicPaths = folders.Select(e => e.CollectionType = "music").ToList();
|
||||
|
||||
_proxy.Update(settings, musicPaths);
|
||||
}
|
||||
|
||||
public ValidationFailure Test(MediaBrowserSettings settings)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.MediaBrowser.Model
|
||||
{
|
||||
public class EmbyMediaFolder
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public string CollectionType { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.MediaBrowser.Model
|
||||
{
|
||||
public class EmbyMediaFoldersResponse
|
||||
{
|
||||
public List<EmbyMediaFolder> Items { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.MediaBrowser.Model
|
||||
{
|
||||
public class EmbyMediaUpdateInfo
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public string UpdateType { get; set; }
|
||||
}
|
||||
}
|
|
@ -872,6 +872,9 @@
|
|||
<Compile Include="Notifications\Boxcar\BoxcarProxy.cs" />
|
||||
<Compile Include="Notifications\Boxcar\BoxcarSettings.cs" />
|
||||
<Compile Include="Notifications\GrabMessage.cs" />
|
||||
<Compile Include="Notifications\MediaBrowser\Model\EmbyMediaFolder.cs" />
|
||||
<Compile Include="Notifications\MediaBrowser\Model\EmbyMediaFoldersResponse.cs" />
|
||||
<Compile Include="Notifications\MediaBrowser\Model\EmbyMediaUpdateInfo.cs" />
|
||||
<Compile Include="Notifications\Plex\Models\PlexIdentity.cs" />
|
||||
<Compile Include="Notifications\Plex\Models\PlexResponse.cs" />
|
||||
<Compile Include="Notifications\Plex\Models\PlexPreferences.cs" />
|
||||
|
|
Loading…
Reference in New Issue