Fixed: Remove MediaBrowser metadata and pushalot

pull/481/head
Qstick 6 years ago
parent 813f81b3c9
commit 2a992f6c2b

@ -0,0 +1,16 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(20)]
public class remove_pushalot : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Delete.FromTable("Notifications").Row(new { Implementation = "Pushalot" });
Delete.FromTable("Metadata").Row(new { Implementation = "MediaBrowserMetadata" });
Delete.FromTable("MetadataFiles").Row(new { Consumer = "MediaBrowserMetadata" });
}
}
}

@ -1,125 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Extras.Metadata.Files;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music;
namespace NzbDrone.Core.Extras.Metadata.Consumers.MediaBrowser
{
public class MediaBrowserMetadata : MetadataBase<MediaBrowserMetadataSettings>
{
private readonly Logger _logger;
public MediaBrowserMetadata(
Logger logger)
{
_logger = logger;
}
public override string Name => "Emby (Legacy)";
public override MetadataFile FindMetadataFile(Artist artist, string path)
{
var filename = Path.GetFileName(path);
if (filename == null) return null;
var metadata = new MetadataFile
{
ArtistId = artist.Id,
Consumer = GetType().Name,
RelativePath = artist.Path.GetRelativePath(path)
};
if (filename.Equals("artist.xml", StringComparison.InvariantCultureIgnoreCase))
{
metadata.Type = MetadataType.ArtistMetadata;
return metadata;
}
return null;
}
public override MetadataFileResult ArtistMetadata(Artist artist)
{
if (!Settings.ArtistMetadata)
{
return null;
}
_logger.Debug("Generating artist.xml for: {0}", artist.Name);
var sb = new StringBuilder();
var xws = new XmlWriterSettings();
xws.OmitXmlDeclaration = true;
xws.Indent = false;
using (var xw = XmlWriter.Create(sb, xws))
{
var artistElement = new XElement("Artist");
artistElement.Add(new XElement("id", artist.ForeignArtistId));
artistElement.Add(new XElement("Status", artist.Status));
artistElement.Add(new XElement("Added", artist.Added.ToString("MM/dd/yyyy HH:mm:ss tt")));
artistElement.Add(new XElement("LockData", "false"));
artistElement.Add(new XElement("Overview", artist.Overview));
artistElement.Add(new XElement("LocalTitle", artist.Name));
artistElement.Add(new XElement("Rating", artist.Ratings.Value));
var persons = new XElement("Persons");
foreach (var person in artist.Members)
{
persons.Add(new XElement("Person",
new XElement("Name", person.Name),
new XElement("Type", "Actor"),
new XElement("Role", person.Instrument)
));
}
artistElement.Add(persons);
var doc = new XDocument(artistElement);
doc.Save(xw);
_logger.Debug("Saving artist.xml for {0}", artist.Name);
return new MetadataFileResult("artist.xml", doc.ToString());
}
}
public override MetadataFileResult AlbumMetadata(Artist artist, Album album, string albumPath)
{
return null;
}
public override MetadataFileResult TrackMetadata(Artist artist, TrackFile trackFile)
{
return null;
}
public override List<ImageFileResult> ArtistImages(Artist artist)
{
return new List<ImageFileResult>();
}
public override List<ImageFileResult> AlbumImages(Artist artist, Album album, string albumFolder)
{
return new List<ImageFileResult>();
}
public override List<ImageFileResult> TrackImages(Artist artist, TrackFile trackFile)
{
return new List<ImageFileResult>();
}
}
}

@ -1,31 +0,0 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Extras.Metadata.Consumers.MediaBrowser
{
public class MediaBrowserSettingsValidator : AbstractValidator<MediaBrowserMetadataSettings>
{
}
public class MediaBrowserMetadataSettings : IProviderConfig
{
private static readonly MediaBrowserSettingsValidator Validator = new MediaBrowserSettingsValidator();
public MediaBrowserMetadataSettings()
{
ArtistMetadata = true;
}
[FieldDefinition(0, Label = "Artist Metadata", Type = FieldType.Checkbox, HelpText = "artist.xml")]
public bool ArtistMetadata { get; set; }
public bool IsValid => true;
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
}
}

@ -1,43 +0,0 @@
using System.Collections.Generic;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Notifications.Pushalot
{
public class Pushalot : NotificationBase<PushalotSettings>
{
private readonly IPushalotProxy _proxy;
public Pushalot(IPushalotProxy proxy)
{
_proxy = proxy;
}
public override string Name => "Pushalot";
public override string Link => "https://pushalot.com/";
public override void OnGrab(GrabMessage grabMessage)
{
_proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings);
}
public override void OnDownload(TrackDownloadMessage message)
{
_proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings);
}
public override void OnAlbumDownload(AlbumDownloadMessage message)
{
_proxy.SendNotification(ALBUM_DOWNLOADED_TITLE, message.Message, Settings);
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();
failures.AddIfNotNull(_proxy.Test(Settings));
return new ValidationResult(failures);
}
}
}

@ -1,9 +0,0 @@
namespace NzbDrone.Core.Notifications.Pushalot
{
public enum PushalotPriority
{
Silent = -1,
Normal = 0,
Important = 1
}
}

