@ -137,87 +137,97 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
public override MetadataFileResult SeriesMetadata ( Series series )
{
if ( ! Settings . SeriesMetadata )
{
return null ;
}
_logger . Debug ( "Generating tvshow.nfo for: {0}" , series . Title ) ;
var sb = new StringBuilder ( ) ;
var xws = new XmlWriterSettings ( ) ;
xws . OmitXmlDeclaration = true ;
xws . Indent = false ;
var xmlResult = string . Empty ;
using ( var xw = XmlWriter . Create ( sb , xws ) )
if ( Settings . SeriesMetadata )
{
var tvShow = new XElement ( "tvshow" ) ;
tvShow . Add ( new XElement ( "title" , series . Title ) ) ;
_logger . Debug ( "Generating Series Metadata for: {0}" , series . Title ) ;
var sb = new StringBuilder ( ) ;
var xws = new XmlWriterSettings ( ) ;
xws . OmitXmlDeclaration = true ;
xws . Indent = false ;
if ( series . Ratings ! = null & & series . Ratings . Votes > 0 )
using ( var xw = XmlWriter . Create ( sb , xws ) )
{
tvShow . Add ( new XElement ( "rating" , series . Ratings . Value ) ) ;
}
var tvShow = new XElement ( "tvshow" ) ;
tvShow . Add ( new XElement ( "plot" , series . Overview ) ) ;
tvShow . Add ( new XElement ( "mpaa" , series . Certification ) ) ;
tvShow . Add ( new XElement ( "id" , series . TvdbId ) ) ;
tvShow . Add ( new XElement ( "title" , series . Title ) ) ;
var uniqueId = new XElement ( "uniqueid" , series . TvdbId ) ;
uniqueId . SetAttributeValue ( "type" , "tvdb" ) ;
uniqueId . SetAttributeValue ( "default" , true ) ;
tvShow . Add ( uniqueId ) ;
if ( series . Ratings ! = null & & series . Ratings . Votes > 0 )
{
tvShow . Add ( new XElement ( "rating" , series . Ratings . Value ) ) ;
}
if ( series . ImdbId . IsNotNullOrWhiteSpace ( ) )
{
var imdbId = new XElement ( "uniqueid" , series . ImdbId ) ;
imdbId . SetAttributeValue ( "type" , "imdb" ) ;
tvShow . Add ( imdbId ) ;
}
tvShow . Add ( new XElement ( "plot" , series . Overview ) ) ;
tvShow . Add ( new XElement ( "mpaa" , series . Certification ) ) ;
tvShow . Add ( new XElement ( "id" , series . TvdbId ) ) ;
foreach ( var genre in series . Genres )
{
tvShow. Add ( new XElement ( "genre" , genre ) ) ;
}
var uniqueId = new XElement ( "uniqueid" , series . TvdbId ) ;
uniqueId . SetAttributeValue ( "type" , "tvdb" ) ;
uniqueId. SetAttributeValue ( "default" , true ) ;
tvShow . Add ( uniqueId ) ;
if ( series . Tags . Any ( ) )
{
var tags = _tagService . GetTags ( series . Tags ) ;
if ( series . ImdbId . IsNotNullOrWhiteSpace ( ) )
{
var imdbId = new XElement ( "uniqueid" , series . ImdbId ) ;
imdbId . SetAttributeValue ( "type" , "imdb" ) ;
tvShow . Add ( imdbId ) ;
}
foreach ( var tag in tags )
foreach ( var genre in series . Genre s)
{
tvShow . Add ( new XElement ( " tag", tag . Label ) ) ;
tvShow . Add ( new XElement ( " genre", genre ) ) ;
}
}
if ( series . FirstAired . HasValue )
{
tvShow . Add ( new XElement ( "premiered" , series . FirstAired . Value . ToString ( "yyyy-MM-dd" ) ) ) ;
}
if ( series . Tags . Any ( ) )
{
var tags = _tagService . GetTags ( series . Tags ) ;
tvShow . Add ( new XElement ( "studio" , series . Network ) ) ;
foreach ( var tag in tags )
{
tvShow . Add ( new XElement ( "tag" , tag . Label ) ) ;
}
}
foreach ( var actor in series . Actors )
{
var xmlActor = new XElement ( "actor" ,
new XElement ( "name" , actor . Name ) ,
new XElement ( "role" , actor . Character ) ) ;
if ( series . FirstAired . HasValue )
{
tvShow . Add ( new XElement ( "premiered" , series . FirstAired . Value . ToString ( "yyyy-MM-dd" ) ) ) ;
}
tvShow . Add ( new XElement ( "studio" , series . Network ) ) ;
if ( actor . Images . Any ( ) )
foreach ( var actor in series . Actors )
{
xmlActor . Add ( new XElement ( "thumb" , actor . Images . First ( ) . Url ) ) ;
var xmlActor = new XElement ( "actor" ,
new XElement ( "name" , actor . Name ) ,
new XElement ( "role" , actor . Character ) ) ;
if ( actor . Images . Any ( ) )
{
xmlActor . Add ( new XElement ( "thumb" , actor . Images . First ( ) . Url ) ) ;
}
tvShow . Add ( xmlActor ) ;
}
tvShow . Add ( xmlActor ) ;
}
var doc = new XDocument ( tvShow ) ;
doc . Save ( xw ) ;
var doc = new XDocument ( tvShow ) ;
doc . Save ( xw ) ;
xmlResult + = doc . ToString ( ) ;
}
}
_logger . Debug ( "Saving tvshow.nfo for {0}" , series . Title ) ;
if ( Settings . SeriesMetadataUrl )
{
if ( Settings . SeriesMetadata )
{
xmlResult + = Environment . NewLine ;
}
return new MetadataFileResult ( "tvshow.nfo" , doc . ToString ( ) ) ;
xmlResult + = "https://www.thetvdb.com/?tab=series&id=" + series . TvdbId ;
}
return xmlResult = = string . Empty ? null : new MetadataFileResult ( "tvshow.nfo" , xmlResult ) ;
}
public override MetadataFileResult EpisodeMetadata ( Series series , EpisodeFile episodeFile )