1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

New: Add tags to Kodi metadata

This commit is contained in:
Mark McDowall 2018-09-01 17:29:00 -07:00 committed by Taloth Saldono
parent 400838c79a
commit d52b63e5e9
2 changed files with 20 additions and 0 deletions

View File

@ -13,6 +13,7 @@
using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.MediaInfo; using NzbDrone.Core.MediaFiles.MediaInfo;
using NzbDrone.Core.Tags;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
@ -21,16 +22,19 @@ public class XbmcMetadata : MetadataBase<XbmcMetadataSettings>
{ {
private readonly Logger _logger; private readonly Logger _logger;
private readonly IMapCoversToLocal _mediaCoverService; private readonly IMapCoversToLocal _mediaCoverService;
private readonly ITagService _tagService;
private readonly IDetectXbmcNfo _detectNfo; private readonly IDetectXbmcNfo _detectNfo;
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
public XbmcMetadata(IDetectXbmcNfo detectNfo, public XbmcMetadata(IDetectXbmcNfo detectNfo,
IDiskProvider diskProvider, IDiskProvider diskProvider,
IMapCoversToLocal mediaCoverService, IMapCoversToLocal mediaCoverService,
ITagService tagService,
Logger logger) Logger logger)
{ {
_logger = logger; _logger = logger;
_mediaCoverService = mediaCoverService; _mediaCoverService = mediaCoverService;
_tagService = tagService;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_detectNfo = detectNfo; _detectNfo = detectNfo;
} }
@ -180,6 +184,16 @@ public override MetadataFileResult SeriesMetadata(Series series)
tvShow.Add(new XElement("genre", genre)); tvShow.Add(new XElement("genre", genre));
} }
if (series.Tags.Any())
{
var tags = _tagService.GetTags(series.Tags);
foreach (var tag in tags)
{
tvShow.Add(new XElement("tag", tag.Label));
}
}
if (series.FirstAired.HasValue) if (series.FirstAired.HasValue)
{ {
tvShow.Add(new XElement("premiered", series.FirstAired.Value.ToString("yyyy-MM-dd"))); tvShow.Add(new XElement("premiered", series.FirstAired.Value.ToString("yyyy-MM-dd")));

View File

@ -12,6 +12,7 @@ public interface ITagService
{ {
Tag GetTag(int tagId); Tag GetTag(int tagId);
Tag GetTag(string tag); Tag GetTag(string tag);
List<Tag> GetTags(IEnumerable<int> ids);
TagDetails Details(int tagId); TagDetails Details(int tagId);
List<TagDetails> Details(); List<TagDetails> Details();
List<Tag> All(); List<Tag> All();
@ -61,6 +62,11 @@ public Tag GetTag(string tag)
} }
} }
public List<Tag> GetTags(IEnumerable<int> ids)
{
return _repo.Get(ids).ToList();
}
public TagDetails Details(int tagId) public TagDetails Details(int tagId)
{ {
var tag = GetTag(tagId); var tag = GetTag(tagId);