@ -1,106 +0,0 @@
using System;
using System.Net;
using FluentValidation.Results;
using NLog;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Rest;
using RestSharp;
namespace NzbDrone.Core.Notifications.Pushalot
{
public interface IPushalotProxy
{
void SendNotification(string title, string message, PushalotSettings settings);
ValidationFailure Test(PushalotSettings settings);
}
public class PushalotProxy : IPushalotProxy
{
private readonly Logger _logger;
private const string URL = "https://pushalot.com/api/sendmessage";
public PushalotProxy(Logger logger)
{
_logger = logger;
}
public void SendNotification(string title, string message, PushalotSettings settings)
{
var client = RestClientFactory.BuildClient(URL);
var request = BuildRequest();
request.AddParameter("Source", "Lidarr");
if (settings.Image)
{
request.AddParameter("Image", "https://raw.githubusercontent.com/Lidarr/Lidarr/develop/Logo/128.png");
}
request.AddParameter("Title", title);
request.AddParameter("Body", message);
request.AddParameter("AuthorizationToken", settings.AuthToken);
if ((PushalotPriority)settings.Priority == PushalotPriority.Important)
{
request.AddParameter("IsImportant", true);
}
if ((PushalotPriority)settings.Priority == PushalotPriority.Silent)
{
request.AddParameter("IsSilent", true);
}
client.ExecuteAndValidate(request);
}
public RestRequest BuildRequest()
{
var request = new RestRequest(Method.POST);
return request;
}
public ValidationFailure Test(PushalotSettings settings)
{
try
{
const string title = "Test Notification";
const string body = "This is a test message from Lidarr";
SendNotification(title, body, settings);
}
catch (RestException ex)
{
if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
{
_logger.Error(ex, "Authentication Token is invalid");
return new ValidationFailure("AuthToken", "Authentication Token is invalid");
}
if (ex.Response.StatusCode == HttpStatusCode.NotAcceptable)
{
_logger.Error(ex, "Message limit reached");
return new ValidationFailure("AuthToken", "Message limit reached");
}
if (ex.Response.StatusCode == HttpStatusCode.Gone)
{
_logger.Error(ex, "Authorization Token is no longer valid");
return new ValidationFailure("AuthToken", "Authorization Token is no longer valid, please use a new one.");
}
var response = Json.Deserialize<PushalotResponse>(ex.Response.Content);
_logger.Error(ex, "Unable to send test message");
return new ValidationFailure("AuthToken", response.Description);
}
catch (Exception ex)
{
_logger.Error(ex, "Unable to send test message");
return new ValidationFailure("", "Unable to send test message");
}
return null;
}
}
}

@ -1,9 +0,0 @@
namespace NzbDrone.Core.Notifications.Pushalot
{
public class PushalotResponse
{
public bool Success { get; set; }
public int Status { get; set; }
public string Description { get; set; }
}
}

@ -1,41 +0,0 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Notifications.Pushalot
{
public class PushalotSettingsValidator : AbstractValidator<PushalotSettings>
{
public PushalotSettingsValidator()
{
RuleFor(c => c.AuthToken).NotEmpty();
}
}
public class PushalotSettings : IProviderConfig
{
public PushalotSettings()
{
Image = true;
}
private static readonly PushalotSettingsValidator Validator = new PushalotSettingsValidator();
[FieldDefinition(0, Label = "Authorization Token", HelpLink = "https://pushalot.com/manager/authorizations")]
public string AuthToken { get; set; }
[FieldDefinition(1, Label = "Priority", Type = FieldType.Select, SelectOptions = typeof(PushalotPriority))]
public int Priority { get; set; }
[FieldDefinition(2, Label = "Image", Type = FieldType.Checkbox, HelpText = "Include Lidarr logo with notifications")]
public bool Image { get; set; }
public bool IsValid => !string.IsNullOrWhiteSpace(AuthToken);
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
}
}

@ -188,6 +188,7 @@
<Compile Include="Datastore\Migration\012_add_release_status.cs" />
<Compile Include="Datastore\Migration\015_remove_fanzub.cs" />
<Compile Include="Datastore\Migration\016_update_artist_history_indexes.cs" />
<Compile Include="Datastore\Migration\020_remove_pushalot.cs" />
<Compile Include="Datastore\Migration\017_remove_nma.cs" />
<Compile Include="Datastore\Migration\018_album_disambiguation.cs" />
<Compile Include="Datastore\Migration\019_add_ape_quality_in_profiles.cs" />
@ -795,8 +796,6 @@
<Compile Include="MetadataSource\SkyHook\SkyHookProxy.cs" />
<Compile Include="MetadataSource\SearchArtistComparer.cs" />
<Compile Include="MetadataSource\SkyHook\SkyHookException.cs" />
<Compile Include="Extras\Metadata\Consumers\MediaBrowser\MediaBrowserMetadata.cs" />
<Compile Include="Extras\Metadata\Consumers\MediaBrowser\MediaBrowserMetadataSettings.cs" />
<Compile Include="Extras\Metadata\Consumers\Roksbox\RoksboxMetadata.cs" />
<Compile Include="Extras\Metadata\Consumers\Roksbox\RoksboxMetadataSettings.cs" />
<Compile Include="Extras\Metadata\Consumers\Wdtv\WdtvMetadata.cs" />
@ -1019,11 +1018,6 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Notifications\Prowl\ProwlSettings.cs" />
<Compile Include="Notifications\Pushalot\Pushalot.cs" />
<Compile Include="Notifications\Pushalot\PushalotPriority.cs" />
<Compile Include="Notifications\Pushalot\PushalotProxy.cs" />
<Compile Include="Notifications\Pushalot\PushalotResponse.cs" />
<Compile Include="Notifications\Pushalot\PushalotSettings.cs" />
<Compile Include="Notifications\PushBullet\PushBullet.cs" />
<Compile Include="Notifications\PushBullet\PushBulletProxy.cs" />
<Compile Include="Notifications\PushBullet\PushBulletSettings.cs" />

Loading…
Cancel
Save