fix directory not found error in episode organization

This commit is contained in:
Luke Pulverenti 2014-02-25 10:40:16 -05:00
parent 7497fe9554
commit aef805efb9
23 changed files with 143 additions and 73 deletions

View File

@ -285,17 +285,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
EnsureSuccessStatusCode(httpResponse); EnsureSuccessStatusCode(httpResponse);
options.CancellationToken.ThrowIfCancellationRequested(); options.CancellationToken.ThrowIfCancellationRequested();
return new HttpResponseInfo
{
Content = httpResponse.GetResponseStream(),
StatusCode = httpResponse.StatusCode, return GetResponseInfo(httpResponse, httpResponse.GetResponseStream(), GetContentLength(httpResponse));
ContentType = httpResponse.ContentType,
Headers = httpResponse.Headers
};
} }
using (var response = await httpWebRequest.GetResponseAsync().ConfigureAwait(false)) using (var response = await httpWebRequest.GetResponseAsync().ConfigureAwait(false))
@ -314,16 +305,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
memoryStream.Position = 0; memoryStream.Position = 0;
return new HttpResponseInfo return GetResponseInfo(httpResponse, memoryStream, memoryStream.Length);
{
Content = memoryStream,
StatusCode = httpResponse.StatusCode,
ContentType = httpResponse.ContentType,
Headers = httpResponse.Headers
};
} }
} }
} }
@ -367,6 +349,38 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
} }
} }
private HttpResponseInfo GetResponseInfo(HttpWebResponse httpResponse, Stream content, long? contentLength)
{
return new HttpResponseInfo
{
Content = content,
StatusCode = httpResponse.StatusCode,
ContentType = httpResponse.ContentType,
Headers = httpResponse.Headers,
ContentLength = contentLength
};
}
private HttpResponseInfo GetResponseInfo(HttpWebResponse httpResponse, string tempFile, long? contentLength)
{
return new HttpResponseInfo
{
TempFilePath = tempFile,
StatusCode = httpResponse.StatusCode,
ContentType = httpResponse.ContentType,
Headers = httpResponse.Headers,
ContentLength = contentLength
};
}
public Task<HttpResponseInfo> Post(HttpRequestOptions options) public Task<HttpResponseInfo> Post(HttpRequestOptions options)
{ {
return SendAsync(options, "POST"); return SendAsync(options, "POST");
@ -493,16 +507,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
options.Progress.Report(100); options.Progress.Report(100);
return new HttpResponseInfo return GetResponseInfo(httpResponse, tempFile, contentLength);
{
TempFilePath = tempFile,
StatusCode = httpResponse.StatusCode,
ContentType = httpResponse.ContentType,
Headers = httpResponse.Headers
};
} }
} }
catch (OperationCanceledException ex) catch (OperationCanceledException ex)

View File

@ -33,6 +33,12 @@ namespace MediaBrowser.Common.Net
/// <value>The temp file path.</value> /// <value>The temp file path.</value>
public string TempFilePath { get; set; } public string TempFilePath { get; set; }
/// <summary>
/// Gets or sets the length of the content.
/// </summary>
/// <value>The length of the content.</value>
public long? ContentLength { get; set; }
/// <summary> /// <summary>
/// Gets or sets the headers. /// Gets or sets the headers.
/// </summary> /// </summary>

View File

@ -940,7 +940,7 @@ namespace MediaBrowser.Controller.Entities
// First get using the cached Id // First get using the cached Id
if (info.ItemId != Guid.Empty) if (info.ItemId != Guid.Empty)
{ {
item = LibraryManager.GetItemById(info.ItemId) as BaseItem; item = LibraryManager.GetItemById(info.ItemId);
} }
// If still null, search by path // If still null, search by path
@ -1098,7 +1098,9 @@ namespace MediaBrowser.Controller.Entities
return this; return this;
} }
return RecursiveChildren.FirstOrDefault(i => string.Equals(i.Path, path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase)); return RecursiveChildren.FirstOrDefault(i => string.Equals(i.Path, path, StringComparison.OrdinalIgnoreCase) ||
(!i.IsFolder && !i.IsInMixedFolder && string.Equals(i.ContainingFolderPath, path, StringComparison.OrdinalIgnoreCase)) ||
i.PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase));
} }
public override bool IsPlayed(User user) public override bool IsPlayed(User user)

View File

@ -250,7 +250,16 @@ namespace MediaBrowser.Controller.Entities.TV
/// <returns>SeasonInfo.</returns> /// <returns>SeasonInfo.</returns>
public SeasonInfo GetLookupInfo() public SeasonInfo GetLookupInfo()
{ {
return GetItemLookupInfo<SeasonInfo>(); var id = GetItemLookupInfo<SeasonInfo>();
var series = Series;
if (series != null)
{
id.SeriesProviderIds = series.ProviderIds;
}
return id;
} }
/// <summary> /// <summary>

View File

@ -683,6 +683,22 @@ namespace MediaBrowser.Controller.Providers
} }
break; break;
} }
case "MusicbrainzId":
{
var mbz = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(mbz))
{
if (item is MusicAlbum)
{
item.SetProviderId(MetadataProviders.MusicBrainzAlbum, mbz);
}
else if (item is MusicArtist)
{
item.SetProviderId(MetadataProviders.MusicBrainzArtist, mbz);
}
}
break;
}
case "MusicBrainzAlbumId": case "MusicBrainzAlbumId":
{ {
var mbz = reader.ReadElementContentAsString(); var mbz = reader.ReadElementContentAsString();

View File

@ -152,6 +152,11 @@ namespace MediaBrowser.Controller.Providers
public class SeasonInfo : ItemLookupInfo public class SeasonInfo : ItemLookupInfo
{ {
public Dictionary<string, string> SeriesProviderIds { get; set; }
public SeasonInfo()
{
SeriesProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
} }
} }

View File

@ -172,7 +172,7 @@ namespace MediaBrowser.Providers.All
AddImage(files, images, imagePrefix + "movie", ImageType.Primary); AddImage(files, images, imagePrefix + "movie", ImageType.Primary);
} }
if (string.IsNullOrEmpty(item.Path)) if (!string.IsNullOrEmpty(item.Path))
{ {
var name = Path.GetFileNameWithoutExtension(item.Path); var name = Path.GetFileNameWithoutExtension(item.Path);

View File

@ -60,8 +60,8 @@ namespace MediaBrowser.Providers.Manager
var providerIds = new List<Guid>(); var providerIds = new List<Guid>();
// In order to avoid duplicates, only download these if there are none already // In order to avoid duplicates, only download these if there are none already
var backdropLimit = item.HasImage(ImageType.Backdrop) ? 0 : savedOptions.GetLimit(ImageType.Backdrop); var backdropLimit = savedOptions.GetLimit(ImageType.Backdrop);
var screenshotLimit = item.HasImage(ImageType.Screenshot) ? 0 : savedOptions.GetLimit(ImageType.Screenshot); var screenshotLimit = savedOptions.GetLimit(ImageType.Screenshot);
foreach (var provider in providers) foreach (var provider in providers)
{ {
@ -362,9 +362,25 @@ namespace MediaBrowser.Providers.Manager
{ {
var response = await provider.GetImageResponse(url, cancellationToken).ConfigureAwait(false); var response = await provider.GetImageResponse(url, cancellationToken).ConfigureAwait(false);
// If there's already an image of the same size, skip it
if (response.ContentLength.HasValue)
{
try
{
if (item.GetImages(imageType).Any(i => new FileInfo(i.Path).Length == response.ContentLength.Value))
{
response.Content.Dispose();
continue;
}
}
catch (IOException ex)
{
_logger.ErrorException("Error examining images", ex);
}
}
await _providerManager.SaveImage(item, response.Content, response.ContentType, imageType, null, cancellationToken).ConfigureAwait(false); await _providerManager.SaveImage(item, response.Content, response.ContentType, imageType, null, cancellationToken).ConfigureAwait(false);
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate; result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
break;
} }
catch (HttpException ex) catch (HttpException ex)
{ {

View File

@ -66,6 +66,9 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
</Compile>
<Compile Include="AdultVideos\AdultVideoMetadataService.cs" /> <Compile Include="AdultVideos\AdultVideoMetadataService.cs" />
<Compile Include="AdultVideos\AdultVideoXmlProvider.cs" /> <Compile Include="AdultVideos\AdultVideoXmlProvider.cs" />
<Compile Include="All\InternalMetadataFolderImageProvider.cs" /> <Compile Include="All\InternalMetadataFolderImageProvider.cs" />

View File

@ -334,7 +334,7 @@ namespace MediaBrowser.Providers.Movies
{ {
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
Url = url, Url = url,
ResourcePool = FanartArtistProvider.FanArtResourcePool ResourcePool = FanartArtistProvider.Current.FanArtResourcePool
}); });
} }
@ -410,7 +410,7 @@ namespace MediaBrowser.Providers.Movies
using (var response = await _httpClient.Get(new HttpRequestOptions using (var response = await _httpClient.Get(new HttpRequestOptions
{ {
Url = url, Url = url,
ResourcePool = FanartArtistProvider.FanArtResourcePool, ResourcePool = FanartArtistProvider.Current.FanArtResourcePool,
CancellationToken = cancellationToken CancellationToken = cancellationToken
}).ConfigureAwait(false)) }).ConfigureAwait(false))

View File

@ -346,7 +346,7 @@ namespace MediaBrowser.Providers.Music
{ {
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
Url = url, Url = url,
ResourcePool = FanartArtistProvider.FanArtResourcePool ResourcePool = FanartArtistProvider.Current.FanArtResourcePool
}); });
} }

View File

@ -22,7 +22,7 @@ namespace MediaBrowser.Providers.Music
{ {
public class FanartArtistProvider : IRemoteImageProvider, IHasChangeMonitor, IHasOrder public class FanartArtistProvider : IRemoteImageProvider, IHasChangeMonitor, IHasOrder
{ {
internal static readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(3, 3); internal readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(3, 3);
internal const string ApiKey = "5c6b04c68e904cfed1e6cbc9a9e683d4"; internal const string ApiKey = "5c6b04c68e904cfed1e6cbc9a9e683d4";
private const string FanArtBaseUrl = "http://api.fanart.tv/webservice/artist/{0}/{1}/xml/all/1/1"; private const string FanArtBaseUrl = "http://api.fanart.tv/webservice/artist/{0}/{1}/xml/all/1/1";

View File

@ -110,7 +110,7 @@ namespace MediaBrowser.Providers.Music
Url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime), Url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime),
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
EnableHttpCompression = true, EnableHttpCompression = true,
ResourcePool = FanartArtistProvider.FanArtResourcePool ResourcePool = FanartArtistProvider.Current.FanArtResourcePool
}).ConfigureAwait(false)) }).ConfigureAwait(false))
{ {

View File

@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Music
public bool Supports(IHasProviderIds item) public bool Supports(IHasProviderIds item)
{ {
return item is Audio || item is MusicAlbum; return item is Audio;
} }
} }

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Providers.Omdb
{ {
public class OmdbProvider public class OmdbProvider
{ {
internal readonly SemaphoreSlim ResourcePool = new SemaphoreSlim(1, 1); private static readonly SemaphoreSlim ResourcePool = new SemaphoreSlim(1, 1);
private readonly IJsonSerializer _jsonSerializer; private readonly IJsonSerializer _jsonSerializer;
private readonly IHttpClient _httpClient; private readonly IHttpClient _httpClient;
private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly CultureInfo _usCulture = new CultureInfo("en-US");

View File

@ -28,9 +28,4 @@ using System.Runtime.InteropServices;
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -53,6 +53,10 @@ namespace MediaBrowser.Providers.Savers
"MusicBrainzAlbumArtistId", "MusicBrainzAlbumArtistId",
"MusicBrainzAlbumId", "MusicBrainzAlbumId",
"MusicBrainzReleaseGroupId", "MusicBrainzReleaseGroupId",
// Old - not used anymore
"MusicbrainzId",
"Overview", "Overview",
"Persons", "Persons",
"PlotKeywords", "PlotKeywords",

View File

@ -264,7 +264,7 @@ namespace MediaBrowser.Providers.TV
{ {
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
Url = url, Url = url,
ResourcePool = FanartArtistProvider.FanArtResourcePool ResourcePool = FanartArtistProvider.Current.FanArtResourcePool
}); });
} }

View File

@ -111,7 +111,7 @@ namespace MediaBrowser.Providers.TV
Url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime), Url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime),
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
EnableHttpCompression = true, EnableHttpCompression = true,
ResourcePool = FanartArtistProvider.FanArtResourcePool ResourcePool = FanartArtistProvider.Current.FanArtResourcePool
}).ConfigureAwait(false)) }).ConfigureAwait(false))
{ {

View File

@ -332,7 +332,7 @@ namespace MediaBrowser.Providers.TV
{ {
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
Url = url, Url = url,
ResourcePool = FanartArtistProvider.FanArtResourcePool ResourcePool = FanartArtistProvider.Current.FanArtResourcePool
}); });
} }
@ -414,7 +414,7 @@ namespace MediaBrowser.Providers.TV
using (var response = await _httpClient.Get(new HttpRequestOptions using (var response = await _httpClient.Get(new HttpRequestOptions
{ {
Url = url, Url = url,
ResourcePool = FanartArtistProvider.FanArtResourcePool, ResourcePool = FanartArtistProvider.Current.FanArtResourcePool,
CancellationToken = cancellationToken CancellationToken = cancellationToken
}).ConfigureAwait(false)) }).ConfigureAwait(false))

View File

@ -175,23 +175,25 @@ namespace MediaBrowser.Providers.TV
var download = false; var download = false;
var automaticUpdatesEnabled = _config.Configuration.EnableTvDbUpdates; var automaticUpdatesEnabled = _config.Configuration.EnableTvDbUpdates;
const int cacheDays = 3;
var seriesFile = files.FirstOrDefault(i => string.Equals(seriesXmlFilename, i.Name, StringComparison.OrdinalIgnoreCase)); var seriesFile = files.FirstOrDefault(i => string.Equals(seriesXmlFilename, i.Name, StringComparison.OrdinalIgnoreCase));
// No need to check age if automatic updates are enabled // No need to check age if automatic updates are enabled
if (seriesFile == null || !seriesFile.Exists || (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(seriesFile)).TotalDays > 7)) if (seriesFile == null || !seriesFile.Exists || (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(seriesFile)).TotalDays > cacheDays))
{ {
download = true; download = true;
} }
var actorsXml = files.FirstOrDefault(i => string.Equals("actors.xml", i.Name, StringComparison.OrdinalIgnoreCase)); var actorsXml = files.FirstOrDefault(i => string.Equals("actors.xml", i.Name, StringComparison.OrdinalIgnoreCase));
// No need to check age if automatic updates are enabled // No need to check age if automatic updates are enabled
if (actorsXml == null || !actorsXml.Exists || (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(actorsXml)).TotalDays > 7)) if (actorsXml == null || !actorsXml.Exists || (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(actorsXml)).TotalDays > cacheDays))
{ {
download = true; download = true;
} }
var bannersXml = files.FirstOrDefault(i => string.Equals("banners.xml", i.Name, StringComparison.OrdinalIgnoreCase)); var bannersXml = files.FirstOrDefault(i => string.Equals("banners.xml", i.Name, StringComparison.OrdinalIgnoreCase));
// No need to check age if automatic updates are enabled // No need to check age if automatic updates are enabled
if (bannersXml == null || !bannersXml.Exists || (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(bannersXml)).TotalDays > 7)) if (bannersXml == null || !bannersXml.Exists || (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(bannersXml)).TotalDays > cacheDays))
{ {
download = true; download = true;
} }

View File

@ -239,10 +239,17 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
var folder = Path.GetDirectoryName(targetPath); var folder = Path.GetDirectoryName(targetPath);
var targetFileNameWithoutExtension = Path.GetFileNameWithoutExtension(targetPath); var targetFileNameWithoutExtension = Path.GetFileNameWithoutExtension(targetPath);
var filesOfOtherExtensions = Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly) try
.Where(i => EntityResolutionHelper.IsVideoFile(i) && string.Equals(Path.GetFileNameWithoutExtension(i), targetFileNameWithoutExtension, StringComparison.OrdinalIgnoreCase)); {
var filesOfOtherExtensions = Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly)
.Where(i => EntityResolutionHelper.IsVideoFile(i) && string.Equals(Path.GetFileNameWithoutExtension(i), targetFileNameWithoutExtension, StringComparison.OrdinalIgnoreCase));
episodePaths.AddRange(filesOfOtherExtensions); episodePaths.AddRange(filesOfOtherExtensions);
}
catch (DirectoryNotFoundException)
{
// No big deal. Maybe the season folder doesn't already exist.
}
return episodePaths.Where(i => !string.Equals(i, targetPath, StringComparison.OrdinalIgnoreCase)) return episodePaths.Where(i => !string.Equals(i, targetPath, StringComparison.OrdinalIgnoreCase))
.Distinct(StringComparer.OrdinalIgnoreCase) .Distinct(StringComparer.OrdinalIgnoreCase)

View File

@ -216,11 +216,7 @@ namespace MediaBrowser.ServerApplication
var initProgress = new Progress<double>(); var initProgress = new Progress<double>();
if (runService) if (!runService)
{
StartService(logManager);
}
else
{ {
ShowSplashScreen(_appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash")); ShowSplashScreen(_appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash"));
@ -235,18 +231,22 @@ namespace MediaBrowser.ServerApplication
task = _appHost.RunStartupTasks(); task = _appHost.RunStartupTasks();
Task.WaitAll(task); Task.WaitAll(task);
if (!runService) SystemEvents.SessionEnding += SystemEvents_SessionEnding;
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
if (runService)
{
StartService(logManager);
}
else
{ {
HideSplashScreen(); HideSplashScreen();
ShowTrayIcon(); ShowTrayIcon();
task = ApplicationTaskCompletionSource.Task;
Task.WaitAll(task);
} }
SystemEvents.SessionEnding += SystemEvents_SessionEnding;
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
task = ApplicationTaskCompletionSource.Task;
Task.WaitAll(task);
} }
private static ServerNotifyIcon _serverNotifyIcon; private static ServerNotifyIcon _serverNotifyIcon;