2013-06-18 18:54:06 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
using MediaBrowser.Common.Extensions;
|
2013-05-21 03:16:43 +00:00
|
|
|
|
using MediaBrowser.Common.Net;
|
2013-03-04 05:43:06 +00:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2013-02-25 00:13:45 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
2013-03-03 06:58:04 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-06-09 16:47:28 +00:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2013-03-02 17:59:15 +00:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using MediaBrowser.Model.Net;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Xml;
|
2013-06-09 16:47:28 +00:00
|
|
|
|
using MediaBrowser.Providers.Extensions;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-06-09 16:47:28 +00:00
|
|
|
|
namespace MediaBrowser.Providers.TV
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class RemoteEpisodeProvider
|
|
|
|
|
/// </summary>
|
|
|
|
|
class RemoteEpisodeProvider : BaseMetadataProvider
|
|
|
|
|
{
|
2013-05-21 03:16:43 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _provider manager
|
|
|
|
|
/// </summary>
|
2013-03-08 05:08:27 +00:00
|
|
|
|
private readonly IProviderManager _providerManager;
|
2013-05-21 03:16:43 +00:00
|
|
|
|
|
2013-02-25 00:13:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the HTTP client.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The HTTP client.</value>
|
|
|
|
|
protected IHttpClient HttpClient { get; private set; }
|
|
|
|
|
|
2013-03-04 05:43:06 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="RemoteEpisodeProvider" /> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="httpClient">The HTTP client.</param>
|
|
|
|
|
/// <param name="logManager">The log manager.</param>
|
|
|
|
|
/// <param name="configurationManager">The configuration manager.</param>
|
2013-05-21 03:16:43 +00:00
|
|
|
|
/// <param name="providerManager">The provider manager.</param>
|
2013-03-08 05:08:27 +00:00
|
|
|
|
public RemoteEpisodeProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
|
2013-03-04 05:43:06 +00:00
|
|
|
|
: base(logManager, configurationManager)
|
2013-02-25 00:13:45 +00:00
|
|
|
|
{
|
|
|
|
|
HttpClient = httpClient;
|
2013-03-08 05:08:27 +00:00
|
|
|
|
_providerManager = providerManager;
|
2013-02-25 00:13:45 +00:00
|
|
|
|
}
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Supportses the specified item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
|
|
|
|
public override bool Supports(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
return item is Episode;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-25 01:22:21 +00:00
|
|
|
|
public override ItemUpdateType ItemUpdateType
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2013-06-27 23:01:03 +00:00
|
|
|
|
return ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataDownload;
|
2013-06-25 01:22:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the priority.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The priority.</value>
|
|
|
|
|
public override MetadataProviderPriority Priority
|
|
|
|
|
{
|
2013-06-13 18:45:58 +00:00
|
|
|
|
get { return MetadataProviderPriority.Third; }
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether [requires internet].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value><c>true</c> if [requires internet]; otherwise, <c>false</c>.</value>
|
|
|
|
|
public override bool RequiresInternet
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether [refresh on version change].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value><c>true</c> if [refresh on version change]; otherwise, <c>false</c>.</value>
|
|
|
|
|
protected override bool RefreshOnVersionChange
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the provider version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The provider version.</value>
|
|
|
|
|
protected override string ProviderVersion
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return "1";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Needses the refresh internal.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <param name="providerInfo">The provider info.</param>
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
|
|
|
|
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
|
|
|
|
{
|
2013-06-23 15:17:42 +00:00
|
|
|
|
// Don't proceed if there's local metadata
|
|
|
|
|
if (HasLocalMeta(item))
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-28 23:39:17 +00:00
|
|
|
|
return base.NeedsRefreshInternal(item, providerInfo);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-20 14:48:49 +00:00
|
|
|
|
protected override DateTime CompareDate(BaseItem item)
|
2013-05-21 03:16:43 +00:00
|
|
|
|
{
|
|
|
|
|
var episode = (Episode)item;
|
|
|
|
|
|
|
|
|
|
var seriesId = episode.Series != null ? episode.Series.GetProviderId(MetadataProviders.Tvdb) : null;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(seriesId))
|
|
|
|
|
{
|
|
|
|
|
// Process images
|
|
|
|
|
var seriesXmlPath = Path.Combine(RemoteSeriesProvider.GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId), ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower() + ".xml");
|
|
|
|
|
|
|
|
|
|
var seriesXmlFileInfo = new FileInfo(seriesXmlPath);
|
|
|
|
|
|
2013-06-20 14:48:49 +00:00
|
|
|
|
if (seriesXmlFileInfo.Exists)
|
|
|
|
|
{
|
|
|
|
|
return seriesXmlFileInfo.LastWriteTimeUtc;
|
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
}
|
2013-06-20 14:48:49 +00:00
|
|
|
|
|
|
|
|
|
return base.CompareDate(item);
|
2013-05-21 03:16:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
2013-05-21 03:16:43 +00:00
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <returns>Task{System.Boolean}.</returns>
|
2013-03-08 05:08:27 +00:00
|
|
|
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
2013-05-21 03:16:43 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
var episode = (Episode)item;
|
2013-05-21 03:16:43 +00:00
|
|
|
|
|
|
|
|
|
var seriesId = episode.Series != null ? episode.Series.GetProviderId(MetadataProviders.Tvdb) : null;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(seriesId))
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-21 03:16:43 +00:00
|
|
|
|
var seriesXmlPath = Path.Combine(RemoteSeriesProvider.GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId), ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower() + ".xml");
|
|
|
|
|
|
|
|
|
|
var seriesXmlFileInfo = new FileInfo(seriesXmlPath);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
var status = ProviderRefreshStatus.Success;
|
|
|
|
|
|
|
|
|
|
if (seriesXmlFileInfo.Exists)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-21 03:16:43 +00:00
|
|
|
|
var xmlDoc = new XmlDocument();
|
|
|
|
|
xmlDoc.Load(seriesXmlPath);
|
|
|
|
|
|
|
|
|
|
status = await FetchEpisodeData(xmlDoc, episode, seriesId, cancellationToken).ConfigureAwait(false);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
|
|
|
|
|
BaseProviderInfo data;
|
|
|
|
|
if (!item.ProviderData.TryGetValue(Id, out data))
|
|
|
|
|
{
|
|
|
|
|
data = new BaseProviderInfo();
|
|
|
|
|
item.ProviderData[Id] = data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetLastRefreshed(item, DateTime.UtcNow, status);
|
|
|
|
|
return true;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
|
|
|
|
|
Logger.Info("Episode provider not fetching because series does not have a tvdb id: " + item.Path);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches the episode data.
|
|
|
|
|
/// </summary>
|
2013-05-21 03:16:43 +00:00
|
|
|
|
/// <param name="seriesXml">The series XML.</param>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <param name="episode">The episode.</param>
|
|
|
|
|
/// <param name="seriesId">The series id.</param>
|
2013-04-10 15:56:36 +00:00
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <returns>Task{System.Boolean}.</returns>
|
2013-05-21 03:16:43 +00:00
|
|
|
|
private async Task<ProviderRefreshStatus> FetchEpisodeData(XmlDocument seriesXml, Episode episode, string seriesId, CancellationToken cancellationToken)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-12 23:36:42 +00:00
|
|
|
|
var status = ProviderRefreshStatus.Success;
|
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
if (episode.IndexNumber == null)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-12 23:36:42 +00:00
|
|
|
|
return status;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
var seasonNumber = episode.ParentIndexNumber ?? TVUtils.GetSeasonNumberFromEpisodeFile(episode.Path);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
if (seasonNumber == null)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-21 03:16:43 +00:00
|
|
|
|
return status;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
var usingAbsoluteData = false;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
var episodeNode = seriesXml.SelectSingleNode("//Episode[EpisodeNumber='" + episode.IndexNumber.Value + "'][SeasonNumber='" + seasonNumber.Value + "']");
|
2013-05-06 19:31:57 +00:00
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
if (episodeNode == null)
|
|
|
|
|
{
|
|
|
|
|
if (seasonNumber.Value == 1)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-21 03:16:43 +00:00
|
|
|
|
episodeNode = seriesXml.SelectSingleNode("//Episode[absolute_number='" + episode.IndexNumber.Value + "']");
|
|
|
|
|
usingAbsoluteData = true;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
}
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
// If still null, nothing we can do
|
|
|
|
|
if (episodeNode == null)
|
|
|
|
|
{
|
|
|
|
|
return status;
|
|
|
|
|
}
|
2013-06-18 18:54:06 +00:00
|
|
|
|
IEnumerable<XmlDocument> extraEpisodesNode = new XmlDocument[]{};
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-06-18 18:54:06 +00:00
|
|
|
|
if (episode.IndexNumberEnd.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var seriesXDocument = XDocument.Load(new XmlNodeReader(seriesXml));
|
|
|
|
|
if (usingAbsoluteData)
|
|
|
|
|
{
|
|
|
|
|
extraEpisodesNode =
|
|
|
|
|
seriesXDocument.Descendants("Episode")
|
|
|
|
|
.Where(
|
|
|
|
|
x =>
|
|
|
|
|
int.Parse(x.Element("absolute_number").Value) > episode.IndexNumber &&
|
|
|
|
|
int.Parse(x.Element("absolute_number").Value) <= episode.IndexNumberEnd.Value).OrderBy(x => x.Element("absolute_number").Value).Select(x => x.ToXmlDocument());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var all =
|
|
|
|
|
seriesXDocument.Descendants("Episode").Where(x => int.Parse(x.Element("SeasonNumber").Value) == seasonNumber.Value);
|
|
|
|
|
|
|
|
|
|
var xElements = all.Where(x => int.Parse(x.Element("EpisodeNumber").Value) > episode.IndexNumber && int.Parse(x.Element("EpisodeNumber").Value) <= episode.IndexNumberEnd.Value);
|
|
|
|
|
extraEpisodesNode = xElements.OrderBy(x => x.Element("EpisodeNumber").Value).Select(x => x.ToXmlDocument());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
var doc = new XmlDocument();
|
|
|
|
|
doc.LoadXml(episodeNode.OuterXml);
|
2013-05-18 18:16:07 +00:00
|
|
|
|
|
2013-06-19 13:54:45 +00:00
|
|
|
|
if (!episode.HasImage(ImageType.Primary))
|
2013-05-21 03:16:43 +00:00
|
|
|
|
{
|
|
|
|
|
var p = doc.SafeGetString("//filename");
|
|
|
|
|
if (p != null)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-21 03:16:43 +00:00
|
|
|
|
if (!Directory.Exists(episode.MetaLocation)) Directory.CreateDirectory(episode.MetaLocation);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-05-21 03:16:43 +00:00
|
|
|
|
try
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-21 03:16:43 +00:00
|
|
|
|
episode.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(episode, TVUtils.BannerUrl + p, Path.GetFileName(p), ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
catch (HttpException)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-21 03:16:43 +00:00
|
|
|
|
status = ProviderRefreshStatus.CompletedWithErrors;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-15 22:19:47 +00:00
|
|
|
|
if (!episode.LockedFields.Contains(MetadataFields.Overview))
|
|
|
|
|
{
|
2013-06-18 18:54:06 +00:00
|
|
|
|
var extraOverview = extraEpisodesNode.Aggregate("", (current, xmlDocument) => current + ("\r\n\r\n" + xmlDocument.SafeGetString("//Overview")));
|
|
|
|
|
episode.Overview = doc.SafeGetString("//Overview") + extraOverview;
|
2013-06-15 22:19:47 +00:00
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
if (usingAbsoluteData)
|
|
|
|
|
episode.IndexNumber = doc.SafeGetInt32("//absolute_number", -1);
|
|
|
|
|
if (episode.IndexNumber < 0)
|
|
|
|
|
episode.IndexNumber = doc.SafeGetInt32("//EpisodeNumber");
|
2013-06-15 22:19:47 +00:00
|
|
|
|
if (!episode.LockedFields.Contains(MetadataFields.Name))
|
|
|
|
|
{
|
2013-06-18 18:54:06 +00:00
|
|
|
|
var extraNames = extraEpisodesNode.Aggregate("", (current, xmlDocument) => current + (", " + xmlDocument.SafeGetString("//EpisodeName")));
|
|
|
|
|
episode.Name = doc.SafeGetString("//EpisodeName") + extraNames;
|
2013-06-15 22:19:47 +00:00
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
episode.CommunityRating = doc.SafeGetSingle("//Rating", -1, 10);
|
|
|
|
|
var firstAired = doc.SafeGetString("//FirstAired");
|
|
|
|
|
DateTime airDate;
|
|
|
|
|
if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
|
|
|
|
|
{
|
|
|
|
|
episode.PremiereDate = airDate.ToUniversalTime();
|
|
|
|
|
episode.ProductionYear = airDate.Year;
|
|
|
|
|
}
|
2013-06-15 22:19:47 +00:00
|
|
|
|
if (!episode.LockedFields.Contains(MetadataFields.Cast))
|
2013-05-21 03:16:43 +00:00
|
|
|
|
{
|
2013-06-15 22:19:47 +00:00
|
|
|
|
episode.People.Clear();
|
|
|
|
|
|
|
|
|
|
var actors = doc.SafeGetString("//GuestStars");
|
|
|
|
|
if (actors != null)
|
2013-05-21 03:16:43 +00:00
|
|
|
|
{
|
2013-06-15 22:19:47 +00:00
|
|
|
|
// Sometimes tvdb actors have leading spaces
|
|
|
|
|
foreach (var person in actors.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)
|
|
|
|
|
.Where(i => !string.IsNullOrWhiteSpace(i))
|
|
|
|
|
.Select(str => new PersonInfo {Type = PersonType.GuestStar, Name = str.Trim()}))
|
|
|
|
|
{
|
|
|
|
|
episode.AddPerson(person);
|
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
}
|
2013-06-18 18:54:06 +00:00
|
|
|
|
foreach (var xmlDocument in extraEpisodesNode)
|
|
|
|
|
{
|
|
|
|
|
var extraActors = xmlDocument.SafeGetString("//GuestStars");
|
|
|
|
|
if (extraActors == null) continue;
|
|
|
|
|
// Sometimes tvdb actors have leading spaces
|
|
|
|
|
foreach (var person in extraActors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
|
|
|
|
.Where(i => !string.IsNullOrWhiteSpace(i))
|
|
|
|
|
.Select(str => new PersonInfo { Type = PersonType.GuestStar, Name = str.Trim() }).Where(person => !episode.People.Any(x=>x.Type == person.Type && x.Name == person.Name)))
|
|
|
|
|
{
|
|
|
|
|
episode.AddPerson(person);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-06-15 22:19:47 +00:00
|
|
|
|
var directors = doc.SafeGetString("//Director");
|
|
|
|
|
if (directors != null)
|
2013-05-21 03:16:43 +00:00
|
|
|
|
{
|
2013-06-15 22:19:47 +00:00
|
|
|
|
// Sometimes tvdb actors have leading spaces
|
|
|
|
|
foreach (var person in directors.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)
|
|
|
|
|
.Where(i => !string.IsNullOrWhiteSpace(i))
|
|
|
|
|
.Select(str => new PersonInfo {Type = PersonType.Director, Name = str.Trim()}))
|
|
|
|
|
{
|
|
|
|
|
episode.AddPerson(person);
|
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
}
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
|
2013-06-15 22:19:47 +00:00
|
|
|
|
var writers = doc.SafeGetString("//Writer");
|
|
|
|
|
if (writers != null)
|
2013-05-21 03:16:43 +00:00
|
|
|
|
{
|
2013-06-15 22:19:47 +00:00
|
|
|
|
// Sometimes tvdb actors have leading spaces
|
|
|
|
|
foreach (var person in writers.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)
|
|
|
|
|
.Where(i => !string.IsNullOrWhiteSpace(i))
|
|
|
|
|
.Select(str => new PersonInfo {Type = PersonType.Writer, Name = str.Trim()}))
|
|
|
|
|
{
|
|
|
|
|
episode.AddPerson(person);
|
|
|
|
|
}
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
2013-05-21 03:16:43 +00:00
|
|
|
|
}
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-05-12 23:36:42 +00:00
|
|
|
|
return status;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether [has local meta] [the specified episode].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="episode">The episode.</param>
|
|
|
|
|
/// <returns><c>true</c> if [has local meta] [the specified episode]; otherwise, <c>false</c>.</returns>
|
2013-04-28 23:39:17 +00:00
|
|
|
|
private bool HasLocalMeta(BaseItem episode)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
|
|
|
|
return (episode.Parent.ResolveArgs.ContainsMetaFileByName(Path.GetFileNameWithoutExtension(episode.Path) + ".xml"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|