Remove useless comments
This commit is contained in:
parent
a9302b8b53
commit
ffd6dac03a
|
@ -257,7 +257,7 @@ namespace Emby.Dlna.Main
|
||||||
|
|
||||||
var fullService = "urn:schemas-upnp-org:device:MediaServer:1";
|
var fullService = "urn:schemas-upnp-org:device:MediaServer:1";
|
||||||
|
|
||||||
_logger.LogInformation("Registering publisher for {0} on {1}", fullService, address.ToString());
|
_logger.LogInformation("Registering publisher for {0} on {1}", fullService, address);
|
||||||
|
|
||||||
var descriptorUri = "/dlna/" + udn + "/description.xml";
|
var descriptorUri = "/dlna/" + udn + "/description.xml";
|
||||||
var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);
|
var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);
|
||||||
|
|
|
@ -99,10 +99,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
||||||
item.ResetPeople();
|
item.ResetPeople();
|
||||||
|
|
||||||
using (var fileStream = File.OpenRead(metadataFile))
|
using (var fileStream = File.OpenRead(metadataFile))
|
||||||
{
|
|
||||||
using (var streamReader = new StreamReader(fileStream, encoding))
|
using (var streamReader = new StreamReader(fileStream, encoding))
|
||||||
{
|
|
||||||
// Use XmlReader for best performance
|
|
||||||
using (var reader = XmlReader.Create(streamReader, settings))
|
using (var reader = XmlReader.Create(streamReader, settings))
|
||||||
{
|
{
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
@ -124,8 +121,6 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
|
|
||||||
|
|
|
@ -246,12 +246,10 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||||
|
|
||||||
// <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>cast</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Blender Foundation</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Janus Bager Kristensen</string>\n\t\t</dict>\n\t</array>\n\t<key>directors</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Sacha Goedegebure</string>\n\t\t</dict>\n\t</array>\n\t<key>studio</key>\n\t<string>Blender Foundation</string>\n</dict>\n</plist>\n
|
// <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>cast</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Blender Foundation</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Janus Bager Kristensen</string>\n\t\t</dict>\n\t</array>\n\t<key>directors</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Sacha Goedegebure</string>\n\t\t</dict>\n\t</array>\n\t<key>studio</key>\n\t<string>Blender Foundation</string>\n</dict>\n</plist>\n
|
||||||
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
|
||||||
{
|
|
||||||
using (var streamReader = new StreamReader(stream))
|
using (var streamReader = new StreamReader(stream))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Use XmlReader for best performance
|
|
||||||
using (var reader = XmlReader.Create(streamReader))
|
using (var reader = XmlReader.Create(streamReader))
|
||||||
{
|
{
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
@ -294,7 +292,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ReadFromDictNode(XmlReader reader, MediaInfo info)
|
private void ReadFromDictNode(XmlReader reader, MediaInfo info)
|
||||||
{
|
{
|
||||||
|
|
|
@ -192,6 +192,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
|
||||||
Type = PersonType.Director
|
Type = PersonType.Director
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var person in episode.GuestStars)
|
foreach (var person in episode.GuestStars)
|
||||||
{
|
{
|
||||||
var index = person.IndexOf('(');
|
var index = person.IndexOf('(');
|
||||||
|
@ -212,6 +213,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
|
||||||
Role = role
|
Role = role
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var writer in episode.Writers)
|
foreach (var writer in episode.Writers)
|
||||||
{
|
{
|
||||||
result.AddPerson(new PersonInfo
|
result.AddPerson(new PersonInfo
|
||||||
|
|
|
@ -1,396 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml;
|
|
||||||
using MediaBrowser.Common.Net;
|
|
||||||
using MediaBrowser.Controller.Configuration;
|
|
||||||
using MediaBrowser.Controller.Dto;
|
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
|
||||||
using MediaBrowser.Controller.Library;
|
|
||||||
using MediaBrowser.Model.Entities;
|
|
||||||
using MediaBrowser.Model.IO;
|
|
||||||
using MediaBrowser.Model.Net;
|
|
||||||
using MediaBrowser.Providers.TV.TheTVDB;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.TV
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Class TvdbPrescanTask
|
|
||||||
/// </summary>
|
|
||||||
public class TvdbPrescanTask : ILibraryPostScanTask
|
|
||||||
{
|
|
||||||
public const string TvdbBaseUrl = "https://thetvdb.com/";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The server time URL
|
|
||||||
/// </summary>
|
|
||||||
private const string ServerTimeUrl = TvdbBaseUrl + "api/Updates.php?type=none";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The updates URL
|
|
||||||
/// </summary>
|
|
||||||
private const string UpdatesUrl = TvdbBaseUrl + "api/Updates.php?type=all&time={0}";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The _HTTP client
|
|
||||||
/// </summary>
|
|
||||||
private readonly IHttpClient _httpClient;
|
|
||||||
/// <summary>
|
|
||||||
/// The _logger
|
|
||||||
/// </summary>
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
/// <summary>
|
|
||||||
/// The _config
|
|
||||||
/// </summary>
|
|
||||||
private readonly IServerConfigurationManager _config;
|
|
||||||
private readonly IFileSystem _fileSystem;
|
|
||||||
private readonly ILibraryManager _libraryManager;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="TvdbPrescanTask"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="logger">The logger.</param>
|
|
||||||
/// <param name="httpClient">The HTTP client.</param>
|
|
||||||
/// <param name="config">The config.</param>
|
|
||||||
public TvdbPrescanTask(ILogger logger, IHttpClient httpClient, IServerConfigurationManager config, IFileSystem fileSystem, ILibraryManager libraryManager)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_httpClient = httpClient;
|
|
||||||
_config = config;
|
|
||||||
_fileSystem = fileSystem;
|
|
||||||
_libraryManager = libraryManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Runs the specified progress.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="progress">The progress.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var path = TvdbSeriesProvider.GetSeriesDataPath(_config.CommonApplicationPaths);
|
|
||||||
|
|
||||||
Directory.CreateDirectory(path);
|
|
||||||
|
|
||||||
var timestampFile = Path.Combine(path, "time.txt");
|
|
||||||
|
|
||||||
var timestampFileInfo = _fileSystem.GetFileInfo(timestampFile);
|
|
||||||
|
|
||||||
// Don't check for tvdb updates anymore frequently than 24 hours
|
|
||||||
if (timestampFileInfo.Exists && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(timestampFileInfo)).TotalDays < 1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find out the last time we queried tvdb for updates
|
|
||||||
var lastUpdateTime = timestampFileInfo.Exists ? File.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty;
|
|
||||||
|
|
||||||
string newUpdateTime;
|
|
||||||
|
|
||||||
var existingDirectories = _fileSystem.GetDirectoryPaths(path)
|
|
||||||
.Select(Path.GetFileName)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var seriesList = _libraryManager.GetItemList(new InternalItemsQuery()
|
|
||||||
{
|
|
||||||
IncludeItemTypes = new[] { typeof(Series).Name },
|
|
||||||
Recursive = true,
|
|
||||||
GroupByPresentationUniqueKey = false,
|
|
||||||
DtoOptions = new DtoOptions(false)
|
|
||||||
{
|
|
||||||
EnableImages = false
|
|
||||||
}
|
|
||||||
|
|
||||||
}).Cast<Series>()
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var seriesIdsInLibrary = seriesList
|
|
||||||
.Where(i => !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tvdb)))
|
|
||||||
.Select(i => i.GetProviderId(MetadataProviders.Tvdb))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var missingSeries = seriesIdsInLibrary.Except(existingDirectories, StringComparer.OrdinalIgnoreCase)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var enableInternetProviders = seriesList.Count == 0 ? false : seriesList[0].IsMetadataFetcherEnabled(_libraryManager.GetLibraryOptions(seriesList[0]), TvdbSeriesProvider.Current.Name);
|
|
||||||
if (!enableInternetProviders)
|
|
||||||
{
|
|
||||||
progress.Report(100);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this is our first time, update all series
|
|
||||||
if (string.IsNullOrEmpty(lastUpdateTime))
|
|
||||||
{
|
|
||||||
// First get tvdb server time
|
|
||||||
using (var response = await _httpClient.SendAsync(new HttpRequestOptions
|
|
||||||
{
|
|
||||||
Url = ServerTimeUrl,
|
|
||||||
CancellationToken = cancellationToken,
|
|
||||||
EnableHttpCompression = true,
|
|
||||||
BufferContent = false
|
|
||||||
|
|
||||||
}, "GET").ConfigureAwait(false))
|
|
||||||
{
|
|
||||||
// First get tvdb server time
|
|
||||||
using (var stream = response.Content)
|
|
||||||
{
|
|
||||||
newUpdateTime = GetUpdateTime(stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
existingDirectories.AddRange(missingSeries);
|
|
||||||
|
|
||||||
await UpdateSeries(existingDirectories, path, null, progress, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var seriesToUpdate = await GetSeriesIdsToUpdate(existingDirectories, lastUpdateTime, cancellationToken).ConfigureAwait(false);
|
|
||||||
|
|
||||||
newUpdateTime = seriesToUpdate.Item2;
|
|
||||||
|
|
||||||
long.TryParse(lastUpdateTime, NumberStyles.Any, UsCulture, out var lastUpdateValue);
|
|
||||||
|
|
||||||
var nullableUpdateValue = lastUpdateValue == 0 ? (long?)null : lastUpdateValue;
|
|
||||||
|
|
||||||
var listToUpdate = seriesToUpdate.Item1.ToList();
|
|
||||||
listToUpdate.AddRange(missingSeries);
|
|
||||||
|
|
||||||
await UpdateSeries(listToUpdate, path, nullableUpdateValue, progress, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
File.WriteAllText(timestampFile, newUpdateTime, Encoding.UTF8);
|
|
||||||
progress.Report(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the update time.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="response">The response.</param>
|
|
||||||
/// <returns>System.String.</returns>
|
|
||||||
private string GetUpdateTime(Stream response)
|
|
||||||
{
|
|
||||||
// Use XmlReader for best performance
|
|
||||||
var settings = new XmlReaderSettings()
|
|
||||||
{
|
|
||||||
ValidationType = ValidationType.None,
|
|
||||||
CheckCharacters = false,
|
|
||||||
IgnoreProcessingInstructions = true,
|
|
||||||
IgnoreComments = true
|
|
||||||
};
|
|
||||||
|
|
||||||
using (var streamReader = new StreamReader(response, Encoding.UTF8))
|
|
||||||
using (var reader = XmlReader.Create(streamReader, settings))
|
|
||||||
{
|
|
||||||
reader.MoveToContent();
|
|
||||||
reader.Read();
|
|
||||||
|
|
||||||
// Loop through each element
|
|
||||||
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
|
|
||||||
{
|
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
|
||||||
{
|
|
||||||
switch (reader.Name)
|
|
||||||
{
|
|
||||||
case "Time":
|
|
||||||
{
|
|
||||||
return (reader.ReadElementContentAsString() ?? string.Empty).Trim();
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
reader.Skip();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader.Read();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the series ids to update.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="existingSeriesIds">The existing series ids.</param>
|
|
||||||
/// <param name="lastUpdateTime">The last update time.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task{IEnumerable{System.String}}.</returns>
|
|
||||||
private async Task<Tuple<IEnumerable<string>, string>> GetSeriesIdsToUpdate(IEnumerable<string> existingSeriesIds, string lastUpdateTime, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
// First get last time
|
|
||||||
using (var response = await _httpClient.SendAsync(new HttpRequestOptions
|
|
||||||
{
|
|
||||||
Url = string.Format(UpdatesUrl, lastUpdateTime),
|
|
||||||
CancellationToken = cancellationToken,
|
|
||||||
EnableHttpCompression = true,
|
|
||||||
BufferContent = false
|
|
||||||
|
|
||||||
}, "GET").ConfigureAwait(false))
|
|
||||||
{
|
|
||||||
using (var stream = response.Content)
|
|
||||||
{
|
|
||||||
var data = GetUpdatedSeriesIdList(stream);
|
|
||||||
|
|
||||||
var existingDictionary = existingSeriesIds.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
var seriesList = data.ids
|
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i) && existingDictionary.ContainsKey(i));
|
|
||||||
|
|
||||||
return new Tuple<IEnumerable<string>, string>(seriesList, data.updateTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private (List<string> ids, string updateTime) GetUpdatedSeriesIdList(Stream stream)
|
|
||||||
{
|
|
||||||
string updateTime = null;
|
|
||||||
var idList = new List<string>();
|
|
||||||
|
|
||||||
// Use XmlReader for best performance
|
|
||||||
var settings = new XmlReaderSettings()
|
|
||||||
{
|
|
||||||
ValidationType = ValidationType.None,
|
|
||||||
CheckCharacters = false,
|
|
||||||
IgnoreProcessingInstructions = true,
|
|
||||||
IgnoreComments = true
|
|
||||||
};
|
|
||||||
|
|
||||||
using (var streamReader = new StreamReader(stream, Encoding.UTF8))
|
|
||||||
using (var reader = XmlReader.Create(streamReader, settings))
|
|
||||||
{
|
|
||||||
reader.MoveToContent();
|
|
||||||
reader.Read();
|
|
||||||
|
|
||||||
// Loop through each element
|
|
||||||
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
|
|
||||||
{
|
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
|
||||||
{
|
|
||||||
switch (reader.Name)
|
|
||||||
{
|
|
||||||
case "Time":
|
|
||||||
{
|
|
||||||
updateTime = (reader.ReadElementContentAsString() ?? string.Empty).Trim();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Series":
|
|
||||||
{
|
|
||||||
var id = (reader.ReadElementContentAsString() ?? string.Empty).Trim();
|
|
||||||
idList.Add(id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
reader.Skip();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader.Read();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (idList, updateTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the series.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="seriesIds">The series ids.</param>
|
|
||||||
/// <param name="seriesDataPath">The series data path.</param>
|
|
||||||
/// <param name="lastTvDbUpdateTime">The last tv db update time.</param>
|
|
||||||
/// <param name="progress">The progress.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
private async Task UpdateSeries(List<string> seriesIds, string seriesDataPath, long? lastTvDbUpdateTime, IProgress<double> progress, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var numComplete = 0;
|
|
||||||
|
|
||||||
var seriesList = _libraryManager.GetItemList(new InternalItemsQuery()
|
|
||||||
{
|
|
||||||
IncludeItemTypes = new[] { typeof(Series).Name },
|
|
||||||
Recursive = true,
|
|
||||||
GroupByPresentationUniqueKey = false,
|
|
||||||
DtoOptions = new DtoOptions(false)
|
|
||||||
{
|
|
||||||
EnableImages = false
|
|
||||||
}
|
|
||||||
|
|
||||||
}).Cast<Series>();
|
|
||||||
|
|
||||||
// Gather all series into a lookup by tvdb id
|
|
||||||
var allSeries = seriesList
|
|
||||||
.Where(i => !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tvdb)))
|
|
||||||
.ToLookup(i => i.GetProviderId(MetadataProviders.Tvdb));
|
|
||||||
|
|
||||||
foreach (var seriesId in seriesIds)
|
|
||||||
{
|
|
||||||
// Find the preferred language(s) for the movie in the library
|
|
||||||
var languages = allSeries[seriesId]
|
|
||||||
.Select(i => i.GetPreferredMetadataLanguage())
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var language in languages)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await UpdateSeries(seriesId, seriesDataPath, lastTvDbUpdateTime, language, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (HttpException ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Error updating tvdb series id {ID}, language {Language}", seriesId, language);
|
|
||||||
|
|
||||||
// Already logged at lower levels, but don't fail the whole operation, unless timed out
|
|
||||||
// We have to fail this to make it run again otherwise new episode data could potentially be missing
|
|
||||||
if (ex.IsTimedOut)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
numComplete++;
|
|
||||||
double percent = numComplete;
|
|
||||||
percent /= seriesIds.Count;
|
|
||||||
percent *= 100;
|
|
||||||
|
|
||||||
progress.Report(percent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the series.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">The id.</param>
|
|
||||||
/// <param name="seriesDataPath">The series data path.</param>
|
|
||||||
/// <param name="lastTvDbUpdateTime">The last tv db update time.</param>
|
|
||||||
/// <param name="preferredMetadataLanguage">The preferred metadata language.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
private Task UpdateSeries(string id, string seriesDataPath, long? lastTvDbUpdateTime, string preferredMetadataLanguage, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Updating series from tvdb " + id + ", language " + preferredMetadataLanguage);
|
|
||||||
|
|
||||||
seriesDataPath = Path.Combine(seriesDataPath, id);
|
|
||||||
|
|
||||||
Directory.CreateDirectory(seriesDataPath);
|
|
||||||
|
|
||||||
return TvdbSeriesProvider.Current.DownloadSeriesZip(id, MetadataProviders.Tvdb.ToString(), null, null, seriesDataPath, lastTvDbUpdateTime, preferredMetadataLanguage, cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -145,6 +145,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
|
||||||
|
|
||||||
private async Task<string> GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken)
|
private async Task<string> GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
|
||||||
TvDbResponse<SeriesSearchResult[]> result = null;
|
TvDbResponse<SeriesSearchResult[]> result = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -333,7 +334,6 @@ namespace MediaBrowser.Providers.TV.TheTVDB
|
||||||
result.ResultLanguage = metadataLanguage;
|
result.ResultLanguage = metadataLanguage;
|
||||||
series.AirDays = TVUtils.GetAirDays(tvdbSeries.AirsDayOfWeek);
|
series.AirDays = TVUtils.GetAirDays(tvdbSeries.AirsDayOfWeek);
|
||||||
series.AirTime = tvdbSeries.AirsTime;
|
series.AirTime = tvdbSeries.AirsTime;
|
||||||
|
|
||||||
series.CommunityRating = (float?)tvdbSeries.SiteRating;
|
series.CommunityRating = (float?)tvdbSeries.SiteRating;
|
||||||
series.SetProviderId(MetadataProviders.Imdb, tvdbSeries.ImdbId);
|
series.SetProviderId(MetadataProviders.Imdb, tvdbSeries.ImdbId);
|
||||||
series.SetProviderId(MetadataProviders.Zap2It, tvdbSeries.Zap2itId);
|
series.SetProviderId(MetadataProviders.Zap2It, tvdbSeries.Zap2itId);
|
||||||
|
|
|
@ -62,14 +62,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
throw new ArgumentException("The metadata file was empty or null.", nameof(metadataFile));
|
throw new ArgumentException("The metadata file was empty or null.", nameof(metadataFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
var settings = new XmlReaderSettings()
|
|
||||||
{
|
|
||||||
ValidationType = ValidationType.None,
|
|
||||||
CheckCharacters = false,
|
|
||||||
IgnoreProcessingInstructions = true,
|
|
||||||
IgnoreComments = true
|
|
||||||
};
|
|
||||||
|
|
||||||
_validProviderIds = _validProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
_validProviderIds = _validProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
var idInfos = ProviderManager.GetExternalIdInfos(item.Item);
|
var idInfos = ProviderManager.GetExternalIdInfos(item.Item);
|
||||||
|
@ -88,7 +80,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
_validProviderIds.Add("tmdbcolid", "TmdbCollection");
|
_validProviderIds.Add("tmdbcolid", "TmdbCollection");
|
||||||
_validProviderIds.Add("imdb_id", "Imdb");
|
_validProviderIds.Add("imdb_id", "Imdb");
|
||||||
|
|
||||||
Fetch(item, metadataFile, settings, cancellationToken);
|
Fetch(item, metadataFile, GetXmlReaderSettings(), cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool SupportsUrlAfterClosingXmlTag => false;
|
protected virtual bool SupportsUrlAfterClosingXmlTag => false;
|
||||||
|
@ -105,10 +97,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
if (!SupportsUrlAfterClosingXmlTag)
|
if (!SupportsUrlAfterClosingXmlTag)
|
||||||
{
|
{
|
||||||
using (var fileStream = File.OpenRead(metadataFile))
|
using (var fileStream = File.OpenRead(metadataFile))
|
||||||
{
|
|
||||||
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
||||||
{
|
|
||||||
// Use XmlReader for best performance
|
|
||||||
using (var reader = XmlReader.Create(streamReader, settings))
|
using (var reader = XmlReader.Create(streamReader, settings))
|
||||||
{
|
{
|
||||||
item.ResetPeople();
|
item.ResetPeople();
|
||||||
|
@ -131,13 +120,10 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var fileStream = File.OpenRead(metadataFile))
|
using (var fileStream = File.OpenRead(metadataFile))
|
||||||
{
|
|
||||||
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
item.ResetPeople();
|
item.ResetPeople();
|
||||||
|
@ -184,8 +170,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var stringReader = new StringReader(xml))
|
using (var stringReader = new StringReader(xml))
|
||||||
{
|
|
||||||
// Use XmlReader for best performance
|
|
||||||
using (var reader = XmlReader.Create(stringReader, settings))
|
using (var reader = XmlReader.Create(stringReader, settings))
|
||||||
{
|
{
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
@ -207,14 +191,12 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (XmlException)
|
catch (XmlException)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual string MovieDbParserSearchString => "themoviedb.org/movie/";
|
protected virtual string MovieDbParserSearchString => "themoviedb.org/movie/";
|
||||||
|
|
||||||
|
@ -916,6 +898,15 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal XmlReaderSettings GetXmlReaderSettings()
|
||||||
|
=> new XmlReaderSettings()
|
||||||
|
{
|
||||||
|
ValidationType = ValidationType.None,
|
||||||
|
CheckCharacters = false,
|
||||||
|
IgnoreProcessingInstructions = true,
|
||||||
|
IgnoreComments = true
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to split names of comma or pipe delimeted genres and people
|
/// Used to split names of comma or pipe delimeted genres and people
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -27,7 +27,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
protected override void Fetch(MetadataResult<Episode> item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken)
|
protected override void Fetch(MetadataResult<Episode> item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
using (var fileStream = File.OpenRead(metadataFile))
|
using (var fileStream = File.OpenRead(metadataFile))
|
||||||
{
|
|
||||||
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
item.ResetPeople();
|
item.ResetPeople();
|
||||||
|
@ -46,8 +45,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var stringReader = new StringReader(xml))
|
using (var stringReader = new StringReader(xml))
|
||||||
{
|
|
||||||
// Use XmlReader for best performance
|
|
||||||
using (var reader = XmlReader.Create(stringReader, settings))
|
using (var reader = XmlReader.Create(stringReader, settings))
|
||||||
{
|
{
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
@ -69,14 +66,12 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (XmlException)
|
catch (XmlException)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches the data from XML node.
|
/// Fetches the data from XML node.
|
||||||
|
|
|
@ -122,18 +122,9 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
using (var stringReader = new StringReader("<set>" + xml + "</set>"))
|
using (var stringReader = new StringReader("<set>" + xml + "</set>"))
|
||||||
{
|
{
|
||||||
// These are not going to be valid xml so no sense in causing the provider to fail and spamming the log with exceptions
|
// These are not going to be valid xml so no sense in causing the provider to fail and spamming the log with exceptions
|
||||||
var settings = new XmlReaderSettings()
|
|
||||||
{
|
|
||||||
ValidationType = ValidationType.None,
|
|
||||||
CheckCharacters = false,
|
|
||||||
IgnoreProcessingInstructions = true,
|
|
||||||
IgnoreComments = true
|
|
||||||
};
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Use XmlReader for best performance
|
using (var reader = XmlReader.Create(stringReader, GetXmlReaderSettings()))
|
||||||
using (var reader = XmlReader.Create(stringReader, settings))
|
|
||||||
{
|
{
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
reader.Read();
|
reader.Read();
|
||||||
|
|
|
@ -964,7 +964,6 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
||||||
|
|
||||||
private void AddCustomTags(string path, List<string> xmlTagsUsed, XmlWriter writer, ILogger logger, IFileSystem fileSystem)
|
private void AddCustomTags(string path, List<string> xmlTagsUsed, XmlWriter writer, ILogger logger, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
// Use XmlReader for best performance
|
|
||||||
var settings = new XmlReaderSettings()
|
var settings = new XmlReaderSettings()
|
||||||
{
|
{
|
||||||
ValidationType = ValidationType.None,
|
ValidationType = ValidationType.None,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user