parent
6740257135
commit
890f107467
|
@ -0,0 +1,77 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Extras.Metadata.Files;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Extras.Metadata.Consumers.Plex
|
||||
{
|
||||
public class PlexMetadata : MetadataBase<PlexMetadataSettings>
|
||||
{
|
||||
public override string Name => "Plex";
|
||||
|
||||
public override MetadataFile FindMetadataFile(Series series, string path)
|
||||
{
|
||||
var filename = Path.GetFileName(path);
|
||||
|
||||
if (filename == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var relativePath = series.Path.GetRelativePath(path);
|
||||
|
||||
if (relativePath == ".plexmatch")
|
||||
{
|
||||
return new MetadataFile
|
||||
{
|
||||
SeriesId = series.Id,
|
||||
Consumer = GetType().Name,
|
||||
RelativePath = series.Path.GetRelativePath(path),
|
||||
Type = MetadataType.SeriesMetadata
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override MetadataFileResult SeriesMetadata(Series series)
|
||||
{
|
||||
if (!Settings.SeriesPlexMatchFile)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var content = new StringBuilder();
|
||||
|
||||
content.AppendLine($"Title: {series.Title}");
|
||||
content.AppendLine($"Year: {series.Year}");
|
||||
content.AppendLine($"TvdbId: {series.TvdbId}");
|
||||
content.AppendLine($"ImdbId: {series.ImdbId}");
|
||||
|
||||
return new MetadataFileResult(".plexmatch", content.ToString());
|
||||
}
|
||||
|
||||
public override MetadataFileResult EpisodeMetadata(Series series, EpisodeFile episodeFile)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public override List<ImageFileResult> SeriesImages(Series series)
|
||||
{
|
||||
return new List<ImageFileResult>();
|
||||
}
|
||||
|
||||
public override List<ImageFileResult> SeasonImages(Series series, Season season)
|
||||
{
|
||||
return new List<ImageFileResult>();
|
||||
}
|
||||
|
||||
public override List<ImageFileResult> EpisodeImages(Series series, EpisodeFile episodeFile)
|
||||
{
|
||||
return new List<ImageFileResult>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using FluentValidation;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Extras.Metadata.Consumers.Plex
|
||||
{
|
||||
public class PlexMetadataSettingsValidator : AbstractValidator<PlexMetadataSettings>
|
||||
{
|
||||
public PlexMetadataSettingsValidator()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class PlexMetadataSettings : IProviderConfig
|
||||
{
|
||||
private static readonly PlexMetadataSettingsValidator Validator = new PlexMetadataSettingsValidator();
|
||||
|
||||
public PlexMetadataSettings()
|
||||
{
|
||||
SeriesPlexMatchFile = true;
|
||||
}
|
||||
|
||||
[FieldDefinition(0, Label = "Series Plex Match File", Type = FieldType.Checkbox, Section = MetadataSectionType.Metadata, HelpText = "Creates a .plexmatch file in the series folder")]
|
||||
public bool SeriesPlexMatchFile { get; set; }
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue