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

@ -286,16 +286,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
options.CancellationToken.ThrowIfCancellationRequested();
return new HttpResponseInfo
{
Content = httpResponse.GetResponseStream(),
StatusCode = httpResponse.StatusCode,
ContentType = httpResponse.ContentType,
Headers = httpResponse.Headers
};
return GetResponseInfo(httpResponse, httpResponse.GetResponseStream(), GetContentLength(httpResponse));
}
using (var response = await httpWebRequest.GetResponseAsync().ConfigureAwait(false))
@ -314,16 +305,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
memoryStream.Position = 0;
return new HttpResponseInfo
{
Content = memoryStream,
StatusCode = httpResponse.StatusCode,
ContentType = httpResponse.ContentType,
Headers = httpResponse.Headers
};
return GetResponseInfo(httpResponse, memoryStream, memoryStream.Length);
}
}
}
@ -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)
{
return SendAsync(options, "POST");
@ -493,16 +507,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
options.Progress.Report(100);
return new HttpResponseInfo
{
TempFilePath = tempFile,
StatusCode = httpResponse.StatusCode,
ContentType = httpResponse.ContentType,
Headers = httpResponse.Headers
};
return GetResponseInfo(httpResponse, tempFile, contentLength);
}
}
catch (OperationCanceledException ex)

View File

@ -33,6 +33,12 @@ namespace MediaBrowser.Common.Net
/// <value>The temp file path.</value>
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>
/// Gets or sets the headers.
/// </summary>

View File

@ -940,7 +940,7 @@ namespace MediaBrowser.Controller.Entities
// First get using the cached Id
if (info.ItemId != Guid.Empty)
{
item = LibraryManager.GetItemById(info.ItemId) as BaseItem;
item = LibraryManager.GetItemById(info.ItemId);
}
// If still null, search by path
@ -1098,7 +1098,9 @@ namespace MediaBrowser.Controller.Entities
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)

View File

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

View File

@ -683,6 +683,22 @@ namespace MediaBrowser.Controller.Providers
}
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":
{
var mbz = reader.ReadElementContentAsString();

View File

@ -152,6 +152,11 @@ namespace MediaBrowser.Controller.Providers
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);
}
if (string.IsNullOrEmpty(item.Path))
if (!string.IsNullOrEmpty(item.Path))
{
var name = Path.GetFileNameWithoutExtension(item.Path);

View File

@ -60,8 +60,8 @@ namespace MediaBrowser.Providers.Manager
var providerIds = new List<Guid>();
// 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 screenshotLimit = item.HasImage(ImageType.Screenshot) ? 0 : savedOptions.GetLimit(ImageType.Screenshot);
var backdropLimit = savedOptions.GetLimit(ImageType.Backdrop);
var screenshotLimit = savedOptions.GetLimit(ImageType.Screenshot);
foreach (var provider in providers)
{
@ -362,9 +362,25 @@ namespace MediaBrowser.Providers.Manager
{
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);
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
break;
}
catch (HttpException ex)
{

View File

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

View File

@ -334,7 +334,7 @@ namespace MediaBrowser.Providers.Movies
{
CancellationToken = cancellationToken,
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
{
Url = url,
ResourcePool = FanartArtistProvider.FanArtResourcePool,
ResourcePool = FanartArtistProvider.Current.FanArtResourcePool,
CancellationToken = cancellationToken
}).ConfigureAwait(false))

View File

@ -346,7 +346,7 @@ namespace MediaBrowser.Providers.Music
{
CancellationToken = cancellationToken,
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
{
internal static readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(3, 3);
internal readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(3, 3);
internal const string ApiKey = "5c6b04c68e904cfed1e6cbc9a9e683d4";
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),
CancellationToken = cancellationToken,
EnableHttpCompression = true,
ResourcePool = FanartArtistProvider.FanArtResourcePool
ResourcePool = FanartArtistProvider.Current.FanArtResourcePool
}).ConfigureAwait(false))
{

View File

@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Music
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
{
internal readonly SemaphoreSlim ResourcePool = new SemaphoreSlim(1, 1);
private static readonly SemaphoreSlim ResourcePool = new SemaphoreSlim(1, 1);
private readonly IJsonSerializer _jsonSerializer;
private readonly IHttpClient _httpClient;
private readonly CultureInfo _usCulture = new CultureInfo("en-US");

View File

@ -29,8 +29,3 @@ using System.Runtime.InteropServices;
// Build Number
// 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",
"MusicBrainzAlbumId",
"MusicBrainzReleaseGroupId",
// Old - not used anymore
"MusicbrainzId",
"Overview",
"Persons",
"PlotKeywords",

View File

@ -264,7 +264,7 @@ namespace MediaBrowser.Providers.TV
{
CancellationToken = cancellationToken,
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),
CancellationToken = cancellationToken,
EnableHttpCompression = true,
ResourcePool = FanartArtistProvider.FanArtResourcePool
ResourcePool = FanartArtistProvider.Current.FanArtResourcePool
}).ConfigureAwait(false))
{

View File

@ -332,7 +332,7 @@ namespace MediaBrowser.Providers.TV
{
CancellationToken = cancellationToken,
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
{
Url = url,
ResourcePool = FanartArtistProvider.FanArtResourcePool,
ResourcePool = FanartArtistProvider.Current.FanArtResourcePool,
CancellationToken = cancellationToken
}).ConfigureAwait(false))

View File

@ -175,23 +175,25 @@ namespace MediaBrowser.Providers.TV
var download = false;
var automaticUpdatesEnabled = _config.Configuration.EnableTvDbUpdates;
const int cacheDays = 3;
var seriesFile = files.FirstOrDefault(i => string.Equals(seriesXmlFilename, i.Name, StringComparison.OrdinalIgnoreCase));
// 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;
}
var actorsXml = files.FirstOrDefault(i => string.Equals("actors.xml", i.Name, StringComparison.OrdinalIgnoreCase));
// 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;
}
var bannersXml = files.FirstOrDefault(i => string.Equals("banners.xml", i.Name, StringComparison.OrdinalIgnoreCase));
// 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;
}

View File

@ -239,10 +239,17 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
var folder = Path.GetDirectoryName(targetPath);
var targetFileNameWithoutExtension = Path.GetFileNameWithoutExtension(targetPath);
try
{
var filesOfOtherExtensions = Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly)
.Where(i => EntityResolutionHelper.IsVideoFile(i) && string.Equals(Path.GetFileNameWithoutExtension(i), targetFileNameWithoutExtension, StringComparison.OrdinalIgnoreCase));
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))
.Distinct(StringComparer.OrdinalIgnoreCase)

View File

